diff --git a/swad_HTML.c b/swad_HTML.c
index 465dd09a..bd3a4af3 100644
--- a/swad_HTML.c
+++ b/swad_HTML.c
@@ -856,6 +856,36 @@ void HTM_SCRIPT_End (void)
HTM_SCRIPT_NestingLevel--;
}
+/*****************************************************************************/
+/********************************* Parameters ********************************/
+/*****************************************************************************/
+
+void HTM_PARAM (const char *Name,
+ const char *fmt,...)
+ {
+ va_list ap;
+ int NumBytesPrinted;
+ char *Value;
+
+ if (fmt)
+ if (fmt[0])
+ {
+ va_start (ap,fmt);
+ NumBytesPrinted = vasprintf (&Value,fmt,ap);
+ va_end (ap);
+
+ if (NumBytesPrinted < 0) // If memory allocation wasn't possible,
+ // or some other error occurs,
+ // vasprintf will return -1
+ Lay_NotEnoughMemoryExit ();
+
+ /***** Print HTML *****/
+ fprintf (Gbl.F.Out,"\n",Name,Value);
+
+ free (Value);
+ }
+ }
+
/*****************************************************************************/
/*********************************** Labels **********************************/
/*****************************************************************************/
diff --git a/swad_HTML.h b/swad_HTML.h
index ba2af2a4..da97c8c1 100644
--- a/swad_HTML.h
+++ b/swad_HTML.h
@@ -103,6 +103,9 @@ void HTM_A_End (void);
void HTM_SCRIPT_Begin (const char *URL,const char *CharSet);
void HTM_SCRIPT_End (void);
+void HTM_PARAM (const char *Name,
+ const char *fmt,...);
+
void HTM_LABEL_Begin (const char *fmt,...);
void HTM_LABEL_End (void);
diff --git a/swad_changelog.h b/swad_changelog.h
index a9a5d986..f96d34d3 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -487,7 +487,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
-#define Log_PLATFORM_VERSION "SWAD 19.58 (2019-11-09)"
+#define Log_PLATFORM_VERSION "SWAD 19.59 (2019-11-09)"
#define CSS_FILE "swad19.47.css"
#define JS_FILE "swad19.39.js"
/*
@@ -495,6 +495,7 @@ ps2pdf source.ps destination.pdf
// TODO: Impedir la creación y edición de proyectos si no son editables.
// TODO: Importante: filtrar proyectos por usuarios (igual que en trabajos o en asistencia)
+ Version 19.59: Nov 09, 2019 Code refactoring in HTML params. (246187 lines)
Version 19.58: Nov 09, 2019 Code refactoring in HTML definition lists. (246169 lines)
Version 19.57: Nov 09, 2019 Code refactoring in HTML definition lists. (246156 lines)
Version 19.56: Nov 08, 2019 Fixed bug in groups.
diff --git a/swad_chat.c b/swad_chat.c
index 3453ea45..c3fa9193 100644
--- a/swad_chat.c
+++ b/swad_chat.c
@@ -593,25 +593,16 @@ void Cht_OpenChatWindow (void)
Str_NO_SKIP_HTML_COMMENTS);
/***** Write parameters *****/
- fprintf (Gbl.F.Out,"\n",
- Gbl.Session.Id);
- fprintf (Gbl.F.Out,"\n",
- UsrName);
- fprintf (Gbl.F.Out,"\n",
- Gbl.IP);
- fprintf (Gbl.F.Out,"\n",
- Cfg_PLATFORM_SERVER);
- fprintf (Gbl.F.Out,"\n");
- fprintf (Gbl.F.Out,"\n",
- Cfg_URL_ICON_PUBLIC);
- fprintf (Gbl.F.Out,"\n",
- Cfg_URL_PHOTO_PUBLIC,Gbl.Usrs.Me.UsrDat.Photo);
- fprintf (Gbl.F.Out,"\n",
- ListRoomCodes);
- fprintf (Gbl.F.Out,"\n",
- ListRoomShrtNames);
- fprintf (Gbl.F.Out,"\n",
- ListRoomFullNames);
+ HTM_PARAM ("nick","N%s",Gbl.Session.Id);
+ HTM_PARAM ("realname","%s",UsrName);
+ HTM_PARAM ("host","%s",Gbl.IP);
+ HTM_PARAM ("server_name","%s",Cfg_PLATFORM_SERVER);
+ HTM_PARAM ("port","%u",5000);
+ HTM_PARAM ("image_bl","%s/usr_bl.jpg",Cfg_URL_ICON_PUBLIC);
+ HTM_PARAM ("image_url","%s/%s.jpg",Cfg_URL_PHOTO_PUBLIC,Gbl.Usrs.Me.UsrDat.Photo);
+ HTM_PARAM ("channel_name","%s",ListRoomCodes);
+ HTM_PARAM ("tab","%s",ListRoomShrtNames);
+ HTM_PARAM ("topic","%s",ListRoomFullNames);
/***** Copy index.html file until the end *****/
Str_WriteUntilStrFoundInFileIncludingStr (Gbl.F.Out,FileChat,"