diff --git a/swad_HTML.c b/swad_HTML.c index 9e096770..1a7cf4f5 100644 --- a/swad_HTML.c +++ b/swad_HTML.c @@ -55,18 +55,19 @@ extern struct Globals Gbl; /***************************** Private vatiables *****************************/ /*****************************************************************************/ -static unsigned HTM_TABLE_NestingLevel = 0; -static unsigned HTM_TR_NestingLevel = 0; -static unsigned HTM_TH_NestingLevel = 0; -static unsigned HTM_TD_NestingLevel = 0; -static unsigned HTM_DIV_NestingLevel = 0; -static unsigned HTM_UL_NestingLevel = 0; -static unsigned HTM_LI_NestingLevel = 0; -static unsigned HTM_A_NestingLevel = 0; -static unsigned HTM_SCRIPT_NestingLevel = 0; -static unsigned HTM_LABEL_NestingLevel = 0; +static unsigned HTM_TABLE_NestingLevel = 0; +static unsigned HTM_TR_NestingLevel = 0; +static unsigned HTM_TH_NestingLevel = 0; +static unsigned HTM_TD_NestingLevel = 0; +static unsigned HTM_DIV_NestingLevel = 0; +static unsigned HTM_SPAN_NestingLevel = 0; +static unsigned HTM_UL_NestingLevel = 0; +static unsigned HTM_LI_NestingLevel = 0; +static unsigned HTM_A_NestingLevel = 0; +static unsigned HTM_SCRIPT_NestingLevel = 0; +static unsigned HTM_LABEL_NestingLevel = 0; static unsigned HTM_TEXTAREA_NestingLevel = 0; -static unsigned HTM_SELECT_NestingLevel = 0; +static unsigned HTM_SELECT_NestingLevel = 0; /*****************************************************************************/ /***************************** Private prototypes ****************************/ @@ -83,6 +84,8 @@ static void HTM_TD_BeginWithoutAttr (void); static void HTM_DIV_BeginWithoutAttr (void); +static void HTM_SPAN_BeginWithoutAttr (void); + static void HTM_UL_BeginWithoutAttr (void); static void HTM_LI_BeginWithoutAttr (void); @@ -558,6 +561,58 @@ void HTM_SECTION_End (void) fprintf (Gbl.F.Out,""); } +/*****************************************************************************/ +/*********************************** Spans ***********************************/ +/*****************************************************************************/ + +void HTM_SPAN_Begin (const char *fmt,...) + { + va_list ap; + int NumBytesPrinted; + char *Attr; + + if (fmt) + { + if (fmt[0]) + { + va_start (ap,fmt); + NumBytesPrinted = vasprintf (&Attr,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,"",Attr); + + free (Attr); + } + else + HTM_SPAN_BeginWithoutAttr (); + } + else + HTM_SPAN_BeginWithoutAttr (); + + HTM_SPAN_NestingLevel++; + } + +static void HTM_SPAN_BeginWithoutAttr (void) + { + fprintf (Gbl.F.Out,""); + } + +void HTM_SPAN_End (void) + { + if (HTM_SPAN_NestingLevel == 0) // No SPAN open + Ale_ShowAlert (Ale_ERROR,"Trying to close unopened SPAN."); + + fprintf (Gbl.F.Out,""); + + HTM_SPAN_NestingLevel--; + } + /*****************************************************************************/ /****************************** Unordered lists ******************************/ /*****************************************************************************/ diff --git a/swad_HTML.h b/swad_HTML.h index 2a6d52c6..da8d570f 100644 --- a/swad_HTML.h +++ b/swad_HTML.h @@ -81,6 +81,9 @@ void HTM_ARTICLE_End (void); void HTM_SECTION_Begin (const char *SectionId); void HTM_SECTION_End (void); +void HTM_SPAN_Begin (const char *fmt,...); +void HTM_SPAN_End (void); + void HTM_UL_Begin (const char *fmt,...); void HTM_UL_End (void); diff --git a/swad_ID.c b/swad_ID.c index cec9d2f7..d6bf3bfd 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -386,14 +386,14 @@ void ID_WriteUsrIDs (struct UsrData *UsrDat,const char *Anchor) if (NumID) fprintf (Gbl.F.Out,"
"); - fprintf (Gbl.F.Out,"", - UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" : - "USR_ID_NC"); + HTM_SPAN_Begin ("class=\"%s\"", + UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" : + "USR_ID_NC"); if (ICanSeeUsrID) fprintf (Gbl.F.Out,"%s",UsrDat->IDs.List[NumID].ID); else fprintf (Gbl.F.Out,"********"); - fprintf (Gbl.F.Out,""); + HTM_SPAN_End (); if (ICanConfirmUsrID && !UsrDat->IDs.List[NumID].Confirmed) @@ -655,13 +655,15 @@ static void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat, UsrDat->IDs.List[NumID].Confirmed ? Txt_ID_X_confirmed : Txt_ID_X_not_confirmed, UsrDat->IDs.List[NumID].ID); - fprintf (Gbl.F.Out,"%s%s", - UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" : - "USR_ID_NC", - Gbl.Title, + HTM_SPAN_Begin ("class=\"%s\" title=\"%s\"", + UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" : + "USR_ID_NC", + Gbl.Title); + fprintf (Gbl.F.Out,"%s%s", UsrDat->IDs.List[NumID].ID, UsrDat->IDs.List[NumID].Confirmed ? "✓" : ""); + HTM_SPAN_End (); if (NumID == UsrDat->IDs.Num - 1) { HTM_TD_End (); diff --git a/swad_attendance.c b/swad_attendance.c index 892abda5..2b759032 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -3132,7 +3132,8 @@ static void Att_ListEventsToSelect (Att_TypeOfView_t TypeOfView) Lay_NotEnoughMemoryExit (); HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd); HTM_LABEL_Begin ("for=\"Att%u\"",NumAttEvent); - fprintf (Gbl.F.Out,"",Id); + HTM_SPAN_Begin ("id=\"%s\"",Id); + HTM_SPAN_End (); HTM_LABEL_End (); Dat_WriteLocalDateHMSFromUTC (Id,Gbl.AttEvents.Lst[NumAttEvent].TimeUTC[Att_START_TIME], Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, @@ -3575,10 +3576,9 @@ static void Att_ListAttEventsForAStd (unsigned NumUsr,struct UsrData *UsrDat) if (asprintf (&Id,"att_date_start_%u_%u",NumUsr,UniqueId) < 0) Lay_NotEnoughMemoryExit (); HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd); - fprintf (Gbl.F.Out,"" - "
%s", - Id, - Gbl.AttEvents.Lst[NumAttEvent].Title); + HTM_SPAN_Begin ("id=\"%s\"",Id); + HTM_SPAN_End (); + fprintf (Gbl.F.Out,"
%s",Gbl.AttEvents.Lst[NumAttEvent].Title); Dat_WriteLocalDateHMSFromUTC (Id,Gbl.AttEvents.Lst[NumAttEvent].TimeUTC[Att_START_TIME], Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, true,true,true,0x7); diff --git a/swad_changelog.h b/swad_changelog.h index b47328c9..7255c42d 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -490,7 +490,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.54.10 (2019-11-07)" +#define Log_PLATFORM_VERSION "SWAD 19.55 (2019-11-07)" #define CSS_FILE "swad19.47.css" #define JS_FILE "swad19.39.js" /* @@ -498,6 +498,8 @@ 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.55: Nov 07, 2019 Code refactoring in HTML spans. + Fixed bug in groups. (246058 lines) Version 19.54.10: Nov 07, 2019 Code refactoring in HTML select options. (245888 lines) Version 19.54.9: Nov 07, 2019 Code refactoring in HTML select options. Fixed bug in dates form. (245936 lines) diff --git a/swad_date.c b/swad_date.c index f2a847bd..9c376e46 100644 --- a/swad_date.c +++ b/swad_date.c @@ -159,8 +159,8 @@ static void Dat_PutIconsDateFormat (void) void Dat_PutSpanDateFormat (Dat_Format_t Format) { - fprintf (Gbl.F.Out,"", - (unsigned) Format); + HTM_SPAN_Begin ("id=\"date_format_%u\"",(unsigned) Format); + HTM_SPAN_End (); } void Dat_PutScriptDateFormat (Dat_Format_t Format) @@ -318,8 +318,9 @@ void Dat_ShowClientLocalTime (void) HTM_DIV_Begin ("id=\"current_month\""); Frm_StartForm (ActSeeCal); Frm_LinkFormSubmit (Txt_Show_calendar,"CURRENT_MONTH",NULL); - fprintf (Gbl.F.Out,"" // JavaScript will write HTML here - ""); + HTM_SPAN_Begin ("id=\"current_month_txt\""); + // JavaScript will write HTML here + HTM_SPAN_End (); Frm_LinkFormEnd (); Frm_EndForm (); HTM_DIV_End (); @@ -331,8 +332,9 @@ void Dat_ShowClientLocalTime (void) Frm_StartForm (ActSeeMyAgd); Frm_LinkFormSubmit (Txt_Show_agenda,"CURRENT_DAY",NULL); } - fprintf (Gbl.F.Out,"" // JavaScript will write HTML here - ""); + HTM_SPAN_Begin ("id=\"current_day_txt\""); + // JavaScript will write HTML here + HTM_SPAN_End (); if (Gbl.Usrs.Me.Logged) { Frm_LinkFormEnd (); diff --git a/swad_exam.c b/swad_exam.c index a31148ec..666d77ca 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -1047,7 +1047,7 @@ static void Exa_ShowExamAnnouncement (long ExaCod, HTM_TR_Begin (NULL); HTM_TD_Begin ("colspan=\"2\" class=\"CM\""); if (TypeViewExamAnnouncement == Exa_PRINT_VIEW) - fprintf (Gbl.F.Out,"",StyleTitle); + HTM_SPAN_Begin ("class=\"%s\"",StyleTitle); else HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"%s\"", Ins.WWW,StyleTitle); @@ -1055,7 +1055,7 @@ static void Exa_ShowExamAnnouncement (long ExaCod, fprintf (Gbl.F.Out,"
%s", Ins.FullName); if (TypeViewExamAnnouncement == Exa_PRINT_VIEW) - fprintf (Gbl.F.Out,"
"); + HTM_SPAN_End (); else HTM_A_End (); HTM_TD_End (); diff --git a/swad_file_browser.c b/swad_file_browser.c index 2ec933dd..3a9f4af7 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -6271,13 +6271,12 @@ static void Brw_WriteFileName (unsigned Level,bool IsPublic) if ((Level == 1) && (Gbl.FileBrowser.Type == Brw_ADMI_ASG_USR || Gbl.FileBrowser.Type == Brw_ADMI_ASG_CRS)) - fprintf (Gbl.F.Out,"", - Gbl.FileBrowser.Asg.Title); + HTM_SPAN_Begin ("title=\"%s\"",Gbl.FileBrowser.Asg.Title); fprintf (Gbl.F.Out,"%s ",FileNameToShow); if ((Level == 1) && (Gbl.FileBrowser.Type == Brw_ADMI_ASG_USR || Gbl.FileBrowser.Type == Brw_ADMI_ASG_CRS)) - fprintf (Gbl.F.Out,""); + HTM_SPAN_End (); } /***** End cell *****/ @@ -6392,11 +6391,11 @@ static void Brw_WriteDatesAssignment (void) /***** Write start date *****/ if (asprintf (&Id,"asg_start_date_%u",UniqueId) < 0) Lay_NotEnoughMemoryExit (); - fprintf (Gbl.F.Out,"",Id); + HTM_SPAN_Begin ("id=\"%s\"",Id); Dat_WriteLocalDateHMSFromUTC (Id,Gbl.FileBrowser.Asg.TimeUTC[Dat_START_TIME], Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, true,true,false,0x7); - fprintf (Gbl.F.Out,""); + HTM_SPAN_End (); free (Id); /***** Arrow *****/ @@ -6405,11 +6404,11 @@ static void Brw_WriteDatesAssignment (void) /***** Write end date *****/ if (asprintf (&Id,"asg_end_date_%u",UniqueId) < 0) Lay_NotEnoughMemoryExit (); - fprintf (Gbl.F.Out,"",Id); + HTM_SPAN_Begin ("id=\"%s\"",Id); Dat_WriteLocalDateHMSFromUTC (Id,Gbl.FileBrowser.Asg.TimeUTC[Dat_END_TIME], Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, true,false,false,0x7); - fprintf (Gbl.F.Out,""); + HTM_SPAN_End (); free (Id); } else @@ -6447,7 +6446,8 @@ static void Brw_WriteFileSizeAndDate (struct FileMetadata *FileMetadata) UniqueId++; if (asprintf (&Id,"filedate%u",UniqueId) < 0) Lay_NotEnoughMemoryExit (); - fprintf (Gbl.F.Out,"",Id); + HTM_SPAN_Begin ("id=\"%s\"",Id); + HTM_SPAN_End (); Dat_WriteLocalDateHMSFromUTC (Id,FileMetadata->Time, Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, true,true,false,0x6); @@ -8386,9 +8386,11 @@ static void Brw_PutFormToUploadFilesUsingDropzone (const char *FileNameToShow) Brw_PutImplicitParamsFileBrowser (); HTM_DIV_Begin ("class=\"dz-message\""); - fprintf (Gbl.F.Out,"%s", - Txt_Select_one_or_more_files_from_your_computer_or_drag_and_drop_here); + HTM_SPAN_Begin ("class=\"DAT_LIGHT\""); + fprintf (Gbl.F.Out,"%s",Txt_Select_one_or_more_files_from_your_computer_or_drag_and_drop_here); + HTM_SPAN_End (); HTM_DIV_End (); + fprintf (Gbl.F.Out,""); /***** Put button to refresh file browser after upload *****/ diff --git a/swad_follow.c b/swad_follow.c index 561c0b4f..2818f95c 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -610,9 +610,8 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat, "FOLLOW_NUM",NULL); } else - fprintf (Gbl.F.Out,"", - (Gbl.Action.Act == Action) ? "FOLLOW_NUM_B" : - "FOLLOW_NUM"); + HTM_SPAN_Begin ("class=\"%s\"",(Gbl.Action.Act == Action) ? "FOLLOW_NUM_B" : + "FOLLOW_NUM"); fprintf (Gbl.F.Out,"%u",NumUsrs); if (NumUsrs) { @@ -620,7 +619,7 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat, Frm_EndForm (); } else - fprintf (Gbl.F.Out,""); + HTM_SPAN_End (); /***** Text *****/ HTM_DIV_Begin ("class=\"%s\"", diff --git a/swad_forum.c b/swad_forum.c index 0997a64f..104e90fb 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -1240,11 +1240,11 @@ static void For_ShowAForumPost (unsigned PstNum,long PstCod, Enabled ? Txt_FORUM_Post_X_allowed : Txt_FORUM_Post_X_banned, PstNum); - fprintf (Gbl.F.Out,"",Gbl.Title); // TODO: Remove? + HTM_SPAN_Begin ("title=\"%s\"",Gbl.Title); // TODO: Remove? Ico_PutIcon (Enabled ? "eye.svg" : "eye-slash.svg", Gbl.Title,"ICO_HIDDEN ICO16x16"); - fprintf (Gbl.F.Out,""); // TODO: Remove? + HTM_SPAN_End (); // TODO: Remove? } /***** Form to remove post *****/ diff --git a/swad_group.c b/swad_group.c index 48671c8f..ee9bbf25 100644 --- a/swad_group.c +++ b/swad_group.c @@ -2270,8 +2270,9 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, HTM_TD_Begin ("class=\"LM\""); HTM_INPUT_CHECKBOX ("GrpCods",false, - "id=\"Grp%ld\" value=\"%ld\"%s%s onclick=\"checkParent(this,'AllGroups')\"", - -(GrpTyp->GrpTypCod),-(GrpTyp->GrpTypCod), + "id=\"Grp%ld\" value=\"%ld\"%s" + " onclick=\"checkParent(this,'AllGroups')\"", + -GrpTyp->GrpTypCod,-GrpTyp->GrpTypCod, ICanSelUnselGroup ? (Checked ? " checked=\"checked\"" : "") : " disabled=\"disabled\""); HTM_TD_End (); @@ -2332,10 +2333,9 @@ static void Grp_WriteGrpHead (struct GroupType *GrpTyp) UniqueId++; if (asprintf (&Id,"open_time_%u",UniqueId) < 0) Lay_NotEnoughMemoryExit (); - fprintf (Gbl.F.Out,"
%s: " - "", - Txt_Opening_of_groups, - Id); + fprintf (Gbl.F.Out,"
%s: ",Txt_Opening_of_groups); + HTM_SPAN_Begin ("id=\"%s\"",Id); + HTM_SPAN_End (); Dat_WriteLocalDateHMSFromUTC (Id,GrpTyp->OpenTimeUTC, Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, true,true,true,0x7); diff --git a/swad_info.c b/swad_info.c index 63e3f588..40a78e6b 100644 --- a/swad_info.c +++ b/swad_info.c @@ -1166,8 +1166,11 @@ void Inf_FormsToSelSendInfo (void) fprintf (Gbl.F.Out,"%s",Txt_INFO_SRC_FULL_TEXT[InfoSrc]); HTM_LABEL_End (); if (Txt_INFO_SRC_HELP[InfoSrc]) - fprintf (Gbl.F.Out,"
(%s)
", - Txt_INFO_SRC_HELP[InfoSrc]); + { + HTM_SPAN_Begin ("class=\"DAT\""); + fprintf (Gbl.F.Out,"
(%s)",Txt_INFO_SRC_HELP[InfoSrc]); + HTM_SPAN_End (); + } if (Inf_FormsForEditionTypes[InfoSrc]) Inf_FormsForEditionTypes[InfoSrc] (InfoSrc); HTM_TD_End (); diff --git a/swad_match.c b/swad_match.c index 9f649ad5..dbdb0f3b 100644 --- a/swad_match.c +++ b/swad_match.c @@ -573,7 +573,9 @@ static void Mch_ListOneOrMoreMatchesTitleGrps (const struct Match *Match) HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); /***** Title *****/ - fprintf (Gbl.F.Out,"%s",Match->Title); + HTM_SPAN_Begin ("class=\"ASG_TITLE\""); + fprintf (Gbl.F.Out,"%s",Match->Title); + HTM_SPAN_End (); /***** Groups whose students can answer this match *****/ if (Gbl.Crs.Grps.NumGrps) diff --git a/swad_media.c b/swad_media.c index fb19f7cb..ecffe679 100644 --- a/swad_media.c +++ b/swad_media.c @@ -1631,9 +1631,9 @@ static void Med_ShowGIF (struct Media *Media, "class=\"%s\" lazyload=\"on\"",ClassMedia); // Lazy load of the media /* Overlay with GIF label */ - fprintf (Gbl.F.Out,"" - "GIF" - ""); + HTM_SPAN_Begin ("class=\"MED_PLAY_ICO\""); + fprintf (Gbl.F.Out,"GIF"); + HTM_SPAN_End (); HTM_DIV_End (); } diff --git a/swad_notice.c b/swad_notice.c index 5c2f148e..f1b77fda 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -693,7 +693,8 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, } if (asprintf (&Id,"not_date_%u",UniqueId) < 0) Lay_NotEnoughMemoryExit (); - fprintf (Gbl.F.Out,"",Id); + HTM_SPAN_Begin ("id=\"%s\"",Id); + HTM_SPAN_End (); if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES) { Frm_LinkFormEnd (); diff --git a/swad_notification.c b/swad_notification.c index 690e2192..24f23d86 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -500,8 +500,11 @@ void Ntf_ShowMyNotifications (void) Frm_EndForm (); } else - fprintf (Gbl.F.Out,"%s", - ClassAnchor,Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent]); + { + HTM_SPAN_Begin ("class=\"%s\"",ClassAnchor); + fprintf (Gbl.F.Out,"%s",Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent]); + HTM_SPAN_End (); + } HTM_TD_End (); /* Write user (from) */ @@ -520,7 +523,7 @@ void Ntf_ShowMyNotifications (void) if (PutLink) Frm_LinkFormSubmit (Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent],ClassAnchor,NULL); else - fprintf (Gbl.F.Out,"",ClassAnchor); + HTM_SPAN_Begin ("class=\"%s\"",ClassAnchor); fprintf (Gbl.F.Out,"%s: %s",Txt_Forum,ForumName); if (PutLink) { @@ -528,7 +531,7 @@ void Ntf_ShowMyNotifications (void) Frm_EndForm (); } else - fprintf (Gbl.F.Out,""); + HTM_SPAN_End (); } else { @@ -538,7 +541,7 @@ void Ntf_ShowMyNotifications (void) if (PutLink) Frm_LinkFormSubmit (Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent],ClassAnchor,NULL); else - fprintf (Gbl.F.Out,"",ClassAnchor); + HTM_SPAN_Begin ("class=\"%s\"",ClassAnchor); if (Crs.CrsCod > 0) fprintf (Gbl.F.Out,"%s: %s",Txt_Course,Crs.ShrtName); @@ -557,7 +560,7 @@ void Ntf_ShowMyNotifications (void) Frm_EndForm (); } else - fprintf (Gbl.F.Out,""); + HTM_SPAN_End (); } HTM_TD_End (); @@ -2049,20 +2052,24 @@ void Ntf_WriteNumberOfNewNtfs (void) The_ClassNotif[Gbl.Prefs.Theme],"form_ntf",NULL); /***** Number of unseen notifications *****/ - fprintf (Gbl.F.Out,"%u %s
", + HTM_SPAN_Begin ("id=\"notif_all\""); + fprintf (Gbl.F.Out,"%u %s
", NumUnseenNtfs, NumUnseenNtfs == 1 ? Txt_notification : Txt_notifications); + HTM_SPAN_End (); /***** Icon and number of new notifications *****/ if (NumNewNtfs) { HTM_IMG (Gbl.Prefs.URLTheme,"bell.svg",Txt_Notifications, "class=\"ICO16x16\""); - fprintf (Gbl.F.Out," %u %s", - NumNewNtfs, + fprintf (Gbl.F.Out," %u",NumNewNtfs); + HTM_SPAN_Begin ("id=\"notif_new\""); + fprintf (Gbl.F.Out," %s", NumNewNtfs == 1 ? Txt_NOTIF_new_SINGULAR : Txt_NOTIF_new_PLURAL); + HTM_SPAN_End (); } /***** End form *****/ diff --git a/swad_pagination.c b/swad_pagination.c index 9e659841..13bb5a8e 100644 --- a/swad_pagination.c +++ b/swad_pagination.c @@ -242,7 +242,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate, Frm_LinkFormSubmit (Gbl.Title,Font,NULL); } else - fprintf (Gbl.F.Out,"",Font); + HTM_SPAN_Begin ("class=\"%s\"",Font); if (FirstMsgEnabled) fprintf (Gbl.F.Out,"%s",Subject); else @@ -253,7 +253,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate, Frm_EndForm (); } else - fprintf (Gbl.F.Out,""); + HTM_SPAN_End (); HTM_DIV_End (); } @@ -355,7 +355,11 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate, Frm_LinkFormEnd (); Frm_EndForm (); if (Pagination->LeftPage > 2) - fprintf (Gbl.F.Out,"",Font); + { + HTM_SPAN_Begin ("class=\"%s\"",Font); + fprintf (Gbl.F.Out,"…"); + HTM_SPAN_End (); + } } /***** Posible link to page left *****/ @@ -451,7 +455,11 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate, Frm_LinkFormEnd (); Frm_EndForm (); if (Pagination->LeftPage < Pagination->StartPage - 1) - fprintf (Gbl.F.Out,"",Font); + { + HTM_SPAN_Begin ("class=\"%s\"",Font); + fprintf (Gbl.F.Out,"…"); + HTM_SPAN_End (); + } } /***** Loop to put links to the pages around the current one *****/ @@ -463,10 +471,11 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate, Txt_Page_X_of_Y, NumPage,Pagination->NumPags); if (!LinkToPagCurrent && NumPage == Pagination->CurrentPage) - fprintf (Gbl.F.Out,"" - "%u" - "", - Gbl.Title,Font,NumPage); + { + HTM_SPAN_Begin ("title=\"%s\" class=\"PAG_CUR %s\"",Gbl.Title,Font); + fprintf (Gbl.F.Out,"%u",NumPage); + HTM_SPAN_End (); + } else { switch (WhatPaginate) @@ -561,7 +570,11 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate, Pagination->RightPage < Pagination->NumPags) { if (Pagination->RightPage > Pagination->EndPage + 1) - fprintf (Gbl.F.Out,"",Font); + { + HTM_SPAN_Begin ("class=\"%s\"",Font); + fprintf (Gbl.F.Out,"…"); + HTM_SPAN_End (); + } switch (WhatPaginate) { case Pag_ASSIGNMENTS: @@ -655,7 +668,11 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate, if (Pagination->EndPage < Pagination->NumPags) { if (Pagination->NumPags > Pagination->RightPage + 1) - fprintf (Gbl.F.Out,"",Font); + { + HTM_SPAN_Begin ("class=\"%s\"",Font); + fprintf (Gbl.F.Out,"…"); + HTM_SPAN_End (); + } switch (WhatPaginate) { case Pag_ASSIGNMENTS: diff --git a/swad_photo.c b/swad_photo.c index e2a40ed8..3b506613 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -1252,12 +1252,23 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL, { Fol_GetNumFollow (UsrDat->UsrCod,&NumFollowing,&NumFollowers); HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE\""); - fprintf (Gbl.F.Out,"%u" - " %s " - "%u" - " %s", - NumFollowing,Txt_Following, - NumFollowers,Txt_Followers); + + HTM_SPAN_Begin ("class=\"DAT_N_BOLD\""); + fprintf (Gbl.F.Out,"%u",NumFollowing); + HTM_SPAN_End (); + + HTM_SPAN_Begin ("class=\"DAT_SMALL\""); + fprintf (Gbl.F.Out," %s ",Txt_Following); + HTM_SPAN_End (); + + HTM_SPAN_Begin ("class=\"DAT_N_BOLD\""); + fprintf (Gbl.F.Out,"%u",NumFollowers); + HTM_SPAN_End (); + + HTM_SPAN_Begin ("class=\"DAT_SMALL\""); + fprintf (Gbl.F.Out," %s",Txt_Followers); + HTM_SPAN_End (); + HTM_DIV_End (); } @@ -2411,11 +2422,16 @@ static void Pho_ShowDegreeStat (int NumStds,int NumStdsWithPhoto) { extern const char *Txt_photos; - fprintf (Gbl.F.Out,"%d " - "(%d %s, %d%%)", - NumStds,NumStdsWithPhoto,Txt_photos, + HTM_SPAN_Begin ("class=\"DAT\""); + fprintf (Gbl.F.Out,"%d ",NumStds); + HTM_SPAN_End (); + + HTM_SPAN_Begin ("class=\"DAT_SMALL\""); + fprintf (Gbl.F.Out,"(%d %s, %d%%)", + NumStdsWithPhoto,Txt_photos, NumStds > 0 ? (int) (((NumStdsWithPhoto * 100.0) / NumStds) + 0.5) : 0); + HTM_SPAN_End (); } /*****************************************************************************/ diff --git a/swad_profile.c b/swad_profile.c index 4933eba6..6197a020 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -475,7 +475,8 @@ static void Prf_ShowTimeSinceFirstClick (const struct UsrData *UsrDat, /* Create unique id */ Frm_SetUniqueId (IdFirstClickTime); - fprintf (Gbl.F.Out,"",IdFirstClickTime); + HTM_SPAN_Begin ("id=\"%s\"",IdFirstClickTime); + HTM_SPAN_End (); if (UsrFigures->NumDays > 0) { fprintf (Gbl.F.Out," ("); diff --git a/swad_record.c b/swad_record.c index 62203468..efe18358 100644 --- a/swad_record.c +++ b/swad_record.c @@ -1803,8 +1803,12 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView, fprintf (Gbl.F.Out,"%s:",Gbl.Crs.Records.LstFields.Lst[NumField].Name); if (TypeOfView == Rec_CRS_LIST_ONE_RECORD || TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS) - fprintf (Gbl.F.Out," (%s)", + { + HTM_SPAN_Begin ("class=\"DAT_SMALL\""); + fprintf (Gbl.F.Out," (%s)", Txt_RECORD_FIELD_VISIBILITY_RECORD[Gbl.Crs.Records.LstFields.Lst[NumField].Visibility]); + HTM_SPAN_End (); + } HTM_TD_End (); /* Get the text of the field */ diff --git a/swad_report.c b/swad_report.c index f85e534a..e3bae436 100644 --- a/swad_report.c +++ b/swad_report.c @@ -305,17 +305,21 @@ static void Rep_TitleReport (struct Rep_CurrentTimeUTC *CurrentTimeUTC) HTM_DIV_Begin ("class=\"TITLE_REPORT DAT\""); /***** User *****/ - fprintf (Gbl.F.Out,"%s: %s", - Txt_User[Gbl.Usrs.Me.UsrDat.Sex], - Gbl.Usrs.Me.UsrDat.FullName); + fprintf (Gbl.F.Out,"%s: ",Txt_User[Gbl.Usrs.Me.UsrDat.Sex]); + HTM_SPAN_Begin ("class=\"DAT_N_BOLD\""); + fprintf (Gbl.F.Out,"%s",Gbl.Usrs.Me.UsrDat.FullName); + HTM_SPAN_End (); /***** Report date *****/ if (CurrentTimeUTC) + { fprintf (Gbl.F.Out,"
" - "%s: %s %s UTC", - Txt_Date, - CurrentTimeUTC->StrDate, - CurrentTimeUTC->StrTime); + "%s: ",Txt_Date); + HTM_SPAN_Begin ("class=\"DAT_N\""); + fprintf (Gbl.F.Out,"%s %s UTC",CurrentTimeUTC->StrDate, + CurrentTimeUTC->StrTime); + HTM_SPAN_End (); + } HTM_DIV_End (); } diff --git a/swad_test.c b/swad_test.c index cfc4cb8c..16998380 100644 --- a/swad_test.c +++ b/swad_test.c @@ -635,12 +635,15 @@ void Tst_ShowTstTotalMark (unsigned NumQsts,double TotalScore) /***** Write total mark ****/ HTM_DIV_Begin ("class=\"DAT CM\""); - fprintf (Gbl.F.Out,"%s: %.2lf (%.2lf %s %u)", - Txt_Score, - (TotalScoreOverSCORE_MAX >= (double) TotalScoreOverSCORE_MAX / 2.0) ? "ANS_OK" : - "ANS_BAD", + fprintf (Gbl.F.Out,"%s: ",Txt_Score); + HTM_SPAN_Begin ("class=\"%s\"", + (TotalScoreOverSCORE_MAX >= + (double) TotalScoreOverSCORE_MAX / 2.0) ? "ANS_OK" : + "ANS_BAD"); + fprintf (Gbl.F.Out,"%.2lf (%.2lf %s %u)", TotalScore, TotalScoreOverSCORE_MAX,Txt_out_of_PART_OF_A_SCORE,Tst_SCORE_MAX); + HTM_SPAN_End (); HTM_DIV_End (); } @@ -3301,8 +3304,9 @@ void Tst_WriteAnswersEdit (long QstCod) case Tst_ANS_INT: Tst_CheckIfNumberOfAnswersIsOne (); row = mysql_fetch_row (mysql_res); - fprintf (Gbl.F.Out,"(%ld)", - Tst_GetIntAnsFromStr (row[1])); + HTM_SPAN_Begin ("class=\"TEST_EDI\""); + fprintf (Gbl.F.Out,"(%ld)",Tst_GetIntAnsFromStr (row[1])); + HTM_SPAN_End (); break; case Tst_ANS_FLOAT: if (Gbl.Test.Answer.NumOptions != 2) @@ -3315,15 +3319,18 @@ void Tst_WriteAnswersEdit (long QstCod) row = mysql_fetch_row (mysql_res); FloatNum[i] = Tst_GetFloatAnsFromStr (row[1]); } - fprintf (Gbl.F.Out,"([%lg; %lg])", - FloatNum[0],FloatNum[1]); + HTM_SPAN_Begin ("class=\"TEST_EDI\""); + fprintf (Gbl.F.Out,"([%lg; %lg])",FloatNum[0],FloatNum[1]); + HTM_SPAN_End (); break; case Tst_ANS_TRUE_FALSE: Tst_CheckIfNumberOfAnswersIsOne (); row = mysql_fetch_row (mysql_res); - fprintf (Gbl.F.Out,"("); + HTM_SPAN_Begin ("class=\"TEST_EDI\""); + fprintf (Gbl.F.Out,"("); Tst_WriteAnsTF (row[1][0]); - fprintf (Gbl.F.Out,")"); + fprintf (Gbl.F.Out,")"); + HTM_SPAN_End (); break; case Tst_ANS_UNIQUE_CHOICE: case Tst_ANS_MULTIPLE_CHOICE: @@ -3620,11 +3627,21 @@ static void Tst_WriteTFAnsAssessTest (struct UsrData *UsrDat, { Tst_WriteScoreStart (2); if (AnsTF == '\0') // If user has omitted the answer - fprintf (Gbl.F.Out,"ANS_0\">%.2lf",0.0); + { + HTM_SPAN_Begin ("class=\"ANS_0\""); + fprintf (Gbl.F.Out,"%.2lf",0.0); + } else if (AnsTF == row[1][0]) // If correct - fprintf (Gbl.F.Out,"ANS_OK\">%.2lf",1.0); + { + HTM_SPAN_Begin ("class=\"ANS_OK\""); + fprintf (Gbl.F.Out,"%.2lf",1.0); + } else // If wrong - fprintf (Gbl.F.Out,"ANS_BAD\">%.2lf",-1.0); + { + HTM_SPAN_Begin ("class=\"ANS_BAD\""); + fprintf (Gbl.F.Out,"%.2lf",-1.0); + } + HTM_SPAN_End (); Tst_WriteScoreEnd (); } @@ -3879,12 +3896,13 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat, { Tst_WriteScoreStart (4); if (*ScoreThisQst == 0.0) - fprintf (Gbl.F.Out,"ANS_0"); + HTM_SPAN_Begin ("class=\"ANS_0\""); else if (*ScoreThisQst > 0.0) - fprintf (Gbl.F.Out,"ANS_OK"); + HTM_SPAN_Begin ("class=\"ANS_OK\""); else - fprintf (Gbl.F.Out,"ANS_BAD"); - fprintf (Gbl.F.Out,"\">%.2lf",*ScoreThisQst); + HTM_SPAN_Begin ("class=\"ANS_BAD\""); + fprintf (Gbl.F.Out,"%.2lf",*ScoreThisQst); + HTM_SPAN_End (); Tst_WriteScoreEnd (); } @@ -4397,11 +4415,21 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat, { Tst_WriteScoreStart (4); if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer - fprintf (Gbl.F.Out,"ANS_0\">%.2lf",0.0); - else if (Correct) // If correct - fprintf (Gbl.F.Out,"ANS_OK\">%.2lf",1.0); - else // If wrong - fprintf (Gbl.F.Out,"ANS_BAD\">%.2lf",0.0); + { + HTM_SPAN_Begin ("class=\"ANS_0\""); + fprintf (Gbl.F.Out,"%.2lf",0.0); + } + else if (Correct) // If correct + { + HTM_SPAN_Begin ("class=\"ANS_OK\""); + fprintf (Gbl.F.Out,"%.2lf",1.0); + } + else // If wrong + { + HTM_SPAN_Begin ("class=\"ANS_BAD\""); + fprintf (Gbl.F.Out,"%.2lf",0.0); + } + HTM_SPAN_End (); Tst_WriteScoreEnd (); } @@ -4516,11 +4544,21 @@ static void Tst_WriteIntAnsAssessTest (struct UsrData *UsrDat, { Tst_WriteScoreStart (2); if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer - fprintf (Gbl.F.Out,"ANS_0\">%.2lf",0.0); - else if (IntAnswerUsr == IntAnswerCorr) // If correct - fprintf (Gbl.F.Out,"ANS_OK\">%.2lf",1.0); - else // If wrong - fprintf (Gbl.F.Out,"ANS_BAD\">%.2lf",0.0); + { + HTM_SPAN_Begin ("class=\"ANS_0\""); + fprintf (Gbl.F.Out,"%.2lf",0.0); + } + else if (IntAnswerUsr == IntAnswerCorr) // If correct + { + HTM_SPAN_Begin ("class=\"ANS_OK\""); + fprintf (Gbl.F.Out,"%.2lf",1.0); + } + else // If wrong + { + HTM_SPAN_Begin ("class=\"ANS_BAD\""); + fprintf (Gbl.F.Out,"%.2lf",0.0); + } + HTM_SPAN_End (); Tst_WriteScoreEnd (); } @@ -4649,12 +4687,22 @@ static void Tst_WriteFloatAnsAssessTest (struct UsrData *UsrDat, { Tst_WriteScoreStart (2); if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer - fprintf (Gbl.F.Out,"ANS_0\">%.2lf",0.0); + { + HTM_SPAN_Begin ("class=\"ANS_0\""); + fprintf (Gbl.F.Out,"%.2lf",0.0); + } else if (FloatAnsUsr >= FloatAnsCorr[0] && - FloatAnsUsr <= FloatAnsCorr[1]) // If correct (inside the interval) - fprintf (Gbl.F.Out,"ANS_OK\">%.2lf",1.0); - else // If wrong (outside the interval) - fprintf (Gbl.F.Out,"ANS_BAD\">%.2lf",0.0); + FloatAnsUsr <= FloatAnsCorr[1]) // If correct (inside the interval) + { + HTM_SPAN_Begin ("class=\"ANS_OK\""); + fprintf (Gbl.F.Out,"%.2lf",1.0); + } + else // If wrong (outside the interval) + { + HTM_SPAN_Begin ("class=\"ANS_BAD\""); + fprintf (Gbl.F.Out,"%.2lf",0.0); + } + HTM_SPAN_End (); Tst_WriteScoreEnd (); } @@ -4690,12 +4738,11 @@ static void Tst_WriteScoreStart (unsigned ColSpan) HTM_TR_Begin (NULL); HTM_TD_Begin ("colspan=\"%u\" class=\"DAT_SMALL LM\"",ColSpan); - fprintf (Gbl.F.Out,"%s: "); HTM_TD_End (); HTM_TR_End (); } @@ -4767,8 +4814,11 @@ void Tst_GetAndWriteTagsQst (long QstCod) HTM_UL_End (); } else - fprintf (Gbl.F.Out,"(%s)", - Txt_no_tags); + { + HTM_SPAN_Begin ("class=\"DAT_SMALL\""); + fprintf (Gbl.F.Out,"(%s)",Txt_no_tags); + HTM_SPAN_End (); + } /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); diff --git a/swad_test_import.c b/swad_test_import.c index bc72d54f..0a2dea8b 100644 --- a/swad_test_import.c +++ b/swad_test_import.c @@ -1039,8 +1039,11 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem, HTM_TABLE_End (); } else // no tags for this question - fprintf (Gbl.F.Out," (%s) ", - ClassData,Txt_no_tags); + { + HTM_SPAN_Begin ("class=\"%s\"",ClassData); + fprintf (Gbl.F.Out," (%s) ",Txt_no_tags); + HTM_SPAN_End (); + } HTM_TD_End (); @@ -1067,17 +1070,23 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem, switch (Gbl.Test.AnswerType) { case Tst_ANS_INT: - fprintf (Gbl.F.Out,"(%ld)", - ClassStem,Gbl.Test.Answer.Integer); + HTM_SPAN_Begin ("class=\"%s\"",ClassStem); + fprintf (Gbl.F.Out,"(%ld)",Gbl.Test.Answer.Integer); + HTM_SPAN_End (); break; case Tst_ANS_FLOAT: - fprintf (Gbl.F.Out,"([%lg; %lg])", - ClassStem,Gbl.Test.Answer.FloatingPoint[0],Gbl.Test.Answer.FloatingPoint[1]); + HTM_SPAN_Begin ("class=\"%s\"",ClassStem); + fprintf (Gbl.F.Out,"([%lg; %lg])", + Gbl.Test.Answer.FloatingPoint[0], + Gbl.Test.Answer.FloatingPoint[1]); + HTM_SPAN_End (); break; case Tst_ANS_TRUE_FALSE: - fprintf (Gbl.F.Out,"(",ClassStem); + HTM_SPAN_Begin ("class=\"%s\"",ClassStem); + fprintf (Gbl.F.Out,"("); Tst_WriteAnsTF (Gbl.Test.Answer.TF); - fprintf (Gbl.F.Out,")"); + fprintf (Gbl.F.Out,")"); + HTM_SPAN_End (); break; case Tst_ANS_UNIQUE_CHOICE: case Tst_ANS_MULTIPLE_CHOICE: diff --git a/swad_timeline.c b/swad_timeline.c index a9bf9608..107dd3b1 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -1401,8 +1401,11 @@ static void TL_PutLinkToViewNewPublications (void) HTM_A_Begin ("href=\"\" class=\"%s\"" " onclick=\"moveNewTimelineToTimeline();return false;\"", The_ClassFormInBoxBold[Gbl.Prefs.Theme]); - fprintf (Gbl.F.Out,"%s (0)", - Txt_See_new_activity); + fprintf (Gbl.F.Out,"%s (",Txt_See_new_activity); + HTM_SPAN_Begin ("id=\"view_new_posts_count\""); + fprintf (Gbl.F.Out,"0"); + HTM_SPAN_End (); + fprintf (Gbl.F.Out,")"); HTM_A_End (); HTM_DIV_End (); } @@ -2322,9 +2325,15 @@ static void TL_PutFormToWriteNewPost (void) /* Write author's full name and nickname */ HTM_DIV_Begin ("class=\"TL_RIGHT_AUTHOR TL_RIGHT_AUTHOR_WIDTH\""); - fprintf (Gbl.F.Out,"%s" - " @%s", - Gbl.Usrs.Me.UsrDat.FullName,Gbl.Usrs.Me.UsrDat.Nickname); + + HTM_SPAN_Begin ("class=\"DAT_N_BOLD\""); + fprintf (Gbl.F.Out,"%s",Gbl.Usrs.Me.UsrDat.FullName); + HTM_SPAN_End (); + + HTM_SPAN_Begin ("class=\"DAT_LIGHT\""); + fprintf (Gbl.F.Out," @%s",Gbl.Usrs.Me.UsrDat.Nickname); + HTM_SPAN_End (); + HTM_DIV_End (); /***** Form to write the post *****/ diff --git a/swad_user.c b/swad_user.c index 1e12ad1e..786767f6 100644 --- a/swad_user.c +++ b/swad_user.c @@ -3495,10 +3495,16 @@ void Usr_ShowFormsLogoutAndRole (void) /***** Put a form to change my role *****/ if (Rol_GetNumAvailableRoles () == 1) - fprintf (Gbl.F.Out,"%s: " - "%s", - Txt_Role, + { + HTM_SPAN_Begin ("class=\"DAT\""); + fprintf (Gbl.F.Out,"%s: ",Txt_Role); + HTM_SPAN_End (); + + HTM_SPAN_Begin ("class=\"DAT_N_BOLD\""); + fprintf (Gbl.F.Out,"%s", Txt_ROLES_SINGUL_Abc[Gbl.Usrs.Me.Role.Logged][Gbl.Usrs.Me.UsrDat.Sex]); + HTM_SPAN_End (); + } else { HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);