App-Dochazka-WWW
view release on metacpan or search on metacpan
share/js/dochazka-www/caches.js view on Meta::CPAN
[beginTime, endTime] = dt.canonicalizeTimeRangeOffset(endTime + String(offset));
populateLastPlusOffsetFormFields(beginTime + '-' + endTime);
populateContinue(populateArray);
return null;
}
if (schedIntvls && ! lastExistIntvl) {
[beginTime, endTime] = schedIntvls[0].split('-');
[beginTime, endTime] = dt.canonicalizeTimeRangeOffset(beginTime + String(offset));
populateLastPlusOffsetFormFields(beginTime + '-' + endTime);
populateContinue(populateArray);
return null;
}
// Names/meanings of variables
//
// "eolei": end of last existing interval
[beginTime, endTime] = lastExistIntvl.split('-');
eolei = endTime;
console.log("eolei is " + eolei);
//
// "withinSchedIntvl": eolei falls within a schedule interval (boolean)
// Example: eolei is 8:00, schedIntvl is 8:00-12:00 -> true
// Example: eolei is 12:00, schedIntvl is 8:00-12:00 -> false
// Example: eolei is 11:55, schedIntvl is 8:00-12:00 -> true
// (Calculate withSchedIntvl by comparing eolei with each schedIntvl in turn.
// If computation is true for any of them, then the result is true)
for (i = 0; i < schedIntvls.length; i += 1) {
withinSchedIntvl = dt.isTimeWithinTimeRange(eolei, schedIntvls[i]);
if (withinSchedIntvl) {
[beginTime, endTime] = dt.canonicalizeTimeRangeOffset(eolei + String(offset));
populateLastPlusOffsetFormFields(beginTime + '-' + endTime);
populateContinue(populateArray);
return null;
}
}
console.log("eolei does not fall within any of the schedule intervals");
//
// "schedAfter": first schedule interval that lies fully after eolei
schedAfter = null;
for (i = 0; i < schedIntvls.length; i += 1) {
if (dt.isTimeRangeAfterTime(schedIntvls[i], eolei)) {
schedAfter = schedIntvls[i];
break;
}
}
// if schedAfter, add offset to beginning of schedAfter
// else, add offset to eolei
if (schedAfter) {
console.log("There is a schedule interval after eolei");
[beginTime, endTime] = schedAfter.split('-');
[beginTime, endTime] = dt.canonicalizeTimeRangeOffset(beginTime + String(offset));
} else {
console.log("There is no schedule interval after eolei");
[beginTime, endTime] = dt.canonicalizeTimeRangeOffset(eolei + String(offset));
}
populateLastPlusOffsetFormFields(beginTime + '-' + endTime);
populateContinue(populateArray);
},
populateLastPlusOffsetFormFields = function (buf) {
var formField = $('#iNlastplusoffset'),
formInput = $('input[id="iNtimerange"');
formField.html(String(buf));
formInput.val(String(buf));
},
populateNextScheduled = function (populateArray) {
var cu = currentUser('obj'),
schedIntvls = $('#iNschedintvls').text(),
m, sid, date, rest, sc, fc, populateContinue;
date = $("#iNdate").text();
console.log("Entering populateNextScheduled() with date " + date);
if (date === "(none)") {
date = null;
}
// Though #iNsid is hidden, the following will display its value
// console.log("SID", document.getElementById("iNsid").textContent);
populateContinue = populate.shift(populateArray);
sid = parseInt($("#iNsid").text(), 10);
if (coreLib.isInteger(sid) && sid > 0) {
console.log("Active schedule of EID " + cu.eid + " for " + date + " has SID " + sid);
} else {
m = "User " + cu.nick + " has no active schedule for " + date;
console.log(m);
coreLib.displayError(m);
populateContinue(populateArray);
return null;
}
// there is an active schedule: determine the schedule intervals
// while avoiding existing intervals
if (schedIntvls === "(none)") {
schedIntvls = null;
}
rest = {
"method": "POST",
"path": "interval/fillup",
"body": {
'clobber': '0',
'tsrange': fullDayTsrange(date),
'dry_run': '1',
'eid': String(cu.eid),
},
};
sc = function (st) {
if (st.code === "DISPATCH_SCHEDULED_INTERVALS_IDENTIFIED") {
appLib.displayIntervals([st.payload.success.intervals[0]], $('#iNnextscheduled'));
$('input[id="iNtimerange"]').val(
dt.tsrangeToTimeRange(st.payload.success.intervals[0].intvl)
);
} else {
if (date) {
m = "No unfulfilled scheduled intervals for " + date;
} else {
m = "No date given";
}
console.log("ERROR: " + m);
coreLib.displayError(m);
}
populateContinue(populateArray);
};
fc = function (st) {
coreLib.displayError(st.payload.message);
populateContinue(populateArray);
};
ajax(rest, sc, fc);
},
populateSchedIntvlsForDate = function (populateArray) {
var cu = currentUser('obj'),
sid, date, tsr, rest, sc, fc, populateContinue;
date = $("#iNdate").text();
console.log("Entering populateSchedIntvlsForDate() with date " + date);
// Though #iNsid is hidden, the following will display its value
// console.log("SID", document.getElementById("iNsid").textContent);
populateContinue = populate.shift(populateArray);
sid = parseInt($("#iNsid").text(), 10);
if (coreLib.isInteger(sid) && sid > 0) {
console.log("Active schedule of EID " + cu.eid + " for " + date + " has SID " + sid);
} else {
console.log("EID " + cu.eid + " has no active schedule for " + date);
populateContinue(populateArray);
return null;
}
// there is an active schedule: determine the schedule intervals
tsr = fullDayTsrange(date);
rest = {
"method": "POST",
"path": "interval/scheduled",
"body": {
'tsrange': tsr,
'eid': String(cu.eid),
},
};
sc = function (st) {
if (st.code === "DISPATCH_SCHEDULED_INTERVALS_IDENTIFIED") {
appLib.displayIntervals(st.payload.success.intervals, $('#iNschedintvls'));
}
populateContinue(populateArray);
};
fc = function (st) {
coreLib.displayError(st.payload.message);
populateContinue(populateArray);
};
ajax(rest, sc, fc);
},
populateScheduleBySID = function (populateArray) {
( run in 2.847 seconds using v1.01-cache-2.11-cpan-98e64b0badf )