Vorlage:Uhr: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Loki (Diskussion | Beiträge) KKeine Bearbeitungszusammenfassung |
K (Vorlagen-Kategorie umbenannt) |
||
| (4 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
<center><div style="font-size:200%; text-align:center; background-color:{{#switch: | <center><div class="clock" style="border-collapse: separate; font-size:200%; text-align:center; background-color:{{#switch: | ||
{{#switch: {{CURRENTMONTH}} | {{#switch: {{CURRENTMONTH}} | ||
| 1 | | 1 | ||
| Zeile 126: | Zeile 126: | ||
}}; color:white; width:45%"> | }}; color:white; width:45%"> | ||
Its {{LOCALTIME}}:{{#time:s}} <br/> Do You Know Where Your Meat Body Is? | Its {{LOCALTIME}}:{{#time:s}} <br/> Do You Know Where Your Meat Body Is? | ||
</div></center> | </div></center><noinclude> | ||
Die volle Funktionsfähigkeit erreicht die '''Vorlage:Uhr''' durch Einfügen des folgenden Javascripts auf der monobook.js-Seite (Link: <nowiki>http://wiki.shadowhelix.de/Benutzer:Name_des_Benutzers/monobook.js</nowiki>): | |||
<pre> | |||
/* Uhr */ | |||
function updateClock () { | |||
var Clock = document.getElementsByTagName( "div" ); | |||
for ( var i = 0; i < Clock.length; i++ ) { | |||
// div mit class="clock" raussuchen | |||
if ( hasClass( Clock[i], "clock" ) ) { | |||
// div wird geleert | |||
while(Clock[i].hasChildNodes()){ | |||
Clock[i].removeChild(Clock[i].lastChild); | |||
} | |||
var currentTime = new Date (); | |||
var currentHours = currentTime.getHours(); | |||
var currentMinutes = currentTime.getMinutes(); | |||
var currentSeconds = currentTime.getSeconds(); | |||
// ergänzung einer null, wenn sec, min, std nur eine ziffer haben | |||
if ( currentHours < 10) { currentHours = "0"+currentHours} | |||
if (currentMinutes < 10) {currentMinutes = "0"+currentMinutes} | |||
if (currentSeconds < 10) {currentSeconds = "0"+currentSeconds} | |||
// text + aktuelle uhrzeit | |||
var ClockText2 = document.createTextNode( "Do You Know Where Your " | |||
+"Meat Body Is?" ); | |||
var ClockText1 = document.createTextNode( "Its "+currentHours+":" | |||
+currentMinutes+":" | |||
+currentSeconds ); | |||
var Brk = document.createElement( "br" ); | |||
// einfügen in div | |||
Clock[i].insertBefore( ClockText2, Clock[i].childNodes[0] ); | |||
Clock[i].insertBefore( Brk, Clock[i].childNodes[0] ); | |||
Clock[i].insertBefore( ClockText1, Clock[i].childNodes[0] ); | |||
// reset der lineHeight notwendig | |||
Clock[i].style.lineHeight = "1.5em"; | |||
// nächster aufruf von updateClock() nach 1000ms | |||
setTimeout('updateClock();',1000); | |||
} | |||
} | |||
} | |||
addOnloadHook( updateClock ); | |||
</pre> | |||
[[Kategorie:!Vorlagen/Gimmick|Uhr]]</noinclude> | |||
Aktuelle Version vom 2. Mai 2013, 15:45 Uhr
Its 16:54:31
Do You Know Where Your Meat Body Is?
Die volle Funktionsfähigkeit erreicht die Vorlage:Uhr durch Einfügen des folgenden Javascripts auf der monobook.js-Seite (Link: http://wiki.shadowhelix.de/Benutzer:Name_des_Benutzers/monobook.js):
/* Uhr */
function updateClock () {
var Clock = document.getElementsByTagName( "div" );
for ( var i = 0; i < Clock.length; i++ ) {
// div mit class="clock" raussuchen
if ( hasClass( Clock[i], "clock" ) ) {
// div wird geleert
while(Clock[i].hasChildNodes()){
Clock[i].removeChild(Clock[i].lastChild);
}
var currentTime = new Date ();
var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes();
var currentSeconds = currentTime.getSeconds();
// ergänzung einer null, wenn sec, min, std nur eine ziffer haben
if ( currentHours < 10) { currentHours = "0"+currentHours}
if (currentMinutes < 10) {currentMinutes = "0"+currentMinutes}
if (currentSeconds < 10) {currentSeconds = "0"+currentSeconds}
// text + aktuelle uhrzeit
var ClockText2 = document.createTextNode( "Do You Know Where Your "
+"Meat Body Is?" );
var ClockText1 = document.createTextNode( "Its "+currentHours+":"
+currentMinutes+":"
+currentSeconds );
var Brk = document.createElement( "br" );
// einfügen in div
Clock[i].insertBefore( ClockText2, Clock[i].childNodes[0] );
Clock[i].insertBefore( Brk, Clock[i].childNodes[0] );
Clock[i].insertBefore( ClockText1, Clock[i].childNodes[0] );
// reset der lineHeight notwendig
Clock[i].style.lineHeight = "1.5em";
// nächster aufruf von updateClock() nach 1000ms
setTimeout('updateClock();',1000);
}
}
}
addOnloadHook( updateClock );