App-Dochazka-WWW
view release on metacpan or search on metacpan
share/js/dochazka-www/svg-lib.js view on Meta::CPAN
], function (
appCaches,
dt,
)
{
var
absWidth = 870,
dayViewerIntervals = function (date, obj, how) {
// returns an SVG document for date, reflecting clocked and
// scheduled intervals in obj; how is a boolean value "holiday or
// weekend"
var r = '',
fill, i, intvl, begin, bo, end, eo, color;
if (how) {
fill = 'font-weight="bold" fill="transparent"';
} else {
fill = 'fill="black"';
}
r += '<svg width="' + absWidth + '" height="30" ' + svgBoilerPlate + '>';
// draw base rectangle
r += '<rect x="5" y="0" width="' + absWidth + '" height="30" fill="gray" stroke="transparent"/>';
// draw attendance intervals
for (i = 0; i < obj.clocked.length; i += 1) {
intvl = obj.clocked[i];
[begin, end] = intvl.iNtimerange.split('-');
[bo, eo] = [timeToOffset(begin), timeToOffset(end)];
color = appCaches.getActivityByAID(intvl.aid).color;
r += '<rect x="' + bo + '" y="0" width="' + (eo - bo) + '" height="30" ' +
'fill="' + color + '" stroke="transparent"/>';
}
// draw schedule intervals
for (i = 0; i < obj.scheduled.length; i += 1) {
intvl = obj.scheduled[i];
[begin, end] = intvl.split('-');
share/js/dochazka-www/viewer.js view on Meta::CPAN
i,
r = '',
lwhow = false; // "Last [date] Was a Holiday Or Weekend"
console.log("currentUserObject", cu);
if (cu.fullname) {
r += '<b>' + cu.fullname + '</b>';
} else {
r += '<b>' + cu.nick + '</b>';
}
r += '<br><br>';
r += "Intervals (scheduled and clocked) during period from " + obj.beginDate + " to " + obj.endDate;
r += '<br><br>';
r += svgLib.dayViewerScale();
for (i = 0; i < sortedDates.length; i += 1) {
// draw new scale if needed (for each week, more or less)
date = sortedDates[i];
if (lwhow && ! holidayOrWeekend(date) && i !== sortedDates.length - 1) {
r += svgLib.dayViewerScale();
}
lwhow = holidayOrWeekend(date);
r += svgLib.dayViewerIntervals(date, haw[date], lwhow);
share/js/dochazka-www/viewer.js view on Meta::CPAN
initializeStore = function (pl) {
// by "Store" here, I mean "haw" and "sortedDates"
var date, i;
haw = $.extend({}, pl);
sortedDates = Object.keys(haw).sort();
for (i = 0; i < sortedDates.length; i += 1) {
date = sortedDates[i];
if (! haw[date].hasOwnProperty('scheduled')) {
haw[date].scheduled = [];
}
if (! haw[date].hasOwnProperty('clocked')) {
haw[date].clocked = [];
}
}
}
;
return {
'multiDayViewer': function (obj) {
var i,
tsr = '[ ' + obj.beginDate + ' 00:00, ' + obj.endDate + ' 23:59 )',
share/js/dochazka-www/viewer.js view on Meta::CPAN
rest = {
"method": "GET",
"path": "holiday/" + tsr,
},
sc = function (st) {
if (st.code === 'DOCHAZKA_HOLIDAYS_AND_WEEKENDS_IN_TSRANGE') {
initializeStore(st.payload);
for (i = 0; i < obj.intervals.length; i += 1) {
aid = obj.intervals[i].aid;
[date, tr] = [obj.intervals[i].iNdate, obj.intervals[i].iNtimerange];
haw[date].clocked.push({"iNtimerange": tr, "aid": aid});
}
addScheduledIntervals(obj);
} else {
throw "unexpected holidays status code " + st.code;
}
};
ajax(rest, sc);
return null;
},
( run in 0.616 second using v1.01-cache-2.11-cpan-49f99fa48dc )