summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-06-22 16:35:00 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-06-22 16:37:07 (GMT)
commit1c2f67f93e01a4b0f9f2bb690c77821fb6dd9326 (patch)
tree03cdabc7975469857713838fd6bbbeea8f6db185 /www
parentfa44b1f132b05bcc22e7f1a2ba29d0ef36885c58 (diff)
fix date/time offset, add button for 'today'
Diffstat (limited to 'www')
-rw-r--r--www/js/calendar.js35
-rw-r--r--www/js/clock.js6
-rw-r--r--www/styles/week.css15
-rw-r--r--www/weeks.html4
4 files changed, 45 insertions, 15 deletions
diff --git a/www/js/calendar.js b/www/js/calendar.js
index c6b4f61..48ba5ef 100644
--- a/www/js/calendar.js
+++ b/www/js/calendar.js
@@ -21,12 +21,12 @@
'use strict';
-var current_week_offset = -4;
+var current_week_offset = 0;
function getLastMonday() {
- var d = new Date();
- d.setHours(0, 0, 0, 0);
- var dow = d.getDay()
+ var d = new Date(clock.getRDTimeMS());
+ d.setUTCHours(0, 0, 0, 0);
+ var dow = d.getUTCDay()
if(dow == 0) {
return new Date(d - (6*24*3600000));
} else {
@@ -35,7 +35,12 @@ function getLastMonday() {
}
function addDeltaDays(d, days) {
- return new Date(d.valueOf() + (days*24*3600000))
+ return new Date(d.valueOf() + (days*24*3600000))
+}
+
+function isThisWeek(d) {
+ var lastmon = getLastMonday()
+ return ((d - lastmon) == 0)
}
function addWeekClass(row, week) {
@@ -64,28 +69,38 @@ function calendar_redraw(weekstart) {
var date = getLastMonday();
date = addDeltaDays(date, weekstart * 7);
for(var w = 0; w < 20; w++) {
- var week = get_rd_week(date.valueOf());
+ var week = get_rd_week(date.valueOf() + 7199999);
var row = $('<tr>');
addWeekClass(row, week);
-
+ if(isThisWeek(date)) {
+ row.append($('<td>').addClass('currentweek').text('*'));
+ } else {
+ row.append($('<td>').addClass('currentweek').text(''));
+ }
row.append($('<td>').addClass('week').text(week));
- row.append($('<td>').addClass('month').text(monthname_short[date.getMonth()]));
+ row.append($('<td>').addClass('month').text(monthname_short[date.getUTCMonth()] + ' ' + date.getUTCFullYear()));
for(var d = 0; d < 7; d++) {
- var col = $('<td>').text(date.getDate());
+ var col = $('<td>').text(date.getUTCDate());
row.append(col);
if(d < 6) {
date = addDeltaDays(date, 1);
}
}
- row.append($('<td>').addClass('month').text(monthname_short[date.getMonth()]));
+ row.append($('<td>').addClass('month').text(monthname_short[date.getUTCMonth()] + ' ' + date.getUTCFullYear()));
date = addDeltaDays(date, 1);
$('#calendar').append(row);
}
}
function calendar_init() {
+ $('#btn-today').click(calendar_today);
$('#btn-earlier').click(calendar_prev);
$('#btn-later').click(calendar_next);
+ calendar_today()
+}
+
+function calendar_today() {
+ current_week_offset = -4;
calendar_redraw(current_week_offset)
}
diff --git a/www/js/clock.js b/www/js/clock.js
index d62acff..3fa5c24 100644
--- a/www/js/clock.js
+++ b/www/js/clock.js
@@ -29,8 +29,12 @@ function Clock() {
this.clock_rtt = 0;
this.state = 'NEW';
+ this.getRDTimeMS = function() {
+ return (+new Date()) + (this.last_message.tz_offset * 1000) + this.clock_offset;
+ }
+
this.redraw = function() {
- var rdtime_ms = (+new Date()) + (this.last_message.tz_offset * 1000) + this.clock_offset;
+ var rdtime_ms = this.getRDTimeMS()
var rdtime = new Date(rdtime_ms);
var date_str = weekday_short[rdtime.getUTCDay()] + ', ';
diff --git a/www/styles/week.css b/www/styles/week.css
index 211f1ad..5536059 100644
--- a/www/styles/week.css
+++ b/www/styles/week.css
@@ -35,6 +35,7 @@
font-size: 1.3em;
font-weight: bold;
padding: 0.3em 3em;
+ margin: 0.2em;
}
#rightcol {
@@ -57,7 +58,13 @@
font-weight: bold;
text-align: center;
padding: 0.3em;
- border-bottom: 1px solid white;
+ border-bottom: 1px solid #eee;
+}
+
+#calendar td.currentweek {
+ font-size: 1.2em;
+ font-weight: bold;
+ background-color: #eee;
}
#calendar td.week {
@@ -66,9 +73,9 @@
}
#calendar td.month {
- width: 3em;
+ width: 6em;
font-size: 1.2em;
font-weight: bold;
- border-left: 2px solid white;
- border-right: 2px solid white;
+ border-left: 2px solid #eee;
+ border-right: 2px solid #eee;
}
diff --git a/www/weeks.html b/www/weeks.html
index 42c8e29..832e032 100644
--- a/www/weeks.html
+++ b/www/weeks.html
@@ -28,6 +28,9 @@
</div>
<div id="buttons">
+ <div>
+ <input id="btn-today" type="button" value="Heute"></input>
+ </div>
<input id="btn-earlier" type="button" value="Früher"></input>
<input id="btn-later" type="button" value="Später"></input>
</div>
@@ -38,6 +41,7 @@
<tr>
<th></th>
<th></th>
+ <th></th>
<th>Mo</th>
<th>Di</th>
<th>Mi</th>