2020-09-26 16:19:37 +02:00
|
|
|
/* -*- mode: javascript -*-
|
|
|
|
*
|
|
|
|
* Selection semaine sur calendrier Absences
|
|
|
|
*
|
|
|
|
* E. Viennet, Oct 2006
|
|
|
|
*/
|
|
|
|
|
|
|
|
var WEEKDAYCOLOR = "#EEEEEE";
|
|
|
|
var WEEKENDCOLOR = "#99CC99";
|
|
|
|
var DAYHIGHLIGHT = "red";
|
|
|
|
var CURRENTWEEKCOLOR = "yellow";
|
|
|
|
|
|
|
|
// get all tr elements from this class
|
|
|
|
// (no getElementBuClassName)
|
2023-11-17 13:53:17 +01:00
|
|
|
function getTRweek(week) {
|
|
|
|
var tablecal = document.getElementById("maincalendar");
|
|
|
|
var all = tablecal.getElementsByTagName("tr");
|
|
|
|
var res = [];
|
|
|
|
for (var i = 0; i < all.length; i++) {
|
|
|
|
if (all[i].className == week) res[res.length] = all[i];
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
var HIGHLIGHTEDCELLS = [];
|
|
|
|
|
|
|
|
function deselectweeks() {
|
2023-11-17 13:53:17 +01:00
|
|
|
for (var i = 0; i < HIGHLIGHTEDCELLS.length; i++) {
|
2020-09-26 16:19:37 +02:00
|
|
|
var row = rows[i];
|
|
|
|
if (row) {
|
2023-11-17 13:53:17 +01:00
|
|
|
if (row.className.match("currentweek")) {
|
|
|
|
row.style.backgroundColor = CURRENTWEEKCOLOR;
|
2020-09-26 16:19:37 +02:00
|
|
|
} else {
|
2023-11-17 13:53:17 +01:00
|
|
|
row.style.backgroundColor = WEEKDAYCOLOR;
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
rows[i] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// highlight 5 days
|
|
|
|
function highlightweek(el) {
|
|
|
|
deselectweeks();
|
|
|
|
var week = el.className;
|
2023-11-17 13:53:17 +01:00
|
|
|
if (week == "wkend" || week.substring(0, 2) != "wk") {
|
2020-09-26 16:19:37 +02:00
|
|
|
return; /* does not hightlight weekends */
|
|
|
|
}
|
|
|
|
rows = getTRweek(week);
|
2023-11-17 13:53:17 +01:00
|
|
|
for (var i = 0; i < rows.length; i++) {
|
2020-09-26 16:19:37 +02:00
|
|
|
var row = rows[i];
|
|
|
|
row.style.backgroundColor = DAYHIGHLIGHT;
|
|
|
|
HIGHLIGHTEDCELLS[HIGHLIGHTEDCELLS.length] = row;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// click on a day
|
|
|
|
function wclick(el) {
|
|
|
|
monday = el.className;
|
2023-11-17 13:53:17 +01:00
|
|
|
form = document.getElementById("formw");
|
|
|
|
form.datelundi.value = monday.substr(2).replace(/_/g, "/").split(" ")[0];
|
2020-09-26 16:19:37 +02:00
|
|
|
form.submit();
|
|
|
|
}
|