Merge branch 'develop' of /var/lib/git/repositories/manuel/uhr

This commit is contained in:
Manuel Friedli 2013-11-28 13:46:38 +01:00
commit 5d6f88ee98
14 changed files with 212 additions and 165 deletions

View file

@ -20,78 +20,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<script type="text/javascript" src="jquery.cookie.js"></script>
<script type="text/javascript" src="uhr.js"></script>
<link rel="stylesheet" type="text/css" href="uhr.css" />
<link rel="stylesheet" type="text/css" href="uhr-black.css" id="theme" />
<link rel="stylesheet" type="text/css" href="uhr-black.css" />
<link rel="stylesheet" type="text/css" href="uhr-blue.css" />
<link rel="stylesheet" type="text/css" href="uhr-green.css" />
<link rel="stylesheet" type="text/css" href="uhr-red.css" />
<link rel="stylesheet" type="text/css" href="uhr-white.css" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<div id="uhr">
<span class="item dot dot1" id="dot1"></span>
<span class="item dot dot2" id="dot2"></span>
<span class="item dot dot3" id="dot3"></span>
<span class="item dot dot4" id="dot4"></span>
<div id="renderarea"></div>
<!-- glossy reflection -->
<span id="reflection"></span>
</div>
<select id="themeswitcher">
<option value="black">Schwarz</option>
<option value="red">Rot</option>
<option value="blue">Blau</option>
<option value="green">Grün</option>
<option value="white">Weiss</option>
</select>
<select id="layoutswitcher">
<option value="de_CH">Bärndütsch</option>
<option value="de">Hochdeutsch</option>
<option value="en">English</option>
</select>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="onoffswitch" checked="checked" onclick="uhr.toggle()" />
<label class="onoffswitch-label" for="onoffswitch">
<div class="onoffswitch-inner"></div>
<div class="onoffswitch-switch"></div>
</label>
</div>
<div id="uhr" class="uhr"></div>
<p id="disclaimer">Created by fritteli, inspired by <a href="http://www.qlocktwo.com/">QLOCKTWO</a>.
<script type="text/javascript">
var uhr = new Uhr($('#renderarea'), $('#theme'));
$(document).ready(function() {
$('#themeswitcher').on('change', function() {
uhr.setTheme(this.value);
});
$('#layoutswitcher').on('change', function() {
uhr.setLayout(this.value);
});
$.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);
uhr.setTheme(theme);
$('#layoutswitcher').val(layout);
uhr.setLayout(layout);
if (status == 'on') {
uhr.start();
$('#onoffswitch').prop('checked', true);
} else {
uhr.stop();
$('#onoffswitch').prop('checked', false);
}
});
</script>
<script type="text/javascript" src="uhr-de_CH.js"></script>
<script type="text/javascript" src="uhr-de.js"></script>
<script type="text/javascript" src="uhr-en.js"></script>
<script type="text/javascript">
new Uhr($('#uhr'), {
layout: 'de_CH',
theme: 'black',
status: 'on'
});
</script>
</body>
</html>

View file

@ -1,5 +1,5 @@
CACHE MANIFEST
# 2.3.1
# 3.0.2
COPYING
index.html

View file

@ -12,10 +12,17 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@import url("uhr-idle-light.css");
#uhr {
.uhr.black {
background-color: #111;
}
.onoffswitch-inner:before {
.black .onoffswitch-inner:before {
background-color: #111;
}
.uhr.black .dot:not(.active) {
border-color: rgba(255,255,255,0.1);
box-shadow: 0 0 0.1em rgba(255,255,255,0.1);
}
.uhr.black .letter:not(.active) {
color: rgba(255,255,255,0.1);
text-shadow: 0 0 0.1em rgba(255,255,255,0.1);
}

View file

@ -12,10 +12,17 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@import url("uhr-idle-light.css");
#uhr {
.uhr.blue {
background-color: #00a;
}
.onoffswitch-inner:before {
.blue .onoffswitch-inner:before {
background-color: #00a;
}
.uhr.blue .dot:not(.active) {
border-color: rgba(255,255,255,0.1);
box-shadow: 0 0 0.1em rgba(255,255,255,0.1);
}
.uhr.blue .letter:not(.active) {
color: rgba(255,255,255,0.1);
text-shadow: 0 0 0.1em rgba(255,255,255,0.1);
}

View file

@ -27,4 +27,4 @@ var layout = {
[h('Z', 10), h('E', 10),h('H', 10),h('N', 9, 10),h('E', 9),h('U', 9),h('N', 9),l('K'),l('U'),l('H'),l('R')]
]
};
uhr.register('de', layout);
Uhr.register('de', layout);

View file

@ -27,4 +27,4 @@ var layout = {
[h('Z', 12), h('W', 12),h('Ö', 12),h('U', 12),h('F', 12),h('I', 12),l('N'),l('A'),l('U'),l('H'),l('R')]
]
};
uhr.register('de_CH', layout);
Uhr.register('de_CH', layout);

