Go to most recent revision | Blame | Compare with Previous | Last modification | View Log
let radiusDays = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
function scheduleToRadius(serialized) {
let radiusPeriod = [];
for(let day in serialized) {
if(radiusDays[day].length > 0) {
for(let period of serialized[day]) {
radiusPeriod.push(
radiusDays[day] + (period[0] + "-" + period[1]).replace(/:/g, '')
);
}
}
}
return radiusPeriod.join(',');
}
function addPeriodToArray(array, index, hours) {
array[index].push([
hours[0].substr(0,2) + ':' + hours[0].substr(2,4),
hours[1].substr(0,2) + ':' + hours[1].substr(2,4)
]);
}
function radiusToSchedule(radiusAttr) {
let res = [[], [], [], [], [], [], []];
if(radiusAttr.length === 0) {
return res;
}
radiusAttr = radiusAttr.split(',');
for(let period of radiusAttr) {
day = radiusDays.indexOf(period.substr(0, 2));
hours = period.substr(2).split('-');
if(hours.length !== 2) continue;
if(day === -1) {
if(period.substr(0, 2) === 'Wk') {
for (let i = 0; i < 5; ++i) {
addPeriodToArray(res, i, hours);
}
} else if(period.substr(0, 3) === 'Any') {
hours = period.substr(3).split('-');
for (let i = 0; i < 7; ++i) {
addPeriodToArray(res, i, hours);
}
}
} else {
addPeriodToArray(res, day, hours);
}
}
return res;
}
(function ($) {
let schedule = $("#login-time-schedule");
$("#login-time-dialog").dialog({
autoOpen: false,
height: $(window).height() > 650 ? 650 : $(window).height(),
width: $(window).width() > 700 ? 700 : $(window).width(),
modal: true
});
$("#login-time-calendar").click((e) => {
e.preventDefault();
let scheduleArray = radiusToSchedule($("#Login-Time").val());
schedule.data('artsy.dayScheduleSelector').deserialize(scheduleArray);
$("#login-time-dialog").dialog("open");
});
schedule.dayScheduleSelector({
interval: 60,
startTime: '00:00',
endTime: '24:00',
stringDays: ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche']
});
schedule.on('selected.artsy.dayScheduleSelector', function (e, selected) {
let days = schedule.data('artsy.dayScheduleSelector').serialize();
$("#Login-Time").val(scheduleToRadius(days));
});
})($);
Generated by GNU Enscript 1.6.6.