1
0
forked from ScoDoc/ScoDoc
ScoDoc/app/static/js/calabs.js

63 lines
1.5 KiB
JavaScript
Raw Normal View History

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)
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() {
for (var i = 0; i < HIGHLIGHTEDCELLS.length; i++) {
2020-09-26 16:19:37 +02:00
var row = rows[i];
if (row) {
if (row.className.match("currentweek")) {
row.style.backgroundColor = CURRENTWEEKCOLOR;
2020-09-26 16:19:37 +02:00
} else {
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;
if (week == "wkend" || week.substring(0, 2) != "wk") {
2020-09-26 16:19:37 +02:00
return; /* does not hightlight weekends */
}
rows = getTRweek(week);
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;
form = document.getElementById("formw");
form.datelundi.value = monday.substr(2).replace(/_/g, "/").split(" ")[0];
2020-09-26 16:19:37 +02:00
form.submit();
}