Version 15.17.3

This commit is contained in:
Antonio Cañas Vargas 2015-10-23 10:40:16 +02:00
parent c0ff3a3838
commit 633b5b4ee2
3 changed files with 52 additions and 47 deletions

View File

@ -43,16 +43,22 @@ function writeLocalDateFromUTC(id,secsSince1970UTC) {
// Write a date-time in client local time // Write a date-time in client local time
function writeLocalDateTimeFromUTC(id,secsSince1970UTC) { function writeLocalDateTimeFromUTC(id,secsSince1970UTC) {
var d = new Date; var d = new Date;
var Minutes; var H;
var StrMinutes; var M;
var S;
var StrH;
var StrM;
var StrS;
d.setTime(secsSince1970UTC * 1000); d.setTime(secsSince1970UTC * 1000);
Minutes = d.getMinutes(); H = d.getHours();
Seconds = d.getSeconds(); M = d.getMinutes();
StrMinutes = ((Minutes < 10) ? "0" : "") + Minutes; S = d.getSeconds();
StrSeconds = ((Seconds < 10) ? "0" : "") + Seconds; StrH = ((H < 10) ? '0' : '') + H;
document.getElementById(id).innerHTML = d.toLocaleDateString() + "<br />" + StrM = ((M < 10) ? '0' : '') + M;
d.getHours() + ":" + StrMinutes + ":" + StrSeconds; StrS = ((S < 10) ? '0' : '') + S;
document.getElementById(id).innerHTML = d.toLocaleDateString() + '<br />' +
StrH + ':' + StrM + ':' + StrS;
} }
// Set local date-time form fields from UTC time // Set local date-time form fields from UTC time
@ -65,8 +71,7 @@ function setLocalDateTimeFormFromUTC(id,secsSince1970UTC) {
Year = d.getFullYear() Year = d.getFullYear()
for (var i=0; i<YearForm.options.length ; i++) for (var i=0; i<YearForm.options.length ; i++)
if (YearForm.options[i].value == Year) if (YearForm.options[i].value == Year) {
{
YearForm.options[i].selected = true; YearForm.options[i].selected = true;
break; break;
} }
@ -112,8 +117,7 @@ function adjustDateForm (id) {
if (DayForm.selectedIndex > Days) if (DayForm.selectedIndex > Days)
DayForm.options[Days].selected = true; DayForm.options[Days].selected = true;
for (var i=DayForm.options.length; i<=Days ; i++) // Create new days for (var i=DayForm.options.length; i<=Days ; i++) { // Create new days
{
var x = String (i); var x = String (i);
DayForm.options[i] = new Option(x,x); DayForm.options[i] = new Option(x,x);
} }
@ -137,29 +141,30 @@ function setDateTo (elem,Day,Month,Year) {
// Write clock in client local time updated every minute // Write clock in client local time updated every minute
function writeLocalClock() { function writeLocalClock() {
var d = new Date; var d = new Date;
var Minutes; var H;
var StrMinutes; var M;
var PrintableDate; var StrH;
var StrM;
setTimeout("writeLocalTime()",60000); setTimeout('writeLocalTime()',60000);
d.setTime(secondsSince1970UTC * 1000); d.setTime(secondsSince1970UTC * 1000);
secondsSince1970UTC += 60; // For next call secondsSince1970UTC += 60; // For next call
Minutes = d.getMinutes(); H = d.getHours();
StrMinutes = ((Minutes < 10) ? "0" : "") + Minutes; M = d.getMinutes();
// PrintableDate = d.toLocaleDateString() + "<br />" + d.getHours() + ":" + StrMinutes; StrH = ((H < 10) ? '0' : '') + H;
PrintableDate = d.getHours() + ":" + StrMinutes; StrM = ((M < 10) ? '0' : '') + M;
document.getElementById('hm').innerHTML = PrintableDate; document.getElementById('hm').innerHTML = StrH + ':' + StrM;
} }
function writeClockConnected() { function writeClockConnected() {
var BoxClock; var BoxClock;
var Hours; var H;
var Minutes; var M;
var Seconds; var S;
var StrMinutes; var StrM;
var StrSeconds; var StrS;
var PrintableClock; var PrintableClock;
countClockConnected++; countClockConnected++;
@ -169,27 +174,27 @@ function writeClockConnected() {
if (BoxClock) { if (BoxClock) {
ListSeconds[i] += 1; ListSeconds[i] += 1;
if (!countClockConnected) { // Print after 10 seconds if (!countClockConnected) { // Print after 10 seconds
Minutes = Math.floor(ListSeconds[i] / 60); M = Math.floor(ListSeconds[i] / 60);
if (Minutes >= 60) { if (M >= 60) {
Hours = Math.floor(Minutes / 60); H = Math.floor(M / 60);
Minutes %= 60; M %= 60;
} else } else
Hours = 0; H = 0;
Seconds = ListSeconds[i] % 60; S = ListSeconds[i] % 60;
if (Hours != 0) { if (H != 0) {
StrMinutes = ((Minutes < 10) ? "0" : "") + Minutes; StrM = ((M < 10) ? '0' : '') + M;
StrSeconds = ((Seconds < 10) ? "0" : "") + Seconds; StrS = ((S < 10) ? '0' : '') + S;
PrintableClock = Hours + ":" + StrMinutes + "'" + StrSeconds + "&quot;"; PrintableClock = H + ':' + StrM + '&#39;' + StrS + '&quot;';
} else if (Minutes != 0) { } else if (M != 0) {
StrSeconds = ((Seconds < 10) ? "0" : "") + Seconds; StrS = ((S < 10) ? '0' : '') + S;
PrintableClock = Minutes + "'" + StrSeconds + "&quot;"; PrintableClock = M + '&#39;' + StrS + '&quot;';
} else } else
PrintableClock = Seconds + "&quot;"; PrintableClock = S + '&quot;';
BoxClock.innerHTML = PrintableClock; BoxClock.innerHTML = PrintableClock;
} }
} }
} }
setTimeout("writeClockConnected()",1000); // refresh after 1 second setTimeout('writeClockConnected()',1000); // refresh after 1 second
} }
// Automatic refresh of connected users using AJAX. This function must be called from time to time // Automatic refresh of connected users using AJAX. This function must be called from time to time
@ -225,10 +230,10 @@ function AJAXCreateObject() {
obj = new XMLHttpRequest(); obj = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE } else if (window.ActiveXObject) { // IE
try { try {
obj = new ActiveXObject("Msxml2.XMLHTTP"); obj = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) { } catch (e) {
try { try {
obj = new ActiveXObject("Microsoft.XMLHTTP"); obj = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {} } catch (e) {}
} }
} }
@ -277,7 +282,7 @@ function readConnUsrsData() {
} }
if (delay >= 60000) // If refresh slower than 1 time each 60 seconds, do refresh; else abort if (delay >= 60000) // If refresh slower than 1 time each 60 seconds, do refresh; else abort
setTimeout("refreshConnected()",delay); setTimeout('refreshConnected()',delay);
} }
} }
} }
@ -296,7 +301,7 @@ function readLastClicksData() {
if (divLastClicks) if (divLastClicks)
divLastClicks.innerHTML = htmlLastClicks; // Update global connected DIV divLastClicks.innerHTML = htmlLastClicks; // Update global connected DIV
if (delay > 200) // If refresh slower than 1 time each 0.2 seconds, do refresh; else abort if (delay > 200) // If refresh slower than 1 time each 0.2 seconds, do refresh; else abort
setTimeout("refreshLastClicks()",delay); setTimeout('refreshLastClicks()',delay);
} }
} }
} }

