Version 15.29.2

This commit is contained in:
Antonio Cañas Vargas 2015-10-29 17:46:48 +01:00
parent 1a68c78525
commit 193bdac699
3 changed files with 76 additions and 67 deletions

View File

@ -670,31 +670,8 @@ function DrawCurrentMonth (id,TimeUTC) {
/******************************** Draw a month *******************************/ /******************************** 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 = [ var NumDaysMonth = [
0, 0,
31, // 1: January 31, // 1: January
@ -713,10 +690,10 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay)
// var StrExamOfX; // var StrExamOfX;
var Week; var Week;
var DayOfWeek; /* 0, 1, 2, 3, 4, 5, 6 */ var DayOfWeek; /* 0, 1, 2, 3, 4, 5, 6 */
var DayOfMonth; var Day;
var NumDaysInMonth; var NumDaysInMonth;
var Year = CurrentYear; var Yea = Year;
var Month = CurrentMonth; var Mon = Month;
// var YYYYMMDD; // var YYYYMMDD;
// var NumHld; // var NumHld;
var ClassForDay; // Class of day depending on type of day 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 0 then write 1 box of the previous month.
If it's 1 then write 0 boxes of the previous month. */ If it's 1 then write 0 boxes of the previous month. */
if ((DayOfWeek = GetDayOfWeek (Year,Month,1)) == 0) if ((DayOfWeek = GetDayOfWeek (Yea,Mon,1)) == 0)
DayOfMonth = 1; Day = 1;
else else
{ {
if (Month <= 1) if (Mon <= 1)
{ {
Month = 12; Mon = 12;
Year--; Yea--;
} }
else else
Month--; Mon--;
NumDaysInMonth = (Month == 2) ? GetNumDaysFebruary (Year) : NumDaysInMonth = (Mon == 2) ? GetNumDaysFebruary (Yea) :
NumDaysMonth[Month]; NumDaysMonth[Mon];
DayOfMonth = NumDaysInMonth - DayOfWeek + 1; Day = NumDaysInMonth - DayOfWeek + 1;
} }
/***** Start of month *****/ /***** Start of month *****/
@ -758,7 +735,7 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay)
/***** Month name *****/ /***** Month name *****/
HTMLContent += '<div class="MONTH">' + HTMLContent += '<div class="MONTH">' +
MONTHS_CAPS[CurrentMonth-1] + ' ' + CurrentYear + MONTHS_CAPS[Month-1] + ' ' + Year +
'</div>'; '</div>';
/***** Month head: first letter for each day of week *****/ /***** Month head: first letter for each day of week *****/
@ -770,7 +747,9 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay)
HTMLContent += '<td class="' + HTMLContent += '<td class="' +
((DayOfWeek == 6) ? 'DAY_NO_WRK_HEAD' : ((DayOfWeek == 6) ? 'DAY_NO_WRK_HEAD' :
'DAY_WRK_HEAD') + 'DAY_WRK_HEAD') +
'">' + DAYS_CAPS[DayOfWeek] + '</td>'; '">' +
DAYS_CAPS[DayOfWeek] +
'</td>';
HTMLContent += '</tr>'; HTMLContent += '</tr>';
/***** Draw every week of the month *****/ /***** Draw every week of the month *****/
@ -786,34 +765,34 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay)
DayOfWeek++) DayOfWeek++)
{ {
/***** Set class for day being drawn *****/ /***** Set class for day being drawn *****/
ClassForDay = (Month == CurrentMonth) ? 'DAY_WRK' : ClassForDay = (Mon == Month) ? 'DAY_WRK' :
'DAY_WRK_LIGHT'; 'DAY_WRK_LIGHT';
/* Day being drawn is sunday? */ /* Day being drawn is sunday? */
if (DayOfWeek == 6) // All the sundays are holidays if (DayOfWeek == 6) // All the sundays are holidays
ClassForDay = (Month == CurrentMonth) ? 'DAY_HLD' : ClassForDay = (Mon == Month) ? 'DAY_HLD' :
'DAY_HLD_LIGHT'; 'DAY_HLD_LIGHT';
/* Date being drawn is today? */ /* Date being drawn is today? */
/* /*
IsToday = (Gbl.CurrentAct != ActPrnCal && Month == CurrentMonth && IsToday = (Gbl.CurrentAct != ActPrnCal && Mon == Month &&
Year == Gbl.Now.Date.Year && Yea == Gbl.Now.Date.Yea &&
Month == Gbl.Now.Date.Month && Mon == Gbl.Now.Date.Month &&
DayOfMonth == Gbl.Now.Date.Day); Day == Gbl.Now.Date.Day);
*/ */
IsToday = (Year == CurrentYear && IsToday = (Yea == Year &&
Month == CurrentMonth && Mon == Month &&
DayOfMonth == CurrentDay); Day == Today);
/* Check if day has an exam announcement */ /* Check if day has an exam announcement */
/* /*
ThisDayHasEvent = false; 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; for (NumExamAnnouncement = 0;
NumExamAnnouncement < Gbl.LstExamAnnouncements.NumExamAnnounc; NumExamAnnouncement < Gbl.LstExamAnnouncements.NumExamAnnounc;
NumExamAnnouncement++) NumExamAnnouncement++)
if (Year == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year && if (Yea == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year &&
Month == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month && Mon == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month &&
DayOfMonth == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day) Day == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day)
{ {
ThisDayHasEvent = true; ThisDayHasEvent = true;
if (PutLinkToEvents) if (PutLinkToEvents)
@ -823,7 +802,7 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay)
StrExamOfX, StrExamOfX,
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day, Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day,
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month, Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month,
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year); Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Yea);
} }
break; break;
} }
@ -861,7 +840,7 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay)
*/ */
/* Write the day of month */ /* Write the day of month */
HTMLContent += DayOfMonth; HTMLContent += Day;
/* If day has an exam announcement */ /* If day has an exam announcement */
/* /*
@ -880,16 +859,16 @@ function DrawMonth (id,CurrentYear,CurrentMonth,CurrentDay)
HTMLContent += '</td>'; HTMLContent += '</td>';
/***** Set the next day *****/ /***** Set the next day *****/
NumDaysInMonth = (Month == 2) ? GetNumDaysFebruary (Year) : NumDaysInMonth = (Mon == 2) ? GetNumDaysFebruary (Yea) :
NumDaysMonth[Month]; NumDaysMonth[Mon];
if (++DayOfMonth > NumDaysInMonth) if (++Day > NumDaysInMonth)
{ {
if (++Month > 12) if (++Mon > 12)
{ {
Year++; Yea++;
Month = 1; Mon = 1;
} }
DayOfMonth = 1; Day = 1;
} }
} }
HTMLContent += '</tr>'; HTMLContent += '</tr>';

