Version 21.83.7: Mar 16, 2022 Code refactoring in forms (input image).

This commit is contained in:
acanas 2022-03-16 01:18:12 +01:00
parent 925c2f6a9b
commit 908eae19dc
13 changed files with 72 additions and 65 deletions

View File

@ -1246,17 +1246,40 @@ void HTM_INPUT_BUTTON (const char *Name,const char *Value,const char *Attr)
Attr); Attr);
} }
void HTM_INPUT_IMAGE (const char *URL,const char *Icon, void HTM_INPUT_IMAGE (const char *URL,const char *Icon,const char *Title,
const char *Title,const char *Class) const char *fmt,...)
{ {
va_list ap;
int NumBytesPrinted;
char *Attr;
HTM_TxtF ("<input type=\"image\" src=\"%s",URL); HTM_TxtF ("<input type=\"image\" src=\"%s",URL);
if (Icon) if (Icon)
if (Icon[0]) if (Icon[0])
HTM_TxtF ("/%s",Icon); HTM_TxtF ("/%s",Icon);
HTM_Txt ("\""); HTM_Txt ("\"");
HTM_TxtF (" alt=\"%s\" title=\"%s\" class=\"%s\" />", HTM_TxtF (" alt=\"%s\" title=\"%s\"",
Title,Title,Class); Title,Title);
if (fmt)
{
if (fmt[0])
{
va_start (ap,fmt);
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
free (Attr);
}
}
HTM_Txt (" />");
} }
void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder, void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder,

View File

@ -148,8 +148,8 @@ void HTM_INPUT_FILE (const char *Name,const char *Accept,
HTM_SubmitOnChange_t SubmitOnChange, HTM_SubmitOnChange_t SubmitOnChange,
const char *fmt,...); const char *fmt,...);
void HTM_INPUT_BUTTON (const char *Name,const char *Value,const char *Attr); void HTM_INPUT_BUTTON (const char *Name,const char *Value,const char *Attr);
void HTM_INPUT_IMAGE (const char *URL,const char *Icon, void HTM_INPUT_IMAGE (const char *URL,const char *Icon,const char *Title,
const char *Title,const char *Class); const char *fmt,...);
void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder, void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder,
const char *AutoComplete,bool Required, const char *AutoComplete,bool Required,
const char *fmt,...); const char *fmt,...);

View File

@ -1051,7 +1051,8 @@ void Ban_WriteMenuWithBanners (void)
/* Banner image */ /* Banner image */
HTM_INPUT_IMAGE (Cfg_URL_BANNER_PUBLIC,Banners.Lst[NumBan].Img, HTM_INPUT_IMAGE (Cfg_URL_BANNER_PUBLIC,Banners.Lst[NumBan].Img,
Banners.Lst[NumBan].FullName,"BANNER"); Banners.Lst[NumBan].FullName,
"class=\"BANNER\"");
/* End form */ /* End form */
Frm_EndForm (); Frm_EndForm ();

View File

@ -5138,7 +5138,6 @@ static void Brw_PutIconFileWithLinkToViewMetadata (struct FileMetadata *FileMeta
{ {
extern const char *Ico_ClassColor[Ico_NUM_COLORS][The_NUM_THEMES]; extern const char *Ico_ClassColor[Ico_NUM_COLORS][The_NUM_THEMES];
extern const char *Txt_Link; extern const char *Txt_Link;
char *Class;
/***** Begin cell *****/ /***** Begin cell *****/
HTM_TD_Begin ("class=\"BM %s\"",Gbl.ColorRows[Gbl.RowEvenOdd]); HTM_TD_Begin ("class=\"BM %s\"",Gbl.ColorRows[Gbl.RowEvenOdd]);
@ -5151,18 +5150,14 @@ static void Brw_PutIconFileWithLinkToViewMetadata (struct FileMetadata *FileMeta
FileMetadata->FilCod); FileMetadata->FilCod);
/***** Icon depending on the file extension *****/ /***** Icon depending on the file extension *****/
if (FileMetadata->FilFolLnk.Type == Brw_IS_FILE) if (FileMetadata->FilFolLnk.Type == Brw_IS_FILE)
Brw_PutIconFile (FileMetadata->FilFolLnk.Name, Brw_PutIconFile (FileMetadata->FilFolLnk.Name,
"CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16", "CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16",
true); // Put link to view metadata true); // Put link to view metadata
else else
{ HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"link.svg",Txt_Link,
if (asprintf (&Class,"CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16 %s", "class=\"CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16 %s\"",
Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]) < 0) Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]);
Err_NotEnoughMemoryExit ();
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"link.svg",Txt_Link,Class);
free (Class);
}
/***** End form *****/ /***** End form *****/
Frm_EndForm (); Frm_EndForm ();
@ -5212,10 +5207,9 @@ static void Brw_PutIconFile (const char *FileName,
} }
if (PutLinkToViewMetadata) if (PutLinkToViewMetadata)
HTM_INPUT_IMAGE (URL,Icon,Title,Class); HTM_INPUT_IMAGE (URL,Icon,Title,"class=\"%s\"",Class);
else else
HTM_IMG (URL,Icon,Title, HTM_IMG (URL,Icon,Title,"class=\"%s\"",Class);
"class=\"%s\"",Class);
free (Title); free (Title);
free (Icon); free (Icon);
free (URL); free (URL);