View File

@ -57,7 +57,6 @@ struct Assignment
long AsgCod; long AsgCod;
bool Hidden; bool Hidden;
long UsrCod; long UsrCod;
// struct DateTime DateTimes[Asg_NUM_DATES];
time_t TimeUTC[Asg_NUM_DATES]; time_t TimeUTC[Asg_NUM_DATES];
bool Open; bool Open;
char Title[Asg_MAX_LENGTH_ASSIGNMENT_TITLE+1]; char Title[Asg_MAX_LENGTH_ASSIGNMENT_TITLE+1];

View File

@ -108,11 +108,12 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.17.2 (2015/10/23)" #define Log_PLATFORM_VERSION "SWAD 15.17.3 (2015/10/23)"
// 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.17.3: Oct 23, 2015 Changes in JavaScript functions related to date-time. (186477 lines)
Version 15.17.2: Oct 23, 2015 Code refactoring related to forms. (186472 lines) Version 15.17.2: Oct 23, 2015 Code refactoring related to forms. (186472 lines)
Version 15.17.1: Oct 23, 2015 Code refactoring related to dates and JavaScript. (186407 lines) Version 15.17.1: Oct 23, 2015 Code refactoring related to dates and JavaScript. (186407 lines)
Version 15.17: Oct 22, 2015 Code refactoring related to dates and JavaScript. Version 15.17: Oct 22, 2015 Code refactoring related to dates and JavaScript.