summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--www/js/calendar.js86
-rw-r--r--www/js/utils.js16
-rw-r--r--www/styles/week.css50
-rw-r--r--www/weeks.html49
4 files changed, 201 insertions, 0 deletions
diff --git a/www/js/calendar.js b/www/js/calendar.js
new file mode 100644
index 0000000..8bdf033
--- /dev/null
+++ b/www/js/calendar.js
@@ -0,0 +1,86 @@
+/*
+ * rhrdweb
+ *
+ * Copyright (C) 2016 Christian Pointner <equinox@helsinki.at>
+ *
+ * This file is part of rhrdweb.
+ *
+ * rhrdweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * rhrdweb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with rhrdweb. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
+function getLastMonday() {
+ var d = new Date();
+ d.setHours(0, 0, 0, 0);
+ var dow = d.getDay()
+ if(dow == 0) {
+ return new Date(d - (6*24*3600000));
+ } else {
+ return new Date(d - ((dow-1)*24*3600000));
+ }
+}
+
+function addDeltaDays(d, days) {
+ return new Date(d.valueOf() + (days*24*3600000))
+}
+
+function addWeekClass(row, week) {
+ switch(week) {
+ case 1:
+ row.addClass('label-info');
+ break;
+ case 2:
+ row.addClass('label-warning');
+ break;
+ case 3:
+ row.addClass('label-success');
+ break;
+ case 4:
+ row.addClass('label-danger');
+ break;
+ default:
+ row.addClass('label-default');
+ }
+}
+
+function calendar_redraw() {
+ var cal = $('#calendar');
+ cal.find("tr:gt(0)").remove();
+
+ var date = getLastMonday();
+ date = addDeltaDays(date, -28);
+ for(var w = 0; w < 42; w++) {
+ var week = get_rd_week(date.valueOf());
+ var row = $('<tr>');
+ addWeekClass(row, week);
+
+ row.append($('<td>').addClass('week').text(week));
+ row.append($('<td>').addClass('month').text(monthname_short[date.getMonth()]));
+ for(var d = 0; d < 7; d++) {
+ var col = $('<td>').text(date.getDate());
+ row.append(col);
+ if(d < 6) {
+ date = addDeltaDays(date, 1);
+ }
+ }
+ row.append($('<td>').addClass('month').text(monthname_short[date.getMonth()]));
+ date = addDeltaDays(date, 1);
+ $('#calendar').append(row);
+ }
+}
+
+function calendar_init() {
+ calendar_redraw()
+}
diff --git a/www/js/utils.js b/www/js/utils.js
index ba40863..a7fef1b 100644
--- a/www/js/utils.js
+++ b/www/js/utils.js
@@ -38,6 +38,22 @@ weekday[6] = 'Samstag';
var weekday_short = new Array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa');
+var monthname = new Array(7);
+monthname[0] = 'Jänner';
+monthname[1] = 'Februar';
+monthname[2] = 'März';
+monthname[3] = 'April';
+monthname[4] = 'Mai';
+monthname[5] = 'Juni';
+monthname[6] = 'Juli';
+monthname[7] = 'August';
+monthname[8] = 'September';
+monthname[9] = 'Oktober';
+monthname[10] = 'November';
+monthname[11] = 'Dezember';
+
+var monthname_short = new Array('Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez');
+
function format_datetime(d) {
if(Object.prototype.toString.call(d) !== '[object Date]') {
return '-';
diff --git a/www/styles/week.css b/www/styles/week.css
new file mode 100644
index 0000000..5ff75cd
--- /dev/null
+++ b/www/styles/week.css
@@ -0,0 +1,50 @@
+/*
+ * rhrdweb
+ *
+ * Copyright (C) 2016 Christian Pointner <equinox@helsinki.at>
+ *
+ * This file is part of rhrdweb.
+ *
+ * rhrdweb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * rhrdweb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with rhrdweb. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#calendar {
+ border-collapse: collapse;
+}
+
+#calendar th {
+ font-size: 1.2em;
+}
+
+#calendar td {
+ width: 2em;
+ font-weight: bold;
+ text-align: center;
+ padding: 0.3em;
+ border-bottom: 1px solid white;
+}
+
+#calendar td.week {
+ font-size: 1.2em;
+ font-weight: bold;
+}
+
+#calendar td.month {
+ width: 3em;
+ font-size: 1.2em;
+ font-weight: bold;
+ border-left: 2px solid white;
+ border-right: 2px solid white;
+}
+
diff --git a/www/weeks.html b/www/weeks.html
new file mode 100644
index 0000000..13ee0e5
--- /dev/null
+++ b/www/weeks.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Radio Helsinki - Automation Week Plan</title>
+ <meta charset="utf-8">
+ <meta name="author" content="Christian Pointner <equinox@helsinki.at>">
+
+ <link rel="shortcut icon" href="/img/favicon.ico" />
+ <link href="/styles/main.css" rel="stylesheet">
+ <link href="/styles/week.css" rel="stylesheet">
+ <script src="/javascript/jquery/jquery.min.js"></script>
+ <script src="/js/utils.js"></script>
+ <script src="/js/clock.js"></script>
+ <script src="/js/calendar.js"></script>
+ </head>
+ <body>
+ <div id="container">
+ <div id="clock">
+ <span class="current-week"></span>
+ <span class="clock-date"></span>
+ <span class="clock-time"></span>
+ </div>
+
+ </div>
+
+ <div id="weeks">
+ <table id="calendar">
+ <tr>
+ <th></th>
+ <th></th>
+ <th>Mo</th>
+ <th>Di</th>
+ <th>Mi</th>
+ <th>Do</th>
+ <th>Fr</th>
+ <th>Sa</th>
+ <th>So</th>
+ <th></th>
+ </tr>
+ </table>
+ </div>
+
+ <script type="text/javascript">
+ <!-- clock_init(); -->
+ calendar_init();
+ </script>
+
+ </body>
+</html>