es funzt! nun muss ich aufräumen und das ganze noch RICHTIG machen.

This commit is contained in:
Manuel Friedli 2014-01-11 12:18:11 +01:00
parent 9db6473085
commit fc2c8ac38a
5 changed files with 33 additions and 11 deletions

View file

@ -30,6 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<body style="padding:0;margin:0;">
<div id="uhr"></div>
<div id="test"></div>
<div class="u"></div>
<div class="u"></div>
<div class="u"></div>
<p id="disclaimer">Created by fritteli, inspired by <a href="http://www.qlocktwo.com/">QLOCKTWO</a>.
<script type="text/javascript" src="uhr-de_CH.js"></script>
<script type="text/javascript" src="uhr-de.js"></script>
@ -46,7 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
width: size + 'px'
});
*/
$('#test').uhr({width:'10em'});
$('div.u').uhr({width:'10em'});
</script>
</body>
</html>

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.registerLanguage('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.registerLanguage('de_CH', layout);

View file

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

33
uhr.js
View file

@ -43,7 +43,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
return;
}
e.data('currentMinute', now.getMinutes());
//FIXME
var dotMinute = Uhr.getDotMinute(e, now);
var hour = Uhr.getHour(e, now);
var coarseMinute = this.getCoarseMinute(e, now);
@ -74,6 +73,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
e.find('.item').removeClass('active');
},
setLanguage: function(e, language) {
var newLanguage = Uhr.layouts[language];
if (newLanguage !== undefined && newLanguage != e.data('currentLanguage')) {
e.data('currentLanguage', newLanguage);
var renderer = new UhrRenderer(newLanguage, e.find('.letterarea'));
renderer.render(e);
jQuery.cookie('language' + e.data('id'), language, {expires: 365, path: '/'});
}
},
setTheme: function(e, theme) {
var currentTheme = e.data('currentTheme');
@ -91,9 +97,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
e.find('.item.' + itemClass).addClass('active');
},
getHour: function(e, date) {
//FIXME
/*
if (typeof e.data('currentLayout').getHour === 'function') {
return e.data('currentLayout').getHour(date);
}
*/
var hour = date.getHours();
if (date.getMinutes() >= 25) {
return hour + 1;
@ -101,16 +110,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
return hour;
},
getCoarseMinute: function(e, date) {
//FIXME
/*
if (typeof e.data('currentLayout').getCoarseMinute === 'function') {
return e.data('currentLayout').getCoarseMinute(date);
}
*/
var minutes = date.getMinutes();
return minutes - Uhr.getDotMinute(e, date);
},
getDotMinute: function(e, date) {
//FIXME
/*
if (typeof e.data('currentLayout').getDotMinute === 'function') {
return e.data('currentLayout').getDotMinute(date);
}
*/
var minutes = date.getMinutes();
return minutes % 5;
},
@ -122,7 +137,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
return 12;
}
return hour;
}
},
registerLanguage: function(languageKey, layout) {
this.layouts[languageKey] = layout;
},
layouts: new Array()
}
$.fn.uhr = function(options) {
var settings = $.extend({
@ -470,6 +489,9 @@ Uhr.prototype.initThemeSwitch = function(defaultValue, overrideCookie) {
this.setTheme(selectedTheme);
}
//}
})(jQuery);
/**
* Hilfsklasse zum Rendern der Uhr.
* @param layout Layout-Objekt, das gerendert werden soll.
@ -492,14 +514,11 @@ UhrRenderer.prototype.render = function(uhr) {
renderer.renderarea.append('<br/>');
}
}
uhr.currentMinute = -1;
uhr.update();
uhr.data('currentMinute', -1);
Uhr.update(uhr);
renderer.renderarea.fadeIn('fast');
});
}
//}
})(jQuery);
/**
* Ein Buchstabe. Hilfsklasse für den Renderer und Inhalt der Layout-Arrays.
* @param value Der Buchstabe, der Dargestellt werden soll.