From e95affcb6047504e72c58c43214f47f56a6aaf4f Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 25 Nov 2013 14:38:25 +0100 Subject: [PATCH] cookies eingebaut --- index.html | 28 +++++++++++++++++++++++++++- uhr.js | 4 ++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 847b42a..c011fb9 100644 --- a/index.html +++ b/index.html @@ -50,7 +50,33 @@ $('#layoutswitcher').on('change', function() { switchLayout(this.value); }); - switchLayout('de_CH'); + $.cookie.defaults.expires = 365; + $.cookie.defaults.path = '/'; + var theme = $.cookie('theme'); + var layout = $.cookie('layout'); + var status = $.cookie('status'); + if (theme == undefined) { + theme = 'black'; + } + if(layout == undefined) { + layout = 'de_CH'; + } + if (status == undefined) { + status = 'on'; + } + $('#themeswitcher').val(theme); + switchTheme(theme); + $('#layoutswitcher').val(layout); + switchLayout(layout); + if (status == 'on') { + if(!isOn()) { + $('#onoffswitch').click(); + } + } else { + if(isOn()) { + $('#onoffswitch').click(); + } + } }); diff --git a/uhr.js b/uhr.js index 4aec6ac..8747842 100644 --- a/uhr.js +++ b/uhr.js @@ -75,6 +75,7 @@ function startClock() { highlightCurrentTime(); clock = window.setInterval(highlightCurrentTime, 1000); } + $.cookie('status', 'on'); } function stopClock() { if (clock != null) { @@ -83,6 +84,7 @@ function stopClock() { currentMinute = -1; clearDisplay(); } + $.cookie('status', 'off'); } function updateClockState() { if (isOn()) { @@ -96,6 +98,7 @@ function isOn() { } function switchTheme(theme) { $('#theme').attr('href', 'uhr-' + theme + '.css'); + $.cookie('theme', theme); } function switchLayout(locale) { stopClock(); @@ -107,6 +110,7 @@ function switchLayout(locale) { if (isOn()) { startClock(); } + $.cookie('layout', locale); } function renderLayout() { var container = $('#renderarea');