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() {
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>
</body>

4
uhr.js
View File

@ -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');