Version 15.41

This commit is contained in:
Antonio Cañas Vargas 2015-11-21 14:30:53 +01:00
parent 45bf293418
commit 0b13d86fc2
3 changed files with 35 additions and 27 deletions

View File

@ -619,7 +619,7 @@ function disableDetailedClicks() {
/************************ Draw an academic calendar **************************/
/*****************************************************************************/
function Cal_DrawCalendar (id,TimeUTC,CurrentPlcCod,PrintView,
function Cal_DrawCalendar (id,Sunday,TimeUTC,CurrentPlcCod,PrintView,
CGI,FormGoToCalendarParams,FormEventParams) {
var StartingMonth = [ // Calendar starts one row before current month
9, // January --> September
@ -633,7 +633,7 @@ function Cal_DrawCalendar (id,TimeUTC,CurrentPlcCod,PrintView,
5, // September --> May
5, // October --> May
5, // November --> May
5 // December --> May
5 // December --> May
];
var d = new Date;
d.setTime(TimeUTC * 1000);
@ -662,9 +662,9 @@ function Cal_DrawCalendar (id,TimeUTC,CurrentPlcCod,PrintView,
MonthId = id + '_month_' + MonthIdNum;
Gbl_HTMLContent += '<td class="CENTER_TOP" style="width:150px;">';
DrawMonth(MonthId, Year, Month, CurrentMonth, CurrentDay,
CurrentPlcCod, true, PrintView, CGI,
FormGoToCalendarParams, FormEventParams);
DrawMonth (MonthId,Sunday,Year,Month,CurrentMonth,CurrentDay,
CurrentPlcCod,true,PrintView,CGI,
FormGoToCalendarParams,FormEventParams);
Gbl_HTMLContent += '</td>';
if (++Month == 13) {
Month = 1;
@ -682,7 +682,7 @@ function Cal_DrawCalendar (id,TimeUTC,CurrentPlcCod,PrintView,
/***************************** Draw current month ****************************/
/*****************************************************************************/
function DrawCurrentMonth (id,TimeUTC,CurrentPlcCod,
function DrawCurrentMonth (id,Sunday,TimeUTC,CurrentPlcCod,
CGI,FormGoToCalendarParams,FormEventParams) {
var d = new Date;
d.setTime(TimeUTC * 1000);
@ -690,17 +690,20 @@ function DrawCurrentMonth (id,TimeUTC,CurrentPlcCod,
var Month = d.getMonth() + 1;
var CurrentDay = d.getDate();
DrawMonth(id,Year,Month,Month,CurrentDay,CurrentPlcCod,false,false,
CGI,FormGoToCalendarParams,FormEventParams);
DrawMonth (id,Sunday,Year,Month,Month,CurrentDay,
CurrentPlcCod,false,false,
CGI,FormGoToCalendarParams,FormEventParams);
document.getElementById(id).innerHTML = Gbl_HTMLContent;
}
/*****************************************************************************/
/******************************** Draw a month *******************************/
/******************************* Draw a month ********************************/
/*****************************************************************************/
// Sunday == 0 ==> Sunday is the first day of the week
// Sunday == 6 ==> Sunday is the last day of the week
function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlcCod,
DrawingCalendar,PrintView,
function DrawMonth (id,Sunday,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,
CurrentPlcCod,DrawingCalendar,PrintView,
CGI,FormGoToCalendarParams,FormEventParams) {
var NumDaysMonth = [
0,
@ -747,7 +750,7 @@ function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlc
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(Yea, Mon, 1)) == 0)
if ((DayOfWeek = (GetDayOfWeekMondayFirst (Yea,Mon,1) + Sunday + 1) % 7) == 0)
Day = 1;
else {
if (Mon <= 1) {
@ -784,10 +787,10 @@ function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlc
Gbl_HTMLContent += '<table class="MONTH_TABLE_DAYS">' + '<tr>';
for (DayOfWeek = 0; DayOfWeek < 7; DayOfWeek++)
Gbl_HTMLContent += '<td class="' +
((DayOfWeek == 6) ? 'DAY_NO_WRK_HEAD' :
'DAY_WRK_HEAD') +
((DayOfWeek == Sunday) ? 'DAY_NO_WRK_HEAD' :
'DAY_WRK_HEAD') +
'">' +
DAYS_CAPS[DayOfWeek] +
DAYS_CAPS[(DayOfWeek + 6 - Sunday) % 7] +
'</td>';
Gbl_HTMLContent += '</tr>';
@ -837,7 +840,7 @@ function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlc
}
/* Day being drawn is sunday? */
if (DayOfWeek == 6) // All the sundays are holidays
if (DayOfWeek == Sunday) // All the sundays are holidays
ClassForDay = (Mon == MonthToDraw) ? 'DAY_HLD' :
'DAY_HLD_LIGHT';
@ -922,16 +925,16 @@ function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlc
}
/*****************************************************************************/
/***************** Compute day of the week from a given date *****************/
/* Compute day of the week from a given date (monday as first day of a week) */
/*****************************************************************************/
// Return 0 for monday, 1 for tuesday,... 6 for sunday
function GetDayOfWeek (Year,Month,Day) {
if (Month <= 2) {
Month += 12;
Year--;
}
return (((Day +
function GetDayOfWeekMondayFirst (Year,Month,Day) {
if (Month <= 2) {
Month += 12;
Year--;
}
return (((Day +
(Month * 2) +
Math.floor (((Month + 1) * 3) / 5) +
Year +
@ -940,7 +943,7 @@ function GetDayOfWeek (Year,Month,Day) {
Math.floor (Year/400) +
2) % 7) + 5) % 7;
}
/*****************************************************************************/
/****************** Return the number of days of february ********************/
/*****************************************************************************/

View File

@ -52,6 +52,7 @@ void Cal_DrawCurrentMonth (void)
{
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
char Params[256+256+Ses_LENGTH_SESSION_ID+256];
unsigned Sunday = 6;
/***** Get list of holidays *****/
if (!Gbl.Hlds.LstIsRead)
@ -71,7 +72,8 @@ void Cal_DrawCurrentMonth (void)
/* Write script to draw the month */
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
" Gbl_HTMLContent = '';"
" DrawCurrentMonth ('CurrentMonth',%ld,%ld,'%s/%s',",
" DrawCurrentMonth ('CurrentMonth',%u,%ld,%ld,'%s/%s',",
Sunday,
(long) Gbl.StartExecutionTimeUTC,
Gbl.CurrentCtr.Ctr.PlcCod,
Cfg_HTTPS_URL_SWAD_CGI,Txt_STR_LANG_ID[Gbl.Prefs.Language]);
@ -109,6 +111,7 @@ void Cal_DrawCalendar (void)
{
extern const char *Txt_Print;
bool PrintView = (Gbl.CurrentAct == ActPrnCal);
unsigned Sunday = 6;
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
char Params[256+256+Ses_LENGTH_SESSION_ID+256];
@ -147,7 +150,8 @@ void Cal_DrawCalendar (void)
/* Write script to draw the month */
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
" Gbl_HTMLContent = '';"
" Cal_DrawCalendar('calendar',%ld,%ld,%s,'%s/%s',",
" Cal_DrawCalendar('calendar',%u,%ld,%ld,%s,'%s/%s',",
Sunday,
(long) Gbl.StartExecutionTimeUTC,
Gbl.CurrentCtr.Ctr.PlcCod,
(Gbl.CurrentAct == ActPrnCal) ? "true" :

View File

@ -111,11 +111,12 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.40.8 (2015/11/20)"
#define Log_PLATFORM_VERSION "SWAD 15.41 (2015/11/21)"
// 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.41: Nov 21, 2015 Javascript code to draw a month with sunday as the first day of a week. (187316 lines)
Version 15.40.8: Nov 20, 2015 Password is requested only one time when creating a new account. (187309 lines)
Version 15.40.7: Nov 20, 2015 New help button to register students in courses without them. (187319 lines)
Version 15.40.6: Nov 20, 2015 New button to register students in courses without them.