summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/calendar.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/www/js/calendar.js b/www/js/calendar.js
index 8bdf033..c6b4f61 100644
--- a/www/js/calendar.js
+++ b/www/js/calendar.js
@@ -21,6 +21,8 @@
'use strict';
+var current_week_offset = -4;
+
function getLastMonday() {
var d = new Date();
d.setHours(0, 0, 0, 0);
@@ -55,13 +57,13 @@ function addWeekClass(row, week) {
}
}
-function calendar_redraw() {
+function calendar_redraw(weekstart) {
var cal = $('#calendar');
cal.find("tr:gt(0)").remove();
var date = getLastMonday();
- date = addDeltaDays(date, -28);
- for(var w = 0; w < 42; w++) {
+ date = addDeltaDays(date, weekstart * 7);
+ for(var w = 0; w < 20; w++) {
var week = get_rd_week(date.valueOf());
var row = $('<tr>');
addWeekClass(row, week);
@@ -82,5 +84,17 @@ function calendar_redraw() {
}
function calendar_init() {
- calendar_redraw()
+ $('#btn-earlier').click(calendar_prev);
+ $('#btn-later').click(calendar_next);
+ calendar_redraw(current_week_offset)
+}
+
+function calendar_prev() {
+ current_week_offset--;
+ calendar_redraw(current_week_offset)
+}
+
+function calendar_next() {
+ current_week_offset++;
+ calendar_redraw(current_week_offset)
}