summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2014-11-27 15:15:22 +0900
committerSean Whitton <spwhitton@spwhitton.name>2014-11-27 15:15:22 +0900
commit7c4b6010d0fe3db251b16ca1d6fd5470ae35bb52 (patch)
tree8fb1ffd242b6f818f3163b7bf49d1e21764d19cb
parentb87df7d90c2e4e151da6e03327e779f9bab3b3e1 (diff)
downloadschoolclock-7c4b6010d0fe3db251b16ca1d6fd5470ae35bb52.tar.gz
store date style in local storage and restore
-rw-r--r--js/main.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/js/main.js b/js/main.js
index 275e700..e9b90a9 100644
--- a/js/main.js
+++ b/js/main.js
@@ -4,6 +4,7 @@
* - rework use of global variables and functions into OO idioms
* - initialise time wasting clock from storage in OO idiom rather
* than just stray function call
+ * - bind a key to toggle the date
*/
$.ionSound({
@@ -136,17 +137,23 @@ function toggleDateStyle()
var British = day + " " + date + nth(date) + " " + month + " " + today.getFullYear();
var American = day + " " + month + " " + date + nth(date) + ", " + today.getFullYear();
- if (currentDate.indexOf(',') > -1)
+ if ($.jStorage.get("date_style", 0) == 0)
{
- $('#date').html(British);
+ $('#date').html(American);
+ $.jStorage.set("date_style", 1);
}
else
{
- $('#date').html(American);
+ $('#date').html(British);
+ $.jStorage.set("date_style", 0);
}
}
// set initial date to British style
+if ($.jStorage.get("date_style", 0) == 0)
+ $.jStorage.set("date_style", 1);
+else
+ $.jStorage.set("date_style", 0);
toggleDateStyle();
$(document).bind('keydown', 's', timeWastingClockReset);