View File

@ -606,10 +606,11 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate
TODO: Attach pdf files in multimedia. TODO: Attach pdf files in multimedia.
*/ */
#define Log_PLATFORM_VERSION "SWAD 21.83.6 (2022-03-15)" #define Log_PLATFORM_VERSION "SWAD 21.83.7 (2022-03-16)"
#define CSS_FILE "swad21.83.5.css" #define CSS_FILE "swad21.83.5.css"
#define JS_FILE "swad21.78.2.js" #define JS_FILE "swad21.78.2.js"
/* /*
Version 21.83.7: Mar 16, 2022 Code refactoring in forms (input image). (323585 lines)
Version 21.83.6: Mar 15, 2022 Working on design of dark theme. (323581 lines) Version 21.83.6: Mar 15, 2022 Working on design of dark theme. (323581 lines)
Version 21.83.5: Mar 15, 2022 Working on design of dark theme. (323559 lines) Version 21.83.5: Mar 15, 2022 Working on design of dark theme. (323559 lines)
Version 21.83.4: Mar 11, 2022 Code refactoring in timetable. (323543 lines) Version 21.83.4: Mar 11, 2022 Code refactoring in timetable. (323543 lines)

View File

@ -425,7 +425,8 @@ static void Con_ShowConnectedUsrsWithARoleBelongingToCurrentCrsOnRightColumn (Ro
// is dynamically updated via AJAX // is dynamically updated via AJAX
Sco_PutParamScope ("ScopeCon",HieLvl_CRS); Sco_PutParamScope ("ScopeCon",HieLvl_CRS);
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"ellipsis-h.svg", HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"ellipsis-h.svg",
Txt_Connected_users,"ICO16x16"); Txt_Connected_users,
"class=\"ICO16x16\"");
Frm_EndForm (); Frm_EndForm ();
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();

View File

@ -2220,7 +2220,7 @@ void Crs_PutIconToSelectMyCoursesInBreadcrumb (void)
/***** Put icon with link *****/ /***** Put icon with link *****/
HTM_INPUT_IMAGE (Gbl.Prefs.URLTheme,"sitemap.svg",Txt_My_courses, HTM_INPUT_IMAGE (Gbl.Prefs.URLTheme,"sitemap.svg",Txt_My_courses,
"BC_ICON ICO_HIGHLIGHT"); "class=\"BC_ICON ICO_HIGHLIGHT\"");
/***** End form *****/ /***** End form *****/
Frm_EndForm (); Frm_EndForm ();

View File

