MediaWiki:Skin/Friedhof.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
WiMu (Diskussion | Beiträge) K (Die Seite wurde neu angelegt.) |
WiMu (Diskussion | Beiträge) K (keine scriptfehler, wenn man auf bearbeiten klickt ...) |
||
Zeile 4: | Zeile 4: | ||
window.onload = function () { | window.onload = function () { | ||
− | maxtop = document.getElementById('rahmen').offsetHeight; | + | if(document.getElementById('rahmen')) { |
− | + | maxtop = document.getElementById('rahmen').offsetHeight; | |
− | + | maxleft = document.getElementById('rahmen').offsetWidth; | |
− | + | butterfly = document.getElementById('schmetterling'); | |
+ | fly(); | ||
+ | } | ||
} | } | ||
Version vom 16. September 2009, 22:45 Uhr
var speed = 50 // "Fluggeschwindigkeit" (Achtung, je höher der Wert, desto langsamer; doof das, aber geht nicht anders)
document.write('<embed src="http://kamelopedia.mormo.org/images/e/ec/Schnaderhüpfel.mid" autostart="true" type="audio/midi" loop="true" hidden="true" height="0" width="0">');
window.onload = function () {
if(document.getElementById('rahmen')) {
maxtop = document.getElementById('rahmen').offsetHeight;
maxleft = document.getElementById('rahmen').offsetWidth;
butterfly = document.getElementById('schmetterling');
fly();
}
}
function fly() {
var direction = Math.floor(Math.random() * 10) % 4;
switch(direction) {
case 0:
if(Number(butterfly.style.top.replace(/px/, "")) + 1 <= maxtop) {
butterfly.style.top = Number(butterfly.style.top.replace(/px/, "")) + 1 + 'px';
}
break;
case 1:
if(Number(butterfly.style.top.replace(/px/, "")) - 1 >= 0) {
butterfly.style.top = Number(butterfly.style.top.replace(/px/, "")) - 1 + 'px';
}
break;
case 2:
if(Number(butterfly.style.left.replace(/px/, "")) + 1 <= maxleft) {
butterfly.style.left = Number(butterfly.style.left.replace(/px/, "")) + 1 + 'px';
}
break;
case 3:
if(Number(butterfly.style.left.replace(/px/, "")) - 1 >= 0) {
butterfly.style.left = Number(butterfly.style.left.replace(/px/, "")) - 1 + 'px';
}
break;
}
window.setTimeout("fly()", speed);
}