wechsel des layouts ist nun möglich

This commit is contained in:
Manuel Friedli 2013-11-25 13:25:02 +01:00
parent 5b051230c9
commit 57365c23e6
5 changed files with 52 additions and 30 deletions

View file

@ -5,6 +5,7 @@
<script type="text/javascript" src="jquery-2.0.3.min.js"></script> <script type="text/javascript" src="jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="uhr.js"></script> <script type="text/javascript" src="uhr.js"></script>
<script type="text/javascript" src="uhr-de_CH.js"></script> <script type="text/javascript" src="uhr-de_CH.js"></script>
<script type="text/javascript" src="uhr-de.js"></script>
<link rel="stylesheet" type="text/css" href="uhr.css" /> <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" id="theme" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
@ -19,13 +20,17 @@
<!-- glossy reflection --> <!-- glossy reflection -->
<span id="reflection"></span> <span id="reflection"></span>
</div> </div>
<div id="themeswitcher"> <select id="themeswitcher">
<input type="radio" name="theme" id="theme-black" value="black" checked="checked" /><label for="theme-black">BLACK</label> <option value="black">Schwarz</option>
<input type="radio" name="theme" id="theme-red" value="red" /><label for="theme-red">RED</label> <option value="red">Rot</option>
<input type="radio" name="theme" id="theme-blue" value="blue" /><label for="theme-blue">BLUE</label> <option value="blue">Blau</option>
<input type="radio" name="theme" id="theme-green" value="green" /><label for="theme-green">GREEN</label> <option value="green">Grün</option>
<input type="radio" name="theme" id="theme-white" value="white" /><label for="theme-white">WHITE</label> <option value="white">Weiss</option>
</div> </select>
<select id="layoutswitcher">
<option value="de_CH">Bärndütsch</option>
<option value="de">Hochdeutsch</option>
</select>
<div class="onoffswitch"> <div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="onoffswitch" checked="checked" onclick="updateClockState()" /> <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="onoffswitch" checked="checked" onclick="updateClockState()" />
<label class="onoffswitch-label" for="onoffswitch"> <label class="onoffswitch-label" for="onoffswitch">
@ -36,10 +41,14 @@
<p id="disclaimer">Created by fritteli, inspired by <a href="http://www.qlocktwo.com/">QLOCKTWO</a>. <p id="disclaimer">Created by fritteli, inspired by <a href="http://www.qlocktwo.com/">QLOCKTWO</a>.
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
render(layout); $('#themeswitcher').on('change', function() {
$('input[name=theme]').on('click', function() { switchTheme(this.value);
switchTheme(this);
}); });
$('#layoutswitcher').on('change', function() {
switchLayout(this.value);
});
currentLayout = layout['de_CH'];
renderLayout();
startClock(); startClock();
}); });
</script> </script>

View file