@ -368,7 +368,7 @@ void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat,
"user-plus.svg", "user-plus.svg",
IFollowUsr ? Txt_Following_unfollow : IFollowUsr ? Txt_Following_unfollow :
Txt_Follow, Txt_Follow,
"ICO_HIGHLIGHT ICO40x40"); "class=\"ICO_HIGHLIGHT ICO40x40\"");
Frm_EndForm (); Frm_EndForm ();
} }
HTM_DIV_End (); HTM_DIV_End ();
@ -749,16 +749,13 @@ static void Fol_PutIconToFollow (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_
{ {
extern const char *Ico_ClassColor[Ico_NUM_COLORS][The_NUM_THEMES]; extern const char *Ico_ClassColor[Ico_NUM_COLORS][The_NUM_THEMES];
extern const char *Txt_Follow; extern const char *Txt_Follow;
char *Class;
/***** Form to unfollow *****/ /***** Form to unfollow *****/
Frm_BeginForm (ActFolUsr); Frm_BeginForm (ActFolUsr);
Usr_PutParamUsrCodEncrypted (EncryptedUsrCod); Usr_PutParamUsrCodEncrypted (EncryptedUsrCod);
if (asprintf (&Class,"FOLLOW_USR_ICO ICO16x16 %s ICO_HIGHLIGHT", HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-plus.svg",Txt_Follow,
Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]) < 0) "class=\"FOLLOW_USR_ICO ICO16x16 %s ICO_HIGHLIGHT\"",
Err_NotEnoughMemoryExit (); Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]);
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-plus.svg",Txt_Follow,Class);
free (Class);
Frm_EndForm (); Frm_EndForm ();
} }
@ -774,7 +771,8 @@ static void Fol_PutIconToUnfollow (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTE
Frm_BeginForm (ActUnfUsr); Frm_BeginForm (ActUnfUsr);
Usr_PutParamUsrCodEncrypted (EncryptedUsrCod); Usr_PutParamUsrCodEncrypted (EncryptedUsrCod);
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-check.svg", HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-check.svg",
Txt_Unfollow,"FOLLOW_USR_ICO ICO_HIGHLIGHT ICO16x16"); Txt_Unfollow,
"class=\"FOLLOW_USR_ICO ICO_HIGHLIGHT ICO16x16\"");
Frm_EndForm (); Frm_EndForm ();
} }

View File