View File

@ -53,6 +53,11 @@ static void Cal_DrawMonth (unsigned RealYear,unsigned RealMonth,
void Cal_DrawCurrentMonth (void) 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 *****/ /***** Get list of holidays *****/
if (!Gbl.Hlds.LstIsRead) if (!Gbl.Hlds.LstIsRead)
{ {
@ -66,11 +71,35 @@ void Cal_DrawCurrentMonth (void)
/***** Draw the month *****/ /***** Draw the month *****/
Cal_DrawMonth (Gbl.Now.Date.Year,Gbl.Now.Date.Month,false,true,false); 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,"<div id=\"CurrentMonth\">" fprintf (Gbl.F.Out,"<div id=\"CurrentMonth\">"
"</div>" "</div>");
"<script type=\"text/javascript\">"
"DrawCurrentMonth ('CurrentMonth',%ld);" /* Write script to draw the month */
"</script>", fprintf (Gbl.F.Out,"<script type=\"text/javascript\">\n"
" var MONTHS_CAPS = [");
for (Month = 0;
Month < 12;
Month++)
{
if (Month)
fprintf (Gbl.F.Out,",");
fprintf (Gbl.F.Out,"'%s'",Txt_MONTHS_CAPS[Month]);
}
fprintf (Gbl.F.Out,"];\n"
" var DAYS_CAPS = [");
for (DayOfWeek = 0;
DayOfWeek < 7;
DayOfWeek++)
{
if (DayOfWeek)
fprintf (Gbl.F.Out,",");
fprintf (Gbl.F.Out,"'%c'",Txt_DAYS_CAPS[DayOfWeek][0]);
}
fprintf (Gbl.F.Out,"];\n"
" DrawCurrentMonth ('CurrentMonth',%ld);\n"
"</script>\n",
(long) Gbl.StartExecutionTimeUTC); (long) Gbl.StartExecutionTimeUTC);
/***** Free list of dates of exam announcements *****/ /***** Free list of dates of exam announcements *****/

View File

@ -108,11 +108,12 @@
/****************************** Public constants *****************************/ /****************************** 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: // 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 // 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.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.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) Version 15.28.1: Oct 28, 2015 Fixed bug in the calculation of some statistics. (186416 lines)