From 3039405c8ddaa42dc9cb2995fbad380317be9e88 Mon Sep 17 00:00:00 2001 From: acanas Date: Mon, 27 Nov 2023 14:41:02 +0100 Subject: [PATCH] Version 23.49: Nov 27, 2023 Code refactoring in highlighting. --- swad_changelog.h | 3 ++- swad_course.c | 39 +++++++++++++++++---------------- swad_enrolment.c | 6 +++--- swad_enrolment.h | 2 +- swad_forum.c | 56 +++++++++++++++++++++++++++++------------------- swad_group.c | 43 ++++++++++++++++++------------------- swad_layout.c | 6 ++++++ swad_layout.h | 7 ++++++ swad_notice.c | 18 ++++++++++------ 9 files changed, 105 insertions(+), 75 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 0a213b3f..a5626e5f 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -633,10 +633,11 @@ Me sale este error, no s "can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod') */ -#define Log_PLATFORM_VERSION "SWAD 23.48.3 (2023-11-27)" +#define Log_PLATFORM_VERSION "SWAD 23.49 (2023-11-27)" #define CSS_FILE "swad23.48.2.css" #define JS_FILE "swad23.47.3.js" /* + Version 23.49: Nov 27, 2023 Code refactoring in highlighting. (335774 lines) Version 23.48.3: Nov 27, 2023 Code refactoring in notices. (335746 lines) Version 23.48.2: Nov 26, 2023 Responsive design in program. (335738 lines) Version 23.48.1: Nov 26, 2023 Responsive design in record cards. (335693 lines) diff --git a/swad_course.c b/swad_course.c index 87a6f00e..7aa33cae 100644 --- a/swad_course.c +++ b/swad_course.c @@ -151,13 +151,14 @@ void Crs_ShowIntroduction (void) static void Crs_WriteListMyCoursesToSelectOne (void) { extern const char *Hlp_PROFILE_Courses; + extern const char *Lay_HighlightClass[Lay_NUM_HIGHLIGHT]; extern const char *Par_CodeStr[]; extern ParCod_Param_t Hie_ParCod[Hie_NUM_LEVELS]; extern const char *Txt_My_courses; extern const char *Txt_HIERARCHY_SINGUL_Abc[Hie_NUM_LEVELS]; struct Hie_Node Hie[Hie_NUM_LEVELS]; Lay_LastItem_t IsLastItemInLevel[1 + 6]; - bool Highlight; // Highlight because degree, course, etc. is selected + Lay_Highlight_t Highlight; // Highlight because degree, course, etc. is selected MYSQL_RES *mysql_resCty; MYSQL_RES *mysql_resIns; MYSQL_RES *mysql_resCtr; @@ -184,9 +185,9 @@ static void Crs_WriteListMyCoursesToSelectOne (void) HTM_UL_Begin ("class=\"LIST_TREE\""); /***** Write link to platform *****/ - Highlight = (Gbl.Hierarchy.Node[Hie_CTY].HieCod <= 0); - HTM_LI_Begin (Highlight ? "class=\"BG_HIGHLIGHT\"" : - NULL); + Highlight = (Gbl.Hierarchy.Node[Hie_CTY].HieCod <= 0) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; + HTM_LI_Begin (Lay_HighlightClass[Highlight]); IsLastItemInLevel[1] = Lay_LAST_ITEM; Lay_IndentDependingOnLevel (1,IsLastItemInLevel, Lay_HORIZONTAL_LINE_AT_RIGHT); @@ -217,9 +218,9 @@ static void Crs_WriteListMyCoursesToSelectOne (void) /***** Write link to country *****/ Highlight = (Gbl.Hierarchy.Node[Hie_INS].HieCod <= 0 && - Gbl.Hierarchy.Node[Hie_CTY].HieCod == Hie[Hie_CTY].HieCod); - HTM_LI_Begin (Highlight ? "class=\"BG_HIGHLIGHT\"" : - NULL); + Gbl.Hierarchy.Node[Hie_CTY].HieCod == Hie[Hie_CTY].HieCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; + HTM_LI_Begin (Lay_HighlightClass[Highlight]); IsLastItemInLevel[2] = (NumCty == NumCtys - 1) ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; Lay_IndentDependingOnLevel (2,IsLastItemInLevel, @@ -252,9 +253,9 @@ static void Crs_WriteListMyCoursesToSelectOne (void) /***** Write link to institution *****/ Highlight = (Gbl.Hierarchy.Node[Hie_CTR].HieCod <= 0 && - Gbl.Hierarchy.Node[Hie_INS].HieCod == Hie[Hie_INS].HieCod); - HTM_LI_Begin (Highlight ? "class=\"BG_HIGHLIGHT\"" : - NULL); + Gbl.Hierarchy.Node[Hie_INS].HieCod == Hie[Hie_INS].HieCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; + HTM_LI_Begin (Lay_HighlightClass[Highlight]); IsLastItemInLevel[3] = (NumIns == NumInss - 1) ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; Lay_IndentDependingOnLevel (3,IsLastItemInLevel, @@ -289,9 +290,9 @@ static void Crs_WriteListMyCoursesToSelectOne (void) /***** Write link to center *****/ Highlight = (Gbl.Hierarchy.Level == Hie_CTR && - Gbl.Hierarchy.Node[Hie_CTR].HieCod == Hie[Hie_CTR].HieCod); - HTM_LI_Begin (Highlight ? "class=\"BG_HIGHLIGHT\"" : - NULL); + Gbl.Hierarchy.Node[Hie_CTR].HieCod == Hie[Hie_CTR].HieCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; + HTM_LI_Begin (Lay_HighlightClass[Highlight]); IsLastItemInLevel[4] = (NumCtr == NumCtrs - 1) ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; Lay_IndentDependingOnLevel (4,IsLastItemInLevel, @@ -326,9 +327,9 @@ static void Crs_WriteListMyCoursesToSelectOne (void) /***** Write link to degree *****/ Highlight = (Gbl.Hierarchy.Level == Hie_DEG && - Gbl.Hierarchy.Node[Hie_DEG].HieCod == Hie[Hie_DEG].HieCod); - HTM_LI_Begin (Highlight ? "class=\"BG_HIGHLIGHT\"" : - NULL); + Gbl.Hierarchy.Node[Hie_DEG].HieCod == Hie[Hie_DEG].HieCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; + HTM_LI_Begin (Lay_HighlightClass[Highlight]); IsLastItemInLevel[5] = (NumDeg == NumDegs - 1) ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; Lay_IndentDependingOnLevel (5,IsLastItemInLevel, @@ -365,11 +366,11 @@ static void Crs_WriteListMyCoursesToSelectOne (void) /***** Write link to course *****/ Highlight = (Gbl.Hierarchy.Level == Hie_CRS && - Gbl.Hierarchy.Node[Hie_CRS].HieCod == Hie[Hie_CRS].HieCod); + Gbl.Hierarchy.Node[Hie_CRS].HieCod == Hie[Hie_CRS].HieCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[6] = (NumCrs == NumCrss - 1) ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; - HTM_LI_Begin (Highlight ? "class=\"BG_HIGHLIGHT\"" : - NULL); + HTM_LI_Begin (Lay_HighlightClass[Highlight]); Lay_IndentDependingOnLevel (6,IsLastItemInLevel, Lay_HORIZONTAL_LINE_AT_RIGHT); Frm_BeginForm (ActMyCrs); diff --git a/swad_enrolment.c b/swad_enrolment.c index 2095831a..935c660e 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -174,16 +174,16 @@ void Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (void) void Enr_PutButtonInlineToRegisterStds (long CrsCod, unsigned Level,Lay_LastItem_t IsLastItemInLevel[], - bool Highlight) + Lay_Highlight_t Highlight) { + extern const char *Lay_HighlightClass[Lay_NUM_HIGHLIGHT]; extern const char *Txt_Register_students; if (Rol_GetMyRoleInCrs (CrsCod) == Rol_TCH) // I am a teacher in the given course if (!Enr_GetNumUsrsInCrss (Hie_CRS,CrsCod, 1 << Rol_STD)) // No students in course { - HTM_LI_Begin (Highlight ? "class=\"BG_HIGHLIGHT\"" : - NULL); + HTM_LI_Begin (Lay_HighlightClass[Highlight]); Lay_IndentDependingOnLevel (Level,IsLastItemInLevel, Lay_NO_HORIZONTAL_LINE_AT_RIGHT); Frm_BeginForm (ActReqEnrSevStd); diff --git a/swad_enrolment.h b/swad_enrolment.h index e69f59f3..7bbfc84d 100644 --- a/swad_enrolment.h +++ b/swad_enrolment.h @@ -76,7 +76,7 @@ typedef enum void Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (void); void Enr_PutButtonInlineToRegisterStds (long CrsCod, unsigned Level,Lay_LastItem_t IsLastItemInLevel[], - bool Highlight); + Lay_Highlight_t Highlight); void Enr_PutLinkToRequestSignUp (void); diff --git a/swad_forum.c b/swad_forum.c index 7ab6d314..14722d0e 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -355,7 +355,7 @@ static long For_WriteLinksToCrsForums (const struct For_Forums *Forums, Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]); static void For_WriteLinkToForum (const struct For_Forums *Forums, const struct For_Forum *Forum, - bool Highlight, + Lay_Highlight_t Highlight, unsigned Level, Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]); static unsigned For_GetNumThrsWithNewPstsInForum (const struct For_Forum *Forum, @@ -1456,7 +1456,7 @@ static void For_PutFormWhichForums (const struct For_Forums *Forums) static void For_WriteLinksToGblForums (const struct For_Forums *Forums, Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]) { - bool Highlight; + Lay_Highlight_t Highlight; bool ICanSeeTeacherForum; struct For_Forum Forum; @@ -1469,7 +1469,8 @@ static void For_WriteLinksToGblForums (const struct For_Forums *Forums, /***** Link to forum global *****/ Forum.Type = For_FORUM_GLOBAL_USRS; Forum.HieCod = -1L; - Highlight = (Forums->Forum.Type == For_FORUM_GLOBAL_USRS); + Highlight = (Forums->Forum.Type == For_FORUM_GLOBAL_USRS) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[1] = Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,1,IsLastItemInLevel); @@ -1479,7 +1480,8 @@ static void For_WriteLinksToGblForums (const struct For_Forums *Forums, { Forum.Type = For_FORUM_GLOBAL_TCHS; Forum.HieCod = -1L; - Highlight = (Forums->Forum.Type == For_FORUM_GLOBAL_TCHS); + Highlight = (Forums->Forum.Type == For_FORUM_GLOBAL_TCHS) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[1] = Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,1,IsLastItemInLevel); } @@ -1493,7 +1495,7 @@ static void For_WriteLinksToPlatformForums (const struct For_Forums *Forums, bool IsLastForum, Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]) { - bool Highlight; + Lay_Highlight_t Highlight; bool ICanSeeTeacherForum; struct For_Forum Forum; @@ -1506,7 +1508,8 @@ static void For_WriteLinksToPlatformForums (const struct For_Forums *Forums, /***** Link to forum of users about the platform *****/ Forum.Type = For_FORUM__SWAD__USRS; Forum.HieCod = -1L; - Highlight = (Forums->Forum.Type == For_FORUM__SWAD__USRS); + Highlight = (Forums->Forum.Type == For_FORUM__SWAD__USRS) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[1] = (IsLastForum && !ICanSeeTeacherForum) ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,1,IsLastItemInLevel); @@ -1516,7 +1519,8 @@ static void For_WriteLinksToPlatformForums (const struct For_Forums *Forums, { Forum.Type = For_FORUM__SWAD__TCHS; Forum.HieCod = -1L; - Highlight = (Forums->Forum.Type == For_FORUM__SWAD__TCHS); + Highlight = (Forums->Forum.Type == For_FORUM__SWAD__TCHS) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[1] = IsLastForum ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,1,IsLastItemInLevel); @@ -1532,7 +1536,7 @@ static long For_WriteLinksToInsForums (const struct For_Forums *Forums, long InsCod,bool IsLastIns, Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]) { - bool Highlight; + Lay_Highlight_t Highlight; Rol_Role_t MaxRoleInIns; bool ICanSeeTeacherForum; struct For_Forum Forum; @@ -1548,7 +1552,8 @@ static long For_WriteLinksToInsForums (const struct For_Forums *Forums, Forum.Type = For_FORUM_INSTIT_USRS; Forum.HieCod = InsCod; Highlight = (Forums->Forum.Type == For_FORUM_INSTIT_USRS && - Forums->Forum.HieCod == InsCod); + Forums->Forum.HieCod == InsCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[2] = (IsLastIns && !ICanSeeTeacherForum) ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,2,IsLastItemInLevel); @@ -1559,7 +1564,8 @@ static long For_WriteLinksToInsForums (const struct For_Forums *Forums, Forum.Type = For_FORUM_INSTIT_TCHS; Forum.HieCod = InsCod; Highlight = (Forums->Forum.Type == For_FORUM_INSTIT_TCHS && - Forums->Forum.HieCod == InsCod); + Forums->Forum.HieCod == InsCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[2] = IsLastIns ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,2,IsLastItemInLevel); @@ -1577,7 +1583,7 @@ static long For_WriteLinksToCtrForums (const struct For_Forums *Forums, long CtrCod,bool IsLastCtr, Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]) { - bool Highlight; + Lay_Highlight_t Highlight; Rol_Role_t MaxRoleInCtr; bool ICanSeeTeacherForum; struct For_Forum Forum; @@ -1593,7 +1599,8 @@ static long For_WriteLinksToCtrForums (const struct For_Forums *Forums, Forum.Type = For_FORUM_CENTER_USRS; Forum.HieCod = CtrCod; Highlight = (Forums->Forum.Type == For_FORUM_CENTER_USRS && - Forums->Forum.HieCod == CtrCod); + Forums->Forum.HieCod == CtrCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[3] = (IsLastCtr && !ICanSeeTeacherForum) ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,3,IsLastItemInLevel); @@ -1604,7 +1611,8 @@ static long For_WriteLinksToCtrForums (const struct For_Forums *Forums, Forum.Type = For_FORUM_CENTER_TCHS; Forum.HieCod = CtrCod; Highlight = (Forums->Forum.Type == For_FORUM_CENTER_TCHS && - Forums->Forum.HieCod == CtrCod); + Forums->Forum.HieCod == CtrCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[3] = IsLastCtr ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,3,IsLastItemInLevel); @@ -1622,7 +1630,7 @@ static long For_WriteLinksToDegForums (const struct For_Forums *Forums, long DegCod,bool IsLastDeg, Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]) { - bool Highlight; + Lay_Highlight_t Highlight; Rol_Role_t MaxRoleInDeg; bool ICanSeeTeacherForum; struct For_Forum Forum; @@ -1638,7 +1646,8 @@ static long For_WriteLinksToDegForums (const struct For_Forums *Forums, Forum.Type = For_FORUM_DEGREE_USRS; Forum.HieCod = DegCod; Highlight = (Forums->Forum.Type == For_FORUM_DEGREE_USRS && - Forums->Forum.HieCod == DegCod); + Forums->Forum.HieCod == DegCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[4] = (IsLastDeg && !ICanSeeTeacherForum) ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,4,IsLastItemInLevel); @@ -1649,7 +1658,8 @@ static long For_WriteLinksToDegForums (const struct For_Forums *Forums, Forum.Type = For_FORUM_DEGREE_TCHS; Forum.HieCod = DegCod; Highlight = (Forums->Forum.Type == For_FORUM_DEGREE_TCHS && - Forums->Forum.HieCod == DegCod); + Forums->Forum.HieCod == DegCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[4] = IsLastDeg ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,4,IsLastItemInLevel); @@ -1667,7 +1677,7 @@ static long For_WriteLinksToCrsForums (const struct For_Forums *Forums, long CrsCod,bool IsLastCrs, Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]) { - bool Highlight; + Lay_Highlight_t Highlight; Rol_Role_t MyRoleInCrs; bool ICanSeeTeacherForum; struct For_Forum Forum; @@ -1683,7 +1693,8 @@ static long For_WriteLinksToCrsForums (const struct For_Forums *Forums, Forum.Type = For_FORUM_COURSE_USRS; Forum.HieCod = CrsCod; Highlight = (Forums->Forum.Type == For_FORUM_COURSE_USRS && - Forums->Forum.HieCod == CrsCod); + Forums->Forum.HieCod == CrsCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[5] = (IsLastCrs && !ICanSeeTeacherForum) ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,5,IsLastItemInLevel); @@ -1694,7 +1705,8 @@ static long For_WriteLinksToCrsForums (const struct For_Forums *Forums, Forum.Type = For_FORUM_COURSE_TCHS; Forum.HieCod = CrsCod; Highlight = (Forums->Forum.Type == For_FORUM_COURSE_TCHS && - Forums->Forum.HieCod == CrsCod); + Forums->Forum.HieCod == CrsCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT; IsLastItemInLevel[5] = IsLastCrs ? Lay_LAST_ITEM : Lay_NO_LAST_ITEM; For_WriteLinkToForum (Forums,&Forum,Highlight,5,IsLastItemInLevel); @@ -1709,10 +1721,11 @@ static long For_WriteLinksToCrsForums (const struct For_Forums *Forums, static void For_WriteLinkToForum (const struct For_Forums *Forums, const struct For_Forum *Forum, - bool Highlight, + Lay_Highlight_t Highlight, unsigned Level, Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]) { + extern const char *Lay_HighlightClass[Lay_NUM_HIGHLIGHT]; extern const char *Txt_Copy_not_allowed; unsigned NumThrs; unsigned NumThrsWithNewPosts; @@ -1723,8 +1736,7 @@ static void For_WriteLinkToForum (const struct For_Forums *Forums, NumThrsWithNewPosts = For_GetNumThrsWithNewPstsInForum (Forum,NumThrs); /***** Begin row *****/ - HTM_LI_Begin (Highlight ? "class=\"BG_HIGHLIGHT\"" : - NULL); + HTM_LI_Begin (Lay_HighlightClass[Highlight]); /***** Indent forum title *****/ Lay_IndentDependingOnLevel (Level,IsLastItemInLevel, diff --git a/swad_group.c b/swad_group.c index 091dcf45..5575ce7c 100644 --- a/swad_group.c +++ b/swad_group.c @@ -125,7 +125,7 @@ static void Grp_ListGrpsToAddOrRemUsrs (struct GroupType *GrpTyp,long UsrCod); static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, Grp_WhichGroups_t GroupsSelectableByStdsOrNETs); static void Grp_WriteGrpHead (struct GroupType *GrpTyp); -static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight); +static void Grp_WriteRowGrp (struct Group *Grp,Lay_Highlight_t Highlight); static void Grp_PutFormToCreateGroupType (void); static void Grp_PutFormToCreateGroup (const struct Roo_Rooms *Rooms); static void Grp_GetGroupTypeDataByCod (struct GroupType *GrpTyp); @@ -1671,7 +1671,8 @@ void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp, " disabled=\"disabled\""); HTM_TD_End (); - Grp_WriteRowGrp (Grp,IBelongToThisGroup); + Grp_WriteRowGrp (Grp,IBelongToThisGroup ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT); HTM_TR_End (); } @@ -1980,7 +1981,8 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp, HTM_TD_End (); - Grp_WriteRowGrp (Grp,IBelongToThisGroup); + Grp_WriteRowGrp (Grp,IBelongToThisGroup ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT); HTM_TR_End (); } @@ -2077,7 +2079,8 @@ static void Grp_ListGrpsToAddOrRemUsrs (struct GroupType *GrpTyp,long UsrCod) HTM_TD_End (); /* Write cell for group */ - Grp_WriteRowGrp (Grp,UsrBelongsToThisGroup); + Grp_WriteRowGrp (Grp,UsrBelongsToThisGroup ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT); /* End row */ HTM_TR_End (); @@ -2173,7 +2176,8 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, " disabled=\"disabled\""); HTM_TD_End (); - Grp_WriteRowGrp (Grp,IBelongToThisGroup); + Grp_WriteRowGrp (Grp,IBelongToThisGroup ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT); HTM_TR_End (); } @@ -2302,7 +2306,7 @@ static void Grp_WriteGrpHead (struct GroupType *GrpTyp) /****************** Write a row with the data of a group *********************/ /*****************************************************************************/ -static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight) +static void Grp_WriteRowGrp (struct Group *Grp,Lay_Highlight_t Highlight) { extern const char *Txt_Group_X_open; extern const char *Txt_Group_X_closed; @@ -2310,10 +2314,14 @@ static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight) int Vacant; Rol_Role_t Role; char StrMaxStudents[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; + static const char *HighlightClass[Lay_NUM_HIGHLIGHT] = + { + [Lay_NO_HIGHLIGHT] = "", + [Lay_HIGHLIGHT ] = " BG_HIGHLIGHT", + }; /***** Write icon to show if group is open or closed *****/ - HTM_TD_Begin (Highlight ? "class=\"BM BG_HIGHLIGHT\"" : - "class=\"BM\""); + HTM_TD_Begin ("class=\"BM%s\"",HighlightClass[Highlight]); if (asprintf (&Title,Grp->Open ? Txt_Group_X_open : Txt_Group_X_closed, Grp->GrpName) < 0) @@ -2327,8 +2335,7 @@ static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight) HTM_TD_End (); /***** Group name *****/ - HTM_TD_Begin (Highlight ? "class=\"LM BG_HIGHLIGHT\"" : - "class=\"LM\""); + HTM_TD_Begin ("class=\"LM%s\"",HighlightClass[Highlight]); HTM_LABEL_Begin ("for=\"Grp%ld\" class=\"DAT_%s\"", Grp->GrpCod,The_GetSuffix ()); HTM_Txt (Grp->GrpName); @@ -2337,9 +2344,7 @@ static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight) /***** Room *****/ HTM_TD_Begin ("class=\"LM DAT_%s%s\"", - The_GetSuffix (), - Highlight ? " BG_HIGHLIGHT" : - ""); + The_GetSuffix (),HighlightClass[Highlight]); HTM_Txt (Grp->Room.ShrtName); HTM_TD_End (); @@ -2349,27 +2354,21 @@ static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight) Role--) { HTM_TD_Begin ("class=\"CM DAT_%s%s\"", - The_GetSuffix (), - Highlight ? " BG_HIGHLIGHT" : - ""); + The_GetSuffix (),HighlightClass[Highlight]); HTM_Int (Grp->NumUsrs[Role]); HTM_TD_End (); } /***** Max. number of students in this group *****/ HTM_TD_Begin ("class=\"CM DAT_%s%s\"", - The_GetSuffix (), - Highlight ? " BG_HIGHLIGHT" : - ""); + The_GetSuffix (),HighlightClass[Highlight]); Grp_WriteMaxStds (StrMaxStudents,Grp->MaxStudents); HTM_TxtF ("%s ",StrMaxStudents); HTM_TD_End (); /***** Vacants in this group *****/ HTM_TD_Begin ("class=\"CM DAT_%s%s\"", - The_GetSuffix (), - Highlight ? " BG_HIGHLIGHT" : - ""); + The_GetSuffix (),HighlightClass[Highlight]); if (Grp->MaxStudents <= Grp_MAX_STUDENTS_IN_A_GROUP) { Vacant = (int) Grp->MaxStudents - (int) Grp->NumUsrs[Rol_STD]; diff --git a/swad_layout.c b/swad_layout.c index d43b8834..02d70654 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -79,6 +79,12 @@ extern struct Globals Gbl; +const char *Lay_HighlightClass[Lay_NUM_HIGHLIGHT] = + { + [Lay_NO_HIGHLIGHT] = NULL, + [Lay_HIGHLIGHT ] = "class=\"BG_HIGHLIGHT\"", + }; + /*****************************************************************************/ /***************************** Private prototypes ****************************/ /*****************************************************************************/ diff --git a/swad_layout.h b/swad_layout.h index 1321c0e8..548c0041 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -54,6 +54,13 @@ typedef enum Lay_HORIZONTAL_LINE_AT_RIGHT, } Lay_HorizontalLineAtRight_t; +#define Lay_NUM_HIGHLIGHT 2 +typedef enum + { + Lay_NO_HIGHLIGHT, + Lay_HIGHLIGHT, + } Lay_Highlight_t; + /*****************************************************************************/ /****************************** Public prototypes ****************************/ /*****************************************************************************/ diff --git a/swad_notice.c b/swad_notice.c index fd1adccc..187e4ee7 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -93,7 +93,7 @@ static void Not_GetNoticeDataFromRow (MYSQL_RES *mysql_res, Not_Listing_t TypeNoticesListing); static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, struct Not_Notice *Notice, - bool Highlight); + Lay_Highlight_t Highlight); static void Not_PutParNotCod (void *NotCod); @@ -357,7 +357,8 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod) /* Draw notice */ Not_DrawANotice (TypeNoticesListing,&Notice, - (Notice.NotCod == HighlightNotCod)); // Highlighted? + (Notice.NotCod == HighlightNotCod) ? Lay_HIGHLIGHT : + Lay_NO_HIGHLIGHT); } switch (TypeNoticesListing) @@ -452,8 +453,7 @@ static void Not_GetDataAndShowNotice (long NotCod) Not_GetNoticeDataFromRow (mysql_res,&Notice,Not_LIST_FULL_NOTICES); /***** Draw the notice *****/ - Not_DrawANotice (Not_LIST_FULL_NOTICES,&Notice, - false); // Not highlighted + Not_DrawANotice (Not_LIST_FULL_NOTICES,&Notice,Lay_NO_HIGHLIGHT); } /***** Free structure that stores the query result *****/ @@ -513,7 +513,7 @@ static void Not_GetNoticeDataFromRow (MYSQL_RES *mysql_res, static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, struct Not_Notice *Notice, - bool Highlight) + Lay_Highlight_t Highlight) { extern const char *Txt_See_full_notice; static const Act_Action_t ActionHideUnhide[HidVis_NUM_HIDDEN_VISIBLE] = @@ -531,6 +531,11 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, [Not_LIST_BRIEF_NOTICES] = "NOTICE_BOX_NARROW", [Not_LIST_FULL_NOTICES ] = "NOTICE_BOX_WIDE", }; + static const char *ContainerHighLightClass[Lay_NUM_HIGHLIGHT] = + { + [Lay_NO_HIGHLIGHT] = "", + [Lay_HIGHLIGHT ] = " NOTICE_HIGHLIGHT", + }; static unsigned UniqueId = 0; char *Id; struct Usr_Data UsrDat; @@ -544,8 +549,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, { HTM_ARTICLE_Begin (Anchor); HTM_DIV_Begin ("class=\"NOTICE_CONT%s\"", - Highlight ? " NOTICE_HIGHLIGHT" : - ""); + ContainerHighLightClass[Highlight]); } /***** Begin yellow note *****/