MediaWiki:Skin/Kamelopedia:Zeitreisemaschine.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
J* (Diskussion | Beiträge) |
J* (Diskussion | Beiträge) |
||
(13 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
− | |||
− | |||
− | |||
/* | /* | ||
* Zeitwähler-Code | * Zeitwähler-Code | ||
Zeile 18: | Zeile 15: | ||
var s = { | var s = { | ||
init: function () { | init: function () { | ||
− | s.info = | + | s.info = document.getElementById("sliderinfo"); |
− | s.info2 = | + | s.info2 = document.getElementById("sliderinfo2"); |
− | s.case = | + | s.case = document.getElementById("slidercase"); |
− | s.back = | + | s.back = document.getElementById("sliderback"); |
− | s.slider = | + | s.slider = document.getElementById("slider"); |
− | s.slider2 = | + | s.slider2 = document.getElementById("slider2"); |
s.top = s.case.getTotalOffsetTop(); | s.top = s.case.getTotalOffsetTop(); | ||
s.left = s.case.getTotalOffsetLeft(); | s.left = s.case.getTotalOffsetLeft(); | ||
Zeile 70: | Zeile 67: | ||
window.onmousemove = s.move; | window.onmousemove = s.move; | ||
s.case.onclick = s.click; | s.case.onclick = s.click; | ||
− | s.birth = parseInt( | + | s.birth = parseInt( document.getElementById("t_birth").innerHTML ); |
− | s.today = parseInt( | + | s.today = parseInt( document.getElementById("t_today").innerHTML ); |
var b = new Date ( s.birth * 1000 ); | var b = new Date ( s.birth * 1000 ); | ||
var t = new Date ( s.today * 1000 ); | var t = new Date ( s.today * 1000 ); | ||
Zeile 101: | Zeile 98: | ||
function parseRevision( a ) | function parseRevision( a ) | ||
{ | { | ||
+ | console.log("parseRevision", a); | ||
document.getElementById("zr_content").innerHTML = a.wiki.HTML; | document.getElementById("zr_content").innerHTML = a.wiki.HTML; | ||
document.getElementsByTagName("H1")[0].innerHTML = page; | document.getElementsByTagName("H1")[0].innerHTML = page; | ||
Zeile 112: | Zeile 110: | ||
initSlider(); | initSlider(); | ||
s.slider2.style.left = (s.dx - 2 ) + "px"; | s.slider2.style.left = (s.dx - 2 ) + "px"; | ||
− | + | document.getElementById("shadow").style.display="none"; | |
return a; | return a; | ||
} | } | ||
Zeile 125: | Zeile 123: | ||
var time="20050101"; | var time="20050101"; | ||
− | var page="Hauptseite"; | + | var page="Kamelopedia:Hauptseite"; |
var dbg; | var dbg; | ||
− | getRevision | + | var getRevision; |
− | + | var getRescue; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | getRescue | ||
− | |||
− | |||
− | |||
− | |||
// in den Datumswähler einhängen: | // in den Datumswähler einhängen: | ||
Zeile 158: | Zeile 145: | ||
function initTM() | function initTM() | ||
{ | { | ||
+ | |||
+ | getRevision = new Async( [ | ||
+ | function () { document.getElementById("shadow").style.display="table"; var a = { wiki: { source: "{{#dpl: namespace = | lastrevisionbefore = "+parseInt(window.time)+" | format=,%REVISION%, | skipthispage = no | count = 1 | titlematch = "+page+" | count = 1}}", title: "Hauptseite" } }; return a; }, | ||
+ | wiki.parse, | ||
+ | function (a) { var rev = parseInt(jQuery(a.wiki.HTML).text()); if (isNaN(rev)) {a.wiki.HTML="Diese Seite gab es damals noch nicht."; console.log(a); parseRevision(a); getRevision.pointer ++; return;} a.wiki.args = "oldid="+rev; a.wiki.title = page; return a; }, | ||
+ | wiki.getHTML, | ||
+ | parseRevision | ||
+ | ], function () {} ); | ||
+ | |||
+ | getRescue = new Async( [ | ||
+ | function (a) { document.getElementById("shadow").style.display="table"; page="Zufällige Artikelvorschläge"; return { wiki: { source: "Probier doch mal: {{#dpl: namespace = | lastrevisionbefore = "+parseInt(time)+" | format = ,\\n*[[%PAGE%]], | randomcount = 6 }}", title: "Hauptseite" } } }, | ||
+ | wiki.parse, | ||
+ | parseRevision | ||
+ | ], function () {} ); | ||
+ | |||
+ | |||
var links = document.getElementsByTagName("A"); | var links = document.getElementsByTagName("A"); | ||
Zeile 163: | Zeile 166: | ||
links[i].keepToday = true; | links[i].keepToday = true; | ||
− | + | ||
+ | |||
+ | document.getElementById("zr_info").onclick = function () { getRescue.start(); }; | ||
initSlider(); | initSlider(); | ||
} | } | ||
addOnloadHook(initTM); | addOnloadHook(initTM); |
Aktuelle Version vom 22. Mai 2015, 07:05 Uhr
/*
* Zeitwähler-Code
*/
function getTotalOffset( element, offsetType, sum )
{
if ( element.offsetParent != null )
sum += getTotalOffset( element.offsetParent, offsetType, sum );
return sum + element[offsetType];
}
Node.prototype.getTotalOffsetTop = function () { return getTotalOffset( this, "offsetTop", 0 ); };
Node.prototype.getTotalOffsetLeft = function () { return getTotalOffset( this, "offsetLeft", 0 ); };
var s = {
init: function () {
s.info = document.getElementById("sliderinfo");
s.info2 = document.getElementById("sliderinfo2");
s.case = document.getElementById("slidercase");
s.back = document.getElementById("sliderback");
s.slider = document.getElementById("slider");
s.slider2 = document.getElementById("slider2");
s.top = s.case.getTotalOffsetTop();
s.left = s.case.getTotalOffsetLeft();
},
move: function (e) {
var x = document.all ? window.event.clientX : e.pageX;
var y = document.all ? window.event.clientY : e.pageY;
if ( x > s.left && x < s.left + s.case.offsetWidth &&
y > s.top && y < s.top + s.case.offsetHeight )
{
s.dx = x - s.left - 1 ;
s.px = s.dx / ( s.case.offsetWidth - 2 );
s.date = s.calcTime(s.px);
s.dateInfo = "";
s.dateInfo += s.date.getDate() + ". ";
s.dateInfo += ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"][s.date.getMonth()] + " ";
s.dateInfo += s.date.getFullYear();
s.info.innerHTML = s.dateInfo;
s.slider.style.left = (s.dx - 1 ) + "px";
s.slider.style.display = "block";
}
else
{
s.info.innerHTML = "Kein Datum ausgewählt.";
s.slider.style.display = "none";
}
},
calcTime: function (p) {
return new Date( ( (s.today - s.birth) * p + s.birth ) * 1000 );
},
click: function (e) {
s.move(e);
s.info2.innerHTML = s.dateInfo;
s.slider2.style.left = (s.dx - 2 ) + "px";
s.slider2.style.display="block";
s.fkt();
}
}
function initSlider()
{
s.init();
window.onmousemove = s.move;
s.case.onclick = s.click;
s.birth = parseInt( document.getElementById("t_birth").innerHTML );
s.today = parseInt( document.getElementById("t_today").innerHTML );
var b = new Date ( s.birth * 1000 );
var t = new Date ( s.today * 1000 );
s.back.innerHTML="";
for (var x=b.getFullYear(); x<t.getFullYear(); x++)
{
var e = document.createElement("DIV");
e.style.position = "absolute";
e.style.height = "100%";
e.style.width = "100%";
e.innerHTML = x+1;
e.style.margin = "0px";
e.style.padding = "0px";
e.style.borderLeft = "1px darkblue solid";
e.style.color = "darkblue";
e.style.top = "0px";
e.style.width = "5em";
e.style.left = ( (new Date(x+1,0,1) - b) / ( t - b ) * (s.case.offsetWidth - 2) ) + "px";
s.back.appendChild(e);
}
}
/*
* Zeitmaschinen-Code
*/
var ret;
function parseRevision( a )
{
console.log("parseRevision", a);
document.getElementById("zr_content").innerHTML = a.wiki.HTML;
document.getElementsByTagName("H1")[0].innerHTML = page;
dbg = wiki.transport;
var links = document.getElementsByTagName("A");
for(var i=0; i<links.length; i++)
if (links[i].keepToday != true)
links[i].onclick = nextlink;
//keine Ahnung warum, aber wir müssen den Slider neu setzen!
initSlider();
s.slider2.style.left = (s.dx - 2 ) + "px";
document.getElementById("shadow").style.display="none";
return a;
}
nextlink = function ()
{
page = this.title;
getRevision.start();
return false;
}
var time="20050101";
var page="Kamelopedia:Hauptseite";
var dbg;
var getRevision;
var getRescue;
// in den Datumswähler einhängen:
s.fkt = function () {
var y = String(s.date.getFullYear());
var m = String(s.date.getMonth()+1);
var d = String(s.date.getDate());
if (d.length == 1 )
d = "0"+d;
if (m.length == 1 )
m = "0"+m;
time = y+m+d;
getRevision.start();
}
function initTM()
{
getRevision = new Async( [
function () { document.getElementById("shadow").style.display="table"; var a = { wiki: { source: "{{#dpl: namespace = | lastrevisionbefore = "+parseInt(window.time)+" | format=,%REVISION%, | skipthispage = no | count = 1 | titlematch = "+page+" | count = 1}}", title: "Hauptseite" } }; return a; },
wiki.parse,
function (a) { var rev = parseInt(jQuery(a.wiki.HTML).text()); if (isNaN(rev)) {a.wiki.HTML="Diese Seite gab es damals noch nicht."; console.log(a); parseRevision(a); getRevision.pointer ++; return;} a.wiki.args = "oldid="+rev; a.wiki.title = page; return a; },
wiki.getHTML,
parseRevision
], function () {} );
getRescue = new Async( [
function (a) { document.getElementById("shadow").style.display="table"; page="Zufällige Artikelvorschläge"; return { wiki: { source: "Probier doch mal: {{#dpl: namespace = | lastrevisionbefore = "+parseInt(time)+" | format = ,\\n*[[%PAGE%]], | randomcount = 6 }}", title: "Hauptseite" } } },
wiki.parse,
parseRevision
], function () {} );
var links = document.getElementsByTagName("A");
for(var i=0; i<links.length; i++)
links[i].keepToday = true;
document.getElementById("zr_info").onclick = function () { getRescue.start(); };
initSlider();
}
addOnloadHook(initTM);