@ -454,13 +454,9 @@ void Ico_PutDivIcon (const char *DivClass,const char *Icon,Ico_Color_t Color,con
void Ico_PutIconLink (const char *Icon,Ico_Color_t Color,const char *Title) void Ico_PutIconLink (const char *Icon,Ico_Color_t Color,const char *Title)
{ {
char *Class; HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon,Title,
"class=\"CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16 %s\"",
if (asprintf (&Class,"CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16 %s", Ico_ClassColor[Color][Gbl.Prefs.Theme]);
Ico_ClassColor[Color][Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon,Title,Class);
free (Class);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -482,13 +478,9 @@ void Ico_PutIconTextLink (const char *Icon,Ico_Color_t Color,const char *Text)
void Ico_PutSettingIconLink (const char *Icon,Ico_Color_t Color,const char *Title) void Ico_PutSettingIconLink (const char *Icon,Ico_Color_t Color,const char *Title)
{ {
char *Class; HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon,Title,
"class=\"ICO_HIGHLIGHT ICOx20 %s\"",
if (asprintf (&Class,"ICO_HIGHLIGHT ICOx20 %s", Ico_ClassColor[Color][Gbl.Prefs.Theme]);
Ico_ClassColor[Color][Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon,Title,Class);
free (Class);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1007,12 +1007,14 @@ static void Lay_WritePageTopHeading (void)
HTM_DIV_Begin ("id=\"head_row_1_logo_small\""); HTM_DIV_Begin ("id=\"head_row_1_logo_small\"");
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Cfg_PLATFORM_LOGO_SMALL_FILENAME, HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Cfg_PLATFORM_LOGO_SMALL_FILENAME,
Cfg_PLATFORM_SHORT_NAME,Cfg_PLATFORM_LOGO_SMALL_CLASS); Cfg_PLATFORM_SHORT_NAME,
"class=\"%s\"",Cfg_PLATFORM_LOGO_SMALL_CLASS);
HTM_DIV_End (); // head_row_1_logo_small HTM_DIV_End (); // head_row_1_logo_small
HTM_DIV_Begin ("id=\"head_row_1_logo_big\""); HTM_DIV_Begin ("id=\"head_row_1_logo_big\"");
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Cfg_PLATFORM_LOGO_BIG_FILENAME, HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Cfg_PLATFORM_LOGO_BIG_FILENAME,
Cfg_PLATFORM_SHORT_NAME,Cfg_PLATFORM_LOGO_BIG_CLASS); Cfg_PLATFORM_SHORT_NAME,
"class=\"%s\"",Cfg_PLATFORM_LOGO_BIG_CLASS);
HTM_DIV_End (); // head_row_1_logo_big HTM_DIV_End (); // head_row_1_logo_big
HTM_DIV_Begin ("id=\"head_row_1_tagline\" class=\"TAGLINE_%s\"", HTM_DIV_Begin ("id=\"head_row_1_tagline\" class=\"TAGLINE_%s\"",

View File

@ -1319,7 +1319,8 @@ static void Mch_PutFormNewMatch (const struct Gam_Game *Game)
/***** Put icon to submit the form *****/ /***** Put icon to submit the form *****/
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"play.svg", HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"play.svg",
Txt_Play,"CONTEXT_OPT ICO_HIGHLIGHT ICO64x64"); Txt_Play,
"class=\"CONTEXT_OPT ICO_HIGHLIGHT ICO64x64\"");
/***** End box *****/ /***** End box *****/
Box_BoxEnd (); Box_BoxEnd ();

View File

@ -70,7 +70,6 @@ void PhoSha_PutIconsToSelectPhotoShape (void)
[PhoSha_SHAPE_RECTANGLE] = "ICO_HIGHLIGHT PHOTOR15x20B", [PhoSha_SHAPE_RECTANGLE] = "ICO_HIGHLIGHT PHOTOR15x20B",
}; };
PhoSha_Shape_t Shape; PhoSha_Shape_t Shape;
char *Class;
Box_BoxBegin (NULL,Txt_User_photos, Box_BoxBegin (NULL,Txt_User_photos,
PhoSha_PutIconsPhotoShape,NULL, PhoSha_PutIconsPhotoShape,NULL,
@ -88,13 +87,11 @@ void PhoSha_PutIconsToSelectPhotoShape (void)
HTM_DIV_Begin ("class=\"PREF_OFF\""); HTM_DIV_Begin ("class=\"PREF_OFF\"");
Frm_BeginForm (ActChgUsrPho); Frm_BeginForm (ActChgUsrPho);
Par_PutHiddenParamUnsigned (NULL,"PhotoShape",Shape); Par_PutHiddenParamUnsigned (NULL,"PhotoShape",Shape);
if (asprintf (&Class,"%s %s",
ClassPhoto[Shape],
Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user.svg", HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user.svg",
Txt_PHOTO_SHAPES[Shape],Class); Txt_PHOTO_SHAPES[Shape],
free (Class); "class=\"%s %s\"",
ClassPhoto[Shape],
Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]);
Frm_EndForm (); Frm_EndForm ();
HTM_DIV_End (); HTM_DIV_End ();
} }

View File

@ -6510,7 +6510,6 @@ void Usr_PutWhoIcon (Usr_Who_t Who)
[Usr_WHO_FOLLOWED] = "user-check.svg", [Usr_WHO_FOLLOWED] = "user-check.svg",
[Usr_WHO_ALL ] = "users.svg", [Usr_WHO_ALL ] = "users.svg",
}; };
char *Class;
switch (Who) switch (Who)
{ {
@ -6522,16 +6521,14 @@ void Usr_PutWhoIcon (Usr_Who_t Who)
Gbl.Usrs.Me.PhotoURL[0] ? NULL : Gbl.Usrs.Me.PhotoURL[0] ? NULL :
"usr_bl.jpg", "usr_bl.jpg",
Txt_WHO[Who], Txt_WHO[Who],
"ICO_HIGHLIGHT PHOTOR15x20"); "class=\"ICO_HIGHLIGHT PHOTOR15x20\"");
break; break;
case Usr_WHO_SELECTED: case Usr_WHO_SELECTED:
case Usr_WHO_FOLLOWED: case Usr_WHO_FOLLOWED:
case Usr_WHO_ALL: case Usr_WHO_ALL:
if (asprintf (&Class,"ICO_HIGHLIGHT ICOx20 %s", HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon[Who],Txt_WHO[Who],
Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]) < 0) "class=\"ICO_HIGHLIGHT ICOx20 %s\"",
Err_NotEnoughMemoryExit (); Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]);
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon[Who],Txt_WHO[Who],Class);
free (Class);
break; break;
default: default:
Err_WrongWhoExit (); Err_WrongWhoExit ();