From 193bdac6996502bb82f11f58a942225c4169cb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 29 Oct 2015 17:46:48 +0100 Subject: [PATCH] Version 15.29.2 --- js/swad.js | 103 +++++++++++++++++++---------------------------- swad_calendar.c | 37 +++++++++++++++-- swad_changelog.h | 3 +- 3 files changed, 76 insertions(+), 67 deletions(-) diff --git a/js/swad.js b/js/swad.js index 6bfcc3bdc..68e92fa47 100644 --- a/js/swad.js +++ b/js/swad.js @@ -670,31 +670,8 @@ function DrawCurrentMonth (id,TimeUTC) { /******************************** Draw a month *******************************/ /*****************************************************************************/ -function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay) +function DrawMonth (id,Year,Month,Today) { - var MONTHS_CAPS = [ - 'ENERO', - 'FEBRERO', - 'MARZO', - 'ABRIL', - 'MAYO', - 'JUNIO', - 'JULIO', - 'AGOSTO', - 'SEPTIEMBRE', - 'OCTUBRE', - 'NOVIEMBRE', - 'DICIEMBRE' - ]; - var DAYS_CAPS = [ - 'L', - 'M', - 'M', - 'J', - 'V', - 'S', - 'D' - ]; var NumDaysMonth = [ 0, 31, // 1: January @@ -713,10 +690,10 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay) // var StrExamOfX; var Week; var DayOfWeek; /* 0, 1, 2, 3, 4, 5, 6 */ - var DayOfMonth; + var Day; var NumDaysInMonth; - var Year = CurrentYear; - var Month = CurrentMonth; + var Yea = Year; + var Mon = Month; // var YYYYMMDD; // var NumHld; var ClassForDay; // Class of day depending on type of day @@ -737,20 +714,20 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay) If it's 0 then write 1 box of the previous month. If it's 1 then write 0 boxes of the previous month. */ - if ((DayOfWeek = GetDayOfWeek (Year,Month,1)) == 0) - DayOfMonth = 1; + if ((DayOfWeek = GetDayOfWeek (Yea,Mon,1)) == 0) + Day = 1; else { - if (Month <= 1) + if (Mon <= 1) { - Month = 12; - Year--; + Mon = 12; + Yea--; } else - Month--; - NumDaysInMonth = (Month == 2) ? GetNumDaysFebruary (Year) : - NumDaysMonth[Month]; - DayOfMonth = NumDaysInMonth - DayOfWeek + 1; + Mon--; + NumDaysInMonth = (Mon == 2) ? GetNumDaysFebruary (Yea) : + NumDaysMonth[Mon]; + Day = NumDaysInMonth - DayOfWeek + 1; } /***** Start of month *****/ @@ -758,7 +735,7 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay) /***** Month name *****/ HTMLContent += '
' + - MONTHS_CAPS[CurrentMonth-1] + ' ' + CurrentYear + + MONTHS_CAPS[Month-1] + ' ' + Year + '
'; /***** Month head: first letter for each day of week *****/ @@ -770,7 +747,9 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay) HTMLContent += '' + DAYS_CAPS[DayOfWeek] + ''; + '">' + + DAYS_CAPS[DayOfWeek] + + ''; HTMLContent += ''; /***** Draw every week of the month *****/ @@ -786,34 +765,34 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay) DayOfWeek++) { /***** Set class for day being drawn *****/ - ClassForDay = (Month == CurrentMonth) ? 'DAY_WRK' : - 'DAY_WRK_LIGHT'; + ClassForDay = (Mon == Month) ? 'DAY_WRK' : + 'DAY_WRK_LIGHT'; /* Day being drawn is sunday? */ if (DayOfWeek == 6) // All the sundays are holidays - ClassForDay = (Month == CurrentMonth) ? 'DAY_HLD' : - 'DAY_HLD_LIGHT'; + ClassForDay = (Mon == Month) ? 'DAY_HLD' : + 'DAY_HLD_LIGHT'; /* Date being drawn is today? */ /* - IsToday = (Gbl.CurrentAct != ActPrnCal && Month == CurrentMonth && - Year == Gbl.Now.Date.Year && - Month == Gbl.Now.Date.Month && - DayOfMonth == Gbl.Now.Date.Day); + IsToday = (Gbl.CurrentAct != ActPrnCal && Mon == Month && + Yea == Gbl.Now.Date.Yea && + Mon == Gbl.Now.Date.Month && + Day == Gbl.Now.Date.Day); */ - IsToday = (Year == CurrentYear && - Month == CurrentMonth && - DayOfMonth == CurrentDay); + IsToday = (Yea == Year && + Mon == Month && + Day == Today); /* Check if day has an exam announcement */ /* ThisDayHasEvent = false; - if (!DrawingCalendar || Month == CurrentMonth) // If drawing calendar and the month is not the real one, don't draw exam announcements + if (!DrawingCalendar || Mon == Month) // If drawing calendar and the month is not the real one, don't draw exam announcements for (NumExamAnnouncement = 0; NumExamAnnouncement < Gbl.LstExamAnnouncements.NumExamAnnounc; NumExamAnnouncement++) - if (Year == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year && - Month == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month && - DayOfMonth == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day) + if (Yea == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year && + Mon == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month && + Day == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day) { ThisDayHasEvent = true; if (PutLinkToEvents) @@ -823,7 +802,7 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay) StrExamOfX, Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day, Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month, - Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year); + Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Yea); } break; } @@ -861,7 +840,7 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay) */ /* Write the day of month */ - HTMLContent += DayOfMonth; + HTMLContent += Day; /* If day has an exam announcement */ /* @@ -880,16 +859,16 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay) HTMLContent += ''; /***** Set the next day *****/ - NumDaysInMonth = (Month == 2) ? GetNumDaysFebruary (Year) : - NumDaysMonth[Month]; - if (++DayOfMonth > NumDaysInMonth) + NumDaysInMonth = (Mon == 2) ? GetNumDaysFebruary (Yea) : + NumDaysMonth[Mon]; + if (++Day > NumDaysInMonth) { - if (++Month > 12) + if (++Mon > 12) { - Year++; - Month = 1; + Yea++; + Mon = 1; } - DayOfMonth = 1; + Day = 1; } } HTMLContent += ''; diff --git a/swad_calendar.c b/swad_calendar.c index dde264983..33bb32f6a 100644 --- a/swad_calendar.c +++ b/swad_calendar.c @@ -53,6 +53,11 @@ static void Cal_DrawMonth (unsigned RealYear,unsigned RealMonth, void Cal_DrawCurrentMonth (void) { + extern const char *Txt_MONTHS_CAPS[12]; + extern const char *Txt_DAYS_CAPS[7]; + unsigned Month; + unsigned DayOfWeek; /* 0, 1, 2, 3, 4, 5, 6 */ + /***** Get list of holidays *****/ if (!Gbl.Hlds.LstIsRead) { @@ -66,11 +71,35 @@ void Cal_DrawCurrentMonth (void) /***** Draw the month *****/ Cal_DrawMonth (Gbl.Now.Date.Year,Gbl.Now.Date.Month,false,true,false); + /***** Draw the month in JavaScript *****/ + /* JavaScript will write HTML here */ fprintf (Gbl.F.Out,"
" - "
" - "", + ""); + + /* Write script to draw the month */ + fprintf (Gbl.F.Out,"\n", (long) Gbl.StartExecutionTimeUTC); /***** Free list of dates of exam announcements *****/ diff --git a/swad_changelog.h b/swad_changelog.h index 2e4538e14..cf68328e6 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -108,11 +108,12 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.29.1 (2015/10/29)" +#define Log_PLATFORM_VERSION "SWAD 15.29.2 (2015/10/29)" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* + Version 15.29.2: Oct 29, 2015 Writing JavaScript function to draw a month in browser. Not finished. (186694 lines) Version 15.29.1: Oct 29, 2015 Writing JavaScript function to draw a month in browser. Not finished. (186694 lines) Version 15.29: Oct 29, 2015 Writing JavaScript function to draw a month in browser. Not finished. (186684 lines) Version 15.28.1: Oct 28, 2015 Fixed bug in the calculation of some statistics. (186416 lines)