summaryrefslogtreecommitdiff
path: root/www/js/todo.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/todo.js')
-rw-r--r--www/js/todo.js40
1 files changed, 36 insertions, 4 deletions
diff --git a/www/js/todo.js b/www/js/todo.js
index 88b8aa4..5636be5 100644
--- a/www/js/todo.js
+++ b/www/js/todo.js
@@ -42,10 +42,9 @@ rh.ShowList = function(d) {
rh.ShowList.prototype.fetch = function() {
var self = this;
+ this.current_week = get_rd_week(this.current.valueOf());
- var d = this.current
- var dstr = d.getFullYear() + '-' + Number(d.getMonth() + 1).pad(2) + '-' + Number(d.getDate()).pad(2);
- $.getJSON( "/rh-bin/schedules.json?DAYS=1&START=" + dstr, function(data) {
+ $.getJSON( "/rh-bin/schedules.json?DAYS=1&START=" + format_date_iso(this.current), function(data) {
if(data.status == "OK") {
self.shows = [];
$(data.shows).each(function(index, showdata) {
@@ -57,6 +56,18 @@ rh.ShowList.prototype.fetch = function() {
});
};
+rh.ShowList.prototype.prev = function() {
+ this.current = new Date(this.current.valueOf() - 24*3600*1000);
+ history.replaceState(null, null, '/todo/' + format_date_iso(this.current));
+ this.fetch();
+};
+
+rh.ShowList.prototype.next = function() {
+ this.current = new Date(this.current.valueOf() + 24*3600*1000);
+ history.replaceState(null, null, '/todo/' + format_date_iso(this.current));
+ this.fetch();
+};
+
rh.Show = function(show) {
this.id = show.id;
this.title = show.title;
@@ -139,6 +150,27 @@ rh.ShowView.prototype.render = function() {
/***************** controller *****************/
function todo_init() {
- shows = new rh.ShowList();
+ var url = parseLocationHref();
+ var d = new Date();
+ if(url.path.length > 1) {
+ tmp = new Date(url.path[1]);
+ if((Object.prototype.toString.call(tmp) === '[object Date]') || (tmp.toString() !== 'Invalid Date')) {
+ d = tmp;
+ }
+ }
+ history.pushState(null, null, '/todo/' + format_date_iso(d));
+
+ shows = new rh.ShowList(d);
showListView = new rh.ShowListView(shows);
+
+ $('#btn-earlier').click(todo_prev);
+ $('#btn-later').click(todo_next);
+}
+
+function todo_prev() {
+ shows.prev();
+}
+
+function todo_next() {
+ shows.next();
}