Benutzer:ThePeritus/monobook.js
Erscheinungsbild
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
// Simon Willison's addLoadEvent()
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
// Clientside SVG-rendering
// Does at least work in FF1.5
function normalizeSVGs() {
for(var j = 0; j<document.svgs.length; j++) {
document.svgs[j].contentDocument.documentElement.setAttribute("height", "100%");
document.svgs[j].contentDocument.documentElement.setAttribute("width", "100%");
}
}
function replaceSVGs() {
document.svgs.loaded = 0;
for(var j = 0; j<document.svgs.length; j++) {
document.svgs[j].replaces.parentNode.appendChild(document.svgs[j]);
document.svgs[j].parentNode.removeChild(document.svgs[j].replaces);
}
}
function collectSVGs() {
var potimgs = document.getElementsByTagName("img");
var imgs = Array();
document.svgs = Array();
for(var j = 0; j<potimgs.length; j++) {
imgs[imgs.length] = potimgs[j]; // HTMLCollection != Array of IMGObject's
}
while(imgs.length > 0) {
var i = imgs.shift();
var split = i.src.split("/");
if(i.src.substr(0, 28) == '/media/'
&& split[5] == 'thumb' // assuming there are no non-thumb .svgs
&& split[8].split(".")[1] == 'svg' ) {
var svgsrc = "/media/wikipedia/".concat(
split[4], "/", split[6], "/", split[7], "/", split[8]
);
var obj = document.createElement("iframe");
obj.setAttribute("type", "image/svg+xml");
obj.setAttribute("src", svgsrc);
obj.setAttribute("scrolling", "no");
obj.setAttribute("frameborder", "no");
obj.setAttribute("height", i.height);
obj.setAttribute("width", i.width);
obj.onload = function() {
if(++document.svgs.loaded == document.svgs.length) {
normalizeSVGs();
}
}
obj.replaces = i;
document.svgs[document.svgs.length] = obj; // reverse order!
}
}
}
addLoadEvent(function() {
collectSVGs();
replaceSVGs();
/* normalizeSVGs(); is called when they are loaded */
});