View file

@ -34,4 +34,4 @@ var layout = {
return hour;
}
};
uhr.register('en', layout);
Uhr.register('en', layout);

View file

@ -12,10 +12,17 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@import url("uhr-idle-dark.css");
#uhr {
.uhr.green {
background-color: #0c0;
}
.onoffswitch-inner:before {
.green .onoffswitch-inner:before {
background-color: #0c0;
}
.uhr.green .dot:not(.active) {
border-color: rgba(0,0,0,0.1);
box-shadow: 0 0 0.1em rgba(0,0,0,0.1);
}
.uhr.green .letter:not(.active) {
color: rgba(0,0,0,0.1);
text-shadow: 0 0 0.1em rgba(0,0,0,0.1);
}

View file

@ -1,22 +0,0 @@
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
.dot {
border-color: rgba(0,0,0,0.1);
box-shadow: 0 0 0.1em rgba(0,0,0,0.1);
}
.letter {
color: rgba(0,0,0,0.1);
text-shadow: 0 0 0.1em rgba(0,0,0,0.1);
}

View file

@ -1,22 +0,0 @@
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
.dot {
border-color: rgba(255,255,255,0.1);
box-shadow: 0 0 0.1em rgba(255,255,255,0.1);
}
.letter {
color: rgba(255,255,255,0.1);
text-shadow: 0 0 0.1em rgba(255,255,255,0.1);
}

View file

@ -12,10 +12,17 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@import url("uhr-idle-light.css");
#uhr {
.uhr.red {
background-color: #700;
}
.onoffswitch-inner:before {
.red .onoffswitch-inner:before {
background-color: #700;
}
.uhr.red .dot:not(.active){
border-color: rgba(255,255,255,0.1);
box-shadow: 0 0 0.1em rgba(255,255,255,0.1);
}
.uhr.red .letter:not(.active) {
color: rgba(255,255,255,0.1);
text-shadow: 0 0 0.1em rgba(255,255,255,0.1);
}

View file

@ -12,18 +12,25 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@import url("uhr-idle-dark.css");
#uhr {
.uhr.white {
background-color: #ccc;
}
.dot.active{
border-color: #fff !important;
box-shadow: 0 0 0.1em #fff !important;
.uhr.white .dot.active{
border-color: #fff;
box-shadow: 0 0 0.1em #fff;
}
.letter.active{
color: #fff !important;
text-shadow: 0 0 0.1em #fff !important;
.uhr.white .letter.active{
color: #fff;
text-shadow: 0 0 0.1em #fff;
}
.onoffswitch-inner:before {
.white .onoffswitch-inner:before {
background-color: #ccc;
}
.uhr.white .dot:not(.active) {
border-color: rgba(0,0,0,0.1);
box-shadow: 0 0 0.1em rgba(0,0,0,0.1);
}
.uhr.white .letter:not(.active) {
color: rgba(0,0,0,0.1);
text-shadow: 0 0 0.1em rgba(0,0,0,0.1);
}

14
uhr.css
View file

@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
body {
font-family: 'Uhrenfont', sans-serif;
}
#uhr {
.uhr {
padding: 3em;
position: relative;
margin: 0;
@ -27,7 +27,7 @@ body {
height: 40em;
transition: background-color 0.5s;
}
#reflection {
.uhr .reflection {
position: absolute;
top: 0;
bottom: 0;
@ -39,7 +39,7 @@ body {
}
#themeswitcher {
}
#renderarea {
.uhr .letterarea {
display: block;
position: absolute;
top: 5em;
@ -63,19 +63,19 @@ body {
border-color: #eee;
box-shadow: 0 0 0.2em #eee;
}
#dot1 {
.dot1 {
top: 1.5em;
left: 1.5em;
}
#dot2 {
.dot2 {
top: 1.5em;
right: 1.5em;
}
#dot3 {
.dot3 {
bottom: 1.5em;
right: 1.5em;
}
#dot4 {
.dot4 {
bottom: 1.5em;
left: 1.5em;
}

155
uhr.js
View file

@ -14,23 +14,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Die Uhr.
* @param renderarea Das jQuery-gewrappte HTML-Element, auf dem die Uhr angezeigt werden soll.
* @param clockarea Das jQuery-gewrappte HTML-Element, auf dem die Uhr angezeigt werden soll.
* @param themeElement Das HTML-Stylesheet-Tag, das das Theme-CSS referenziert.
*/
function Uhr(renderarea, themeElement) {
this.renderarea = renderarea;
this.themeElement = themeElement;
function Uhr(clockarea, settings) {
this.id = Uhr.id++;
this.timer = null;
this.currentTheme = null;
this.currentLayout = null;
this.layouts = new Array();
this.currentLayout = Uhr.layouts['undefined'];
this.currentMinute = -1;
this.register('undefined', {
language: 'Undefined',
values: []
});
this.initHTMLElements(clockarea, settings || {});
}
Uhr.id = 0;
Uhr.layouts = new Array();
Uhr.register = function (locale, layout) {
Uhr.layouts[locale] = layout;
}
Uhr.prototype.toggle = function() {
if (this.isOn()) {
this.stop();
@ -43,7 +42,7 @@ Uhr.prototype.start = function() {
var uhr = this;
this.timer = window.setInterval(function() {uhr.update();}, 1000);
this.update();
$.cookie('status', 'on');
$.cookie('status' + this.id, 'on', {expires: 365, path: '/'});
}
}
Uhr.prototype.stop = function() {
@ -51,29 +50,29 @@ Uhr.prototype.stop = function() {
window.clearInterval(this.timer);
this.timer = null;
this.update();
$.cookie('status', 'off');
$.cookie('status' + this.id, 'off', {expires: 365, path: '/'});
}
}
Uhr.prototype.isOn = function() {
return this.timer != null;
}
Uhr.prototype.register = function(key, layout) {
this.layouts[key] = layout;
}
Uhr.prototype.setLayout = function(locale) {
var newLayout = this.layouts[locale];
var newLayout = Uhr.layouts[locale];
if (newLayout !== undefined && newLayout != this.currentLayout) {
this.currentLayout = newLayout;
var renderer = new UhrRenderer(this.currentLayout, this.renderarea);
var renderer = new UhrRenderer(this.currentLayout, this.letterarea);
renderer.render(this);
$.cookie('layout', locale);
$.cookie('layout' + this.id, locale, {expires: 365, path: '/'});
}
}
Uhr.prototype.setTheme = function(theme) {
if (theme != this.currentTheme) {
this.clockarea.removeClass(this.currentTheme);
this.toggleSwitch.removeClass(this.currentTheme);
this.clockarea.addClass(theme);
this.toggleSwitch.addClass(theme);
this.currentTheme = theme;
this.themeElement.attr('href', 'uhr-' + theme + '.css');
$.cookie('theme', theme);
$.cookie('theme' + this.id, theme, {expires: 365, path: '/'});
}
}
Uhr.prototype.update = function() {
@ -103,10 +102,10 @@ Uhr.prototype.update = function() {
}
}
Uhr.prototype.clear = function() {
this.renderarea.parent().find('.item').removeClass('active');
this.clockarea.find('.item').removeClass('active');
}
Uhr.prototype.highlight = function(itemClass) {
this.renderarea.parent().find('.item.' + itemClass).addClass('active');
this.clockarea.find('.item.' + itemClass).addClass('active');
}
Uhr.prototype.getHour = function(date) {
if (typeof this.currentLayout.getHour === 'function') {
@ -141,6 +140,116 @@ Uhr.prototype.normalizeHour = function(hour) {
}
return hour;
}
Uhr.prototype.initHTMLElements = function(clockarea, presets) {
this.createHTMLElements(clockarea);
var force = presets.force || false;
this.initToggleSwitch(presets.status, force);
this.initLayoutSwitch(presets.layout, force);
this.initThemeSwitch(presets.theme, force);
}
Uhr.prototype.createHTMLElements = function(clockarea) {
this.createClockarea(clockarea)
this.letterarea = this.clockarea.find('.letterarea');
this.createToggleSwitch();
this.createLayoutSwitch();
this.createThemeSwitch();
}
Uhr.prototype.createClockarea = function(clockarea) {
clockarea.empty();
clockarea.append('<span class="item dot dot1"></span>');
clockarea.append('<span class="item dot dot2"></span>');
clockarea.append('<span class="item dot dot3"></span>');
clockarea.append('<span class="item dot dot4"></span>');
clockarea.append('<div class="letterarea"></div>');
clockarea.append('<div class="reflection"></div>');
this.clockarea = clockarea
}
Uhr.prototype.createToggleSwitch = function() {
this.toggleSwitch = $('<div class="onoffswitch"></div>');
var input = $('<input type="checkbox" name="onoffswitch' + this.id + '" class="onoffswitch-checkbox" id="onoffswitch' + this.id + '" checked="checked" />');
this.toggleSwitch.append(input);
this.toggleSwitch.append('<label class="onoffswitch-label" for="onoffswitch' + this.id + '">'
+ '<div class="onoffswitch-inner"></div>'
+ '<div class="onoffswitch-switch"></div>'
+ '</label>');
this.clockarea.after(this.toggleSwitch);
}
Uhr.prototype.createLayoutSwitch = function () {
this.layoutSwitch = $('<select></select>')
for (var code in Uhr.layouts) {
if (Uhr.layouts.hasOwnProperty(code)) {
var layout = Uhr.layouts[code];
var option = $('<option value="' + code + '">' + layout.language + '</option>')
this.layoutSwitch.append(option);
}
}
this.clockarea.after(this.layoutSwitch);
}
Uhr.prototype.createThemeSwitch = function () {
this.themeSwitch = $('<select></select>');
this.themeSwitch.append('<option value="black">Schwarz</option>');
this.themeSwitch.append('<option value="red">Rot</option>');
this.themeSwitch.append('<option value="blue">Blau</option>');
this.themeSwitch.append('<option value="green">Grün</option>');
this.themeSwitch.append('<option value="white">Weiss</option>');
this.clockarea.after(this.themeSwitch);
}
Uhr.prototype.initToggleSwitch = function(defaultValue, overrideCookie) {
var input = $('#onoffswitch' + this.id);
var uhr = this;
input.on('click', function() {
uhr.toggle();
});
var status = $.cookie('status' + this.id);
if (status == undefined || (overrideCookie && (defaultValue != undefined))) {
status = defaultValue;
}
if (status == undefined || status == 'undefined') {
status = 'on';
}
if (status == 'on') {
this.start();
input.prop('checked', true);
} else {
this.stop();
input.prop('checked', false);
}
}
Uhr.prototype.initLayoutSwitch = function(defaultValue, overrideCookie) {
var uhr = this;
this.layoutSwitch.on('change', function() {
uhr.setLayout(this.value);
});
var selectedLayout = $.cookie('layout' + this.id);
if (selectedLayout == undefined || (overrideCookie && (defaultValue != undefined))) {
selectedLayout = defaultValue;
}
if (selectedLayout == undefined || selectedLayout == 'undefined') {
selectedLayout = 'de_CH';
}
this.layoutSwitch.val(selectedLayout);
this.setLayout(selectedLayout);
}
Uhr.prototype.initThemeSwitch = function(defaultValue, overrideCookie) {
var uhr = this;
this.themeSwitch.on('change', function() {
uhr.setTheme(this.value);
});
var selectedTheme = $.cookie('theme' + this.id);
if (selectedTheme == undefined || (overrideCookie && (defaultValue != undefined))) {
selectedTheme = defaultValue;
}
if (selectedTheme == undefined || selectedTheme == 'undefined') {
selectedTheme = 'black';
}
this.themeSwitch.val(selectedTheme);
this.setTheme(selectedTheme);
}
Uhr.register('undefined', {
language: 'Please choose your language',
values: []
});
/**
* Hilfsklasse zum Rendern der Uhr.