überzählige datei gelöscht
This commit is contained in:
		
							parent
							
								
									980ed302d3
								
							
						
					
					
						commit
						ce75dae1b0
					
				
					 1 changed files with 0 additions and 210 deletions
				
			
		
							
								
								
									
										210
									
								
								uhr-objects.js
									
										
									
									
									
								
							
							
						
						
									
										210
									
								
								uhr-objects.js
									
										
									
									
									
								
							|  | @ -1,210 +0,0 @@ | ||||||
| /** |  | ||||||
|  * Die Uhr. |  | ||||||
|  * @param renderarea   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; |  | ||||||
| 	this.timer = null; |  | ||||||
| 	this.currentTheme = null; |  | ||||||
| 	this.currentLayout = null; |  | ||||||
| 	this.layouts = new Array(); |  | ||||||
| 	this.currentMinute = -1; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Uhr.prototype.toggle = function() { |  | ||||||
| 	if (this.isOn()) { |  | ||||||
| 		this.stop(); |  | ||||||
| 	} else { |  | ||||||
| 		this.start(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| Uhr.prototype.start = function() { |  | ||||||
| 	if (!this.isOn()) { |  | ||||||
| 		var uhr = this; |  | ||||||
| 		this.timer = window.setInterval(function() {uhr.update();}, 1000); |  | ||||||
| 		this.update(); |  | ||||||
| 		$.cookie('status', 'on'); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| Uhr.prototype.stop = function() { |  | ||||||
| 	if (this.isOn()) { |  | ||||||
| 		window.clearInterval(this.timer); |  | ||||||
| 		this.timer = null; |  | ||||||
| 		this.update(); |  | ||||||
| 		$.cookie('status', 'off'); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 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]; |  | ||||||
| 	if (newLayout !== undefined && newLayout != this.currentLayout) { |  | ||||||
| 		this.currentLayout = newLayout; |  | ||||||
| 		var renderer = new UhrRenderer(this.currentLayout, this.renderarea); |  | ||||||
| 		renderer.render(this); |  | ||||||
| 		$.cookie('layout', locale); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| Uhr.prototype.setTheme = function(theme) { |  | ||||||
| 	if (theme != this.currentTheme) { |  | ||||||
| 		this.currentTheme = theme; |  | ||||||
| 		this.themeElement.attr('href', 'uhr-' + theme + '.css'); |  | ||||||
| 		$.cookie('theme', theme); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| Uhr.prototype.update = function() { |  | ||||||
| 	if (this.isOn()) { |  | ||||||
| 		var now = new Date(); |  | ||||||
| 		var dotMinute = this.getDotMinute(now); |  | ||||||
| 		if (dotMinute == this.currentMinute) { |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 		this.currentMinute = dotMinute; |  | ||||||
| 		var hour = this.getHour(now); |  | ||||||
| 		var coarseMinute = this.getCoarseMinute(now); |  | ||||||
| 		this.clear(); |  | ||||||
| 		this.highlight('on'); |  | ||||||
| 		for (var i = 1; i <= dotMinute; i++) { |  | ||||||
| 			this.highlight('dot' + i); |  | ||||||
| 		} |  | ||||||
| 		this.highlight('minute' + coarseMinute); |  | ||||||
| 		hour = this.normalizeHour(hour); |  | ||||||
| 		this.highlight('hour' + hour); |  | ||||||
| 		if (coarseMinute == 0) { |  | ||||||
| 			this.highlight('sharphour'); |  | ||||||
| 		} |  | ||||||
| 	} else { |  | ||||||
| 		this.clear(); |  | ||||||
| 		this.currentMinute = -1; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| Uhr.prototype.clear = function() { |  | ||||||
| 	this.renderarea.find('.item').removeClass('active'); |  | ||||||
| } |  | ||||||
| Uhr.prototype.highlight = function(itemClass) { |  | ||||||
| 	this.renderarea.find('.item.' + itemClass).addClass('active'); |  | ||||||
| } |  | ||||||
| Uhr.prototype.getHour = function(date) { |  | ||||||
| 	if (typeof this.currentLayout.getHour === 'function') { |  | ||||||
| 		return this.currentLayout.getHour(date); |  | ||||||
| 	} |  | ||||||
| 	var hour = date.getHours(); |  | ||||||
| 	if (date.getMinutes() >= 25) { |  | ||||||
| 		return hour + 1; |  | ||||||
| 	} |  | ||||||
| 	return hour; |  | ||||||
| } |  | ||||||
| Uhr.prototype.getCoarseMinute = function(date) { |  | ||||||
| 	if (typeof this.currentLayout.getCoarseMinute === 'function') { |  | ||||||
| 		return this.currentLayout.getCoarseMinute(date); |  | ||||||
| 	} |  | ||||||
| 	var minutes = date.getMinutes(); |  | ||||||
| 	return minutes - this.getDotMinute(date); |  | ||||||
| } |  | ||||||
| Uhr.prototype.getDotMinute = function(date) { |  | ||||||
| 	if (typeof this.currentLayout.getDotMinute === 'function') { |  | ||||||
| 		return this.currentLayout.getDotMinute(date); |  | ||||||
| 	} |  | ||||||
| 	var minutes = date.getMinutes(); |  | ||||||
| 	return minutes % 5; |  | ||||||
| } |  | ||||||
| Uhr.prototype.normalizeHour = function(hour) { |  | ||||||
| 	if (hour > 12) { |  | ||||||
| 		hour %= 12; |  | ||||||
| 	} |  | ||||||
| 	if (hour == 0) { |  | ||||||
| 		return 12; |  | ||||||
| 	} |  | ||||||
| 	return hour; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * Hilfsklasse zum Rendern der Uhr. |  | ||||||
|  * @param layout     Layout-Objekt, das gerendert werden soll. |  | ||||||
|  * @param renderarea Das jQuery-gewrappte HTML-Element, auf dem gerendert werden soll. |  | ||||||
|  */ |  | ||||||
| function UhrRenderer(layout, renderarea) { |  | ||||||
| 	this.layout = layout; |  | ||||||
| 	this.renderarea = renderarea; |  | ||||||
| } |  | ||||||
| UhrRenderer.prototype.render = function(uhr) { |  | ||||||
| 	var renderer = this; |  | ||||||
| 	this.renderarea.fadeOut('fast', function() { |  | ||||||
| 		renderer.renderarea.empty(); |  | ||||||
| 		for (var y = 0; y < renderer.layout.values.length; y++) { |  | ||||||
| 			for (var x = 0; x < renderer.layout.values[y].length; x++) { |  | ||||||
| 				var letter = renderer.layout.values[y][x]; |  | ||||||
| 				renderer.renderarea.append(letter.toString()); |  | ||||||
| 			} |  | ||||||
| 			if (y < renderer.layout.values.length - 1) { |  | ||||||
| 				renderer.renderarea.append('<br/>'); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		uhr.currentMinute = -1; |  | ||||||
| 		uhr.update(); |  | ||||||
| 		renderer.renderarea.fadeIn('fast'); |  | ||||||
| 	}); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * Ein Buchstabe. Hilfsklasse für den Renderer und Inhalt der Layout-Arrays. |  | ||||||
|  * @param value Der Buchstabe, der Dargestellt werden soll. |  | ||||||
|  * @param style Die CSS-Styleklassen des Buchstabens. |  | ||||||
|  */ |  | ||||||
| function Letter(value, style) { |  | ||||||
| 	this.value = value; |  | ||||||
| 	this.style = style || ''; |  | ||||||
| 	this.getStyle = function() { |  | ||||||
| 		return "item letter " + style; |  | ||||||
| 	} |  | ||||||
| 	this.getValue = function() { |  | ||||||
| 		return value; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| Letter.prototype.toString = function letterToString() { |  | ||||||
| 	return "<span class=\"" + this.getStyle() + "\">" + this.getValue() + "</span>"; |  | ||||||
| } |  | ||||||
| /** |  | ||||||
|  * Hilfsfunktion, um einen Buchstaben zu erzeugen. |  | ||||||
|  * |  | ||||||
|  * @param letter string: Der Buchstabe, der angezeigt werden soll |  | ||||||
|  * @example l('I', 'is') erzeugt den Buchstaben 'I' mit der CSS-Styleklasse 'is' |  | ||||||
|  */ |  | ||||||
| function l(letter, style) { |  | ||||||
| 	return new Letter(letter, style); |  | ||||||
| } |  | ||||||
| /** |  | ||||||
|  * Hilfsfunktion, um einen Buchstaben zu erzeugen, der zu einem Stunden-Wort gehört. |  | ||||||
|  * |  | ||||||
|  * @param letter   string:  Der Buchstabe, der angezeigt werden soll |  | ||||||
|  * @param hours... integer: Eine Aufzählung von Stundenwerten, zu welchen der Buchstabe als aktiv angezeigt werden soll |  | ||||||
|  * @example h('Z', 2), 11 erzeugt den Buchstaben 'Z', der um 2:xx, 11:xx, 14:xx und 23:xx aktiv angezeigt wird |  | ||||||
|  */ |  | ||||||
| function h(letter) { |  | ||||||
| 	var style = ''; |  | ||||||
| 	for (var i = 1; i < arguments.length; i++) { |  | ||||||
| 		style += ' hour' + arguments[i]; |  | ||||||
| 	} |  | ||||||
| 	return l(letter, style); |  | ||||||
| } |  | ||||||
| /** |  | ||||||
|  * Hilfsfunktion, um einen Buchstaben zu erzeugen, der zu einem Minuten-Wort gehört. |  | ||||||
|  * |  | ||||||
|  * @param letter     string:  Der Buchstabe, der angezeigt werden soll |  | ||||||
|  * @param minutes... integer: Eine Aufzählung von Minutenwerten, zu welchen der Buchstabe als aktiv angezeigt werden soll |  | ||||||
|  * @example m('A', 5, 10, 15, 20, 35) erzeugt den Buchstaben 'A' der um :05, :10, :15, :20 und :35 aktiv angezeigt wird |  | ||||||
|  */ |  | ||||||
| function m(letter) { |  | ||||||
| 	var style = ''; |  | ||||||
| 	for (var i = 1; i < arguments.length; i++) { |  | ||||||
| 		style += ' minute' + arguments[i]; |  | ||||||
| 	} |  | ||||||
| 	return l(letter, style); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue