From 7c4b6010d0fe3db251b16ca1d6fd5470ae35bb52 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 27 Nov 2014 15:15:22 +0900 Subject: store date style in local storage and restore --- js/main.js | 13 ++++++++++--- 1 file 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); -- cgit v1.2.3