@ -1,6 +1,5 @@
layout = { layout['de'] = {
language: "Deutsch", language: "Deutsch",
locale: "de",
values: [ values: [
[l('E', 'on'), l('S', 'on'),l('K'),l('I', 'on'),l('S', 'on'),l('T', 'on'),l('A'),m('F', 5, 25, 35, 55),m('Ü', 5, 25, 35, 55),m('N', 5, 25, 35, 55),m('F', 5, 25, 35, 55)], [l('E', 'on'), l('S', 'on'),l('K'),l('I', 'on'),l('S', 'on'),l('T', 'on'),l('A'),m('F', 5, 25, 35, 55),m('Ü', 5, 25, 35, 55),m('N', 5, 25, 35, 55),m('F', 5, 25, 35, 55)],
[m('Z', 10, 50), m('E', 10, 50),m('H', 10, 50),m('N', 10, 50),m('Z', 20, 40),m('W', 20, 40),m('A', 20, 40),m('N', 20, 40),m('Z', 20, 40),m('I', 20, 40),m('G', 20, 40)], [m('Z', 10, 50), m('E', 10, 50),m('H', 10, 50),m('N', 10, 50),m('Z', 20, 40),m('W', 20, 40),m('A', 20, 40),m('N', 20, 40),m('Z', 20, 40),m('I', 20, 40),m('G', 20, 40)],

View file

@ -1,6 +1,5 @@
var layout = { layout['de_CH'] = {
language: "Bärndütsch", language: "Bärndütsch",
locale: "de_CH",
values: [ values: [
[l('E', 'on'), l('S', 'on'),l('K'),l('I', 'on'),l('S', 'on'),l('C', 'on'),l('H', 'on'),l('A'),m('F', 5, 25, 35, 55),m('Ü', 5, 25, 35, 55),m('F', 5, 25, 35, 55)], [l('E', 'on'), l('S', 'on'),l('K'),l('I', 'on'),l('S', 'on'),l('C', 'on'),l('H', 'on'),l('A'),m('F', 5, 25, 35, 55),m('Ü', 5, 25, 35, 55),m('F', 5, 25, 35, 55)],
[m('V', 15, 45), m('I', 15, 45),m('E', 15, 45),m('R', 15, 45),m('T', 15, 45),m('U', 15, 45),l('B'),l('F'),m('Z', 10, 50),m('Ä', 10, 50),m('Ä', 10, 50)], [m('V', 15, 45), m('I', 15, 45),m('E', 15, 45),m('R', 15, 45),m('T', 15, 45),m('U', 15, 45),l('B'),l('F'),m('Z', 10, 50),m('Ä', 10, 50),m('Ä', 10, 50)],

View file

@ -6,7 +6,6 @@ body {
font-family: 'Uhrenfont', sans-serif; font-family: 'Uhrenfont', sans-serif;
} }
#uhr { #uhr {
display: inline-block;
padding: 3em; padding: 3em;
position: relative; position: relative;
margin: 0; margin: 0;

46
uhr.js
View file

@ -1,6 +1,11 @@
var clock = null; var clock = null;
var currentMinute = -1; var currentMinute = -1;
var layout = layout || {}; var layout = new Array();
layout['default'] = {
language: 'Undefined',
values: []
};
var currentLayout = layout['default'];
function highlightCurrentTime() { function highlightCurrentTime() {
var now = new Date(); var now = new Date();
@ -20,8 +25,8 @@ function highlightCurrentTime() {
highlight('hour' + hour); highlight('hour' + hour);
} }
function getHour(date) { function getHour(date) {
if (typeof layout.getHour === 'function') { if (typeof currentLayout.getHour === 'function') {
return layout.getHour(date); return currentLayout.getHour(date);
} }
var hour = date.getHours(); var hour = date.getHours();
if (date.getMinutes() >= 25) { if (date.getMinutes() >= 25) {
@ -30,15 +35,15 @@ function getHour(date) {
return hour; return hour;
} }
function getCoarseMinute(date) { function getCoarseMinute(date) {
if (typeof layout.getCoarseMinute === 'function') { if (typeof currentLayout.getCoarseMinute === 'function') {
return layout.getCoarseMinute(date); return currentLayout.getCoarseMinute(date);
} }
var minutes = date.getMinutes(); var minutes = date.getMinutes();
return minutes - getDotMinute(date); return minutes - getDotMinute(date);
} }
function getDotMinute(date) { function getDotMinute(date) {
if (typeof layout.getDotMinute === 'function') { if (typeof currentLayout.getDotMinute === 'function') {
return layout.getDotMinute(date); return currentLayout.getDotMinute(date);
} }
var minutes = date.getMinutes(); var minutes = date.getMinutes();
return minutes % 5; return minutes % 5;
@ -77,24 +82,35 @@ function stopClock() {
} }
} }
function updateClockState() { function updateClockState() {
if ($('#onoffswitch').is(':checked')) { if (isOn()) {
startClock(); startClock();
} else { } else {
stopClock(); stopClock();
} }
} }
function switchTheme(element) { function isOn() {
var theme = $(element).val() return $('#onoffswitch').is(':checked');
}
function switchTheme(theme) {
$('#theme').attr('href', 'uhr-' + theme + '.css'); $('#theme').attr('href', 'uhr-' + theme + '.css');
} }
function render(layout) { function switchLayout(locale) {
stopClock();
currentLayout = layout[locale];
renderLayout();
if (isOn()) {
startClock();
}
}
function renderLayout() {
var container = $('#renderarea'); var container = $('#renderarea');
for (var y = 0; y < layout.values.length; y++) { container.empty();
for (var x = 0; x < layout.values[y].length; x++) { for (var y = 0; y < currentLayout.values.length; y++) {
var letter = layout.values[y][x]; for (var x = 0; x < currentLayout.values[y].length; x++) {
var letter = currentLayout.values[y][x];
container.append(letter.toString()); container.append(letter.toString());
} }
if (y < layout.values.length - 1) { if (y < currentLayout.values.length - 1) {
container.append('<br/>'); container.append('<br/>');
} }
} }