diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2014-11-27 15:15:22 +0900 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2014-11-27 15:15:22 +0900 |
commit | 7c4b6010d0fe3db251b16ca1d6fd5470ae35bb52 (patch) | |
tree | 8fb1ffd242b6f818f3163b7bf49d1e21764d19cb | |
parent | b87df7d90c2e4e151da6e03327e779f9bab3b3e1 (diff) | |
download | schoolclock-7c4b6010d0fe3db251b16ca1d6fd5470ae35bb52.tar.gz |
store date style in local storage and restore
-rw-r--r-- | js/main.js | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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); |