cookies eingebaut

This commit is contained in:
Manuel Friedli 2013-11-25 14:38:25 +01:00
parent f229a7968d
commit e95affcb60
2 changed files with 31 additions and 1 deletions

View file

@ -50,7 +50,33 @@
$('#layoutswitcher').on('change', function() { $('#layoutswitcher').on('change', function() {
switchLayout(this.value); 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();
}
}
}); });
</script> </script>
</body> </body>

4
uhr.js
View file

@ -75,6 +75,7 @@ function startClock() {
highlightCurrentTime(); highlightCurrentTime();
clock = window.setInterval(highlightCurrentTime, 1000); clock = window.setInterval(highlightCurrentTime, 1000);
} }
$.cookie('status', 'on');
} }
function stopClock() { function stopClock() {
if (clock != null) { if (clock != null) {
@ -83,6 +84,7 @@ function stopClock() {
currentMinute = -1; currentMinute = -1;
clearDisplay(); clearDisplay();
} }
$.cookie('status', 'off');
} }
function updateClockState() { function updateClockState() {
if (isOn()) { if (isOn()) {
@ -96,6 +98,7 @@ function isOn() {
} }
function switchTheme(theme) { function switchTheme(theme) {
$('#theme').attr('href', 'uhr-' + theme + '.css'); $('#theme').attr('href', 'uhr-' + theme + '.css');
$.cookie('theme', theme);
} }
function switchLayout(locale) { function switchLayout(locale) {
stopClock(); stopClock();
@ -107,6 +110,7 @@ function switchLayout(locale) {
if (isOn()) { if (isOn()) {
startClock(); startClock();
} }
$.cookie('layout', locale);
} }
function renderLayout() { function renderLayout() {
var container = $('#renderarea'); var container = $('#renderarea');