From 0cabcadb25720f28708cd2cd7c566a64a61c6837 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 24 Jun 2016 19:14:30 +0200 Subject: mark today vs. this week diff --git a/www/js/calendar.js b/www/js/calendar.js index afc2369..5df77ac 100644 --- a/www/js/calendar.js +++ b/www/js/calendar.js @@ -28,9 +28,9 @@ function getLastMonday() { d.setUTCHours(12, 0, 0, 0); var dow = d.getUTCDay() if(dow == 0) { - return new Date(d - (6*24*3600000)); + return new Date(d.valueOf() - (6*24*3600000)); } else { - return new Date(d - ((dow-1)*24*3600000)); + return new Date(d.valueOf() - ((dow-1)*24*3600000)); } } @@ -38,9 +38,10 @@ function addDeltaDays(d, days) { return new Date(d.valueOf() + (days*24*3600000)) } -function isThisWeek(d) { - var lastmon = getLastMonday() - return ((d - lastmon) == 0) +function isToday(d) { + var today = new Date(clock.getRDTimeMS()); + today.setUTCHours(12, 0, 0, 0); + return ((d - today) == 0) } function addWeekClass(row, week) { @@ -72,15 +73,13 @@ function calendar_redraw(weekstart) { var week = get_rd_week(date.valueOf() + 7199999); var row = $(''); addWeekClass(row, week); - if(isThisWeek(date)) { - row.append($('').addClass('currentweek').text('*')); - } else { - row.append($('').addClass('currentweek').text('')); - } row.append($('').addClass('week').text(week)); row.append($('').addClass('month').text(monthname_short[date.getUTCMonth()] + ' ' + date.getUTCFullYear())); for(var d = 0; d < 7; d++) { var col = $('').text(date.getUTCDate()); + if(isToday(date)) { + col.addClass('today'); + } row.append(col); if(d < 6) { date = addDeltaDays(date, 1); diff --git a/www/styles/weeks.css b/www/styles/weeks.css index 634da59..fbd0379 100644 --- a/www/styles/weeks.css +++ b/www/styles/weeks.css @@ -93,6 +93,11 @@ border-bottom: 1px solid #eee; } +#calendar td.today { + color: white; + border: 2px solid black; +} + #calendar td.currentweek { font-size: 1.2em; font-weight: bold; diff --git a/www/weeks.html b/www/weeks.html index 53e2dbf..4cba4d2 100644 --- a/www/weeks.html +++ b/www/weeks.html @@ -29,10 +29,10 @@
- +
- - + +
@@ -41,7 +41,6 @@ - Mo Di Mi -- cgit v0.10.2