MediaWiki:Common.js: Difference between revisions

From Wiki Grepolis EN
Jump to navigation
mNo edit summary
mNo edit summary
Line 1: Line 1:
/ * Any JavaScript here will be loaded for all users on every page load. * /
/* Any JavaScript here will be loaded for all users on every page load. */


document.write ("<script src='/index.php?title=Global.js&action=raw&smaxage=0&ctype=text/javascript' type='text/javascript'> </ script>");
document.write("<script src='/index.php?title=Global.js&action=raw&smaxage=0&ctype=text/javascript' type='text/javascript'></script>");


importScript_ = import script
importScript_ = importScript


/ / Makes the sidebar foldable (by Menidan)
sidebar_settings var = JSON.parse (localStorage.getItem ("sidebar_settings")) | | {};


save_sidebar function () {
// Makes the sidebar foldable (by Menidan)
var sidebar_settings = JSON.parse (localStorage.getItem ("sidebar_settings")) || {};
 
function save_sidebar () {
localStorage.setItem ("sidebar_settings", JSON.stringify (sidebar_settings));
localStorage.setItem ("sidebar_settings", JSON.stringify (sidebar_settings));
}
}


set_sidebar function (id, folded) {
function set_sidebar (id, folded) {
if (document.getElementById (id). parentElement.id! = "column-one")
if (document.getElementById (id).parentElement.id != "column-one")
return;
return;
if (folded)
if (folded)
sidebar_settings [id] = true;
sidebar_settings [id] = true;
else
else
sidebar_settings delete [id];
delete sidebar_settings [id];
save_sidebar ();
save_sidebar ();
}
}


var fold = "http://wiki.de.grepolis.com/images/7/7e/Einklappen.png";
var fold = "http://wiki.de.grepolis.com/images/7/7e/Einklappen.png";
unfold var = "http://wiki.de.grepolis.com/images/0/06/Ausklappen.png";
var unfold = "http://wiki.de.grepolis.com/images/0/06/Ausklappen.png";
sidebar_click function (node) {
function sidebar_click (node) {
var content = $ (node.parentElement.lastElementChild);
var content = $ (node.parentElement.lastElementChild);
if (content.css ("display") == "none") {
if (content.css ("display") == "none") {
Line 31: Line 32:
node.firstElementChild.src = fold;
node.firstElementChild.src = fold;
set_sidebar (node.parentElement.id, false);
set_sidebar (node.parentElement.id, false);
Else {}
} else {
content.css ("display", "none");
content.css ("display", "none");
node.firstElementChild.alt = "[+]";
node.firstElementChild.alt = "[+]";
Line 40: Line 41:
}
}


sidebar_links var = $ ("# column-one. generated sidebar.portlet-h5"). Slice (1). replaceWith (function () {
var sidebar_links = $ ("#column-one .generated-sidebar.portlet h5").slice (1).replaceWith (function () {
if (sidebar_settings [this.parentElement.id])
if (! sidebar_settings [this.parentElement.id])
return $ ('<a href="#" style="text-align:center"> <img src="' + fold +'" style="float:left" alt="[-]" /> <h5 > '+ this.innerHTML +' </ h5> </ a> '). click (function () {
return $ ('<a href="#" style="text-align:center"><img src="' + fold + '" style="float:left" alt="[-]" /><h5>' + this.innerHTML + '</h5></a>').click (function () {
sidebar_click return (this);
return sidebar_click (this);
});
});


. $ (This.nextElementSibling) css ("display", "none");
$ (this.nextElementSibling).css ("display", "none");
return $ ('<a href="#" style="text-align:center"> <img src="' + unfold +'" style="float:left" alt="[+]" /> <h5 > '+ this.innerHTML +' </ h5> </ a> '). click (function () {
return $ ('<a href="#" style="text-align:center"><img src="' + unfold + '" style="float:left" alt="[+]" /><h5>' + this.innerHTML + '</h5></a>').click (function () {
sidebar_click return (this);
return sidebar_click (this);
});
});
});
});


console.log ("sidebar ready");
console.log ("sidebar ready");
// Halloween 2013 (by Menidan)
if (location.pathname == "/wiki/Hauptseite" && ! localStorage.getItem ("halloween-2013")) {
localStorage.setItem ("halloween-2013", "delete this entry to show the window again");
var overlay = $ ('<div></div>').appendTo (document.body);
overlay.css ({
"background-color": "black",
"backgound-position": "center",
"background-size": "contain",
"background-repeat": "no-repeat",
"background-attachment": "fixed",
"backgound-image": "url(/images/e/ea/Test.gif)",
position: "absolute",
left: 0,
right: 0,
top: 0,
bottom: 0,
"z-index": 10
});
overlay [0].style.backgroundImage = "url(/images/e/ea/Test.gif)";
$ (document.body).css ("overflow", "hidden");
var close_button = $ ('<a href="#"><img src="/images/7/75/Grepolis_Wiki_307.png" /></a>').appendTo (overlay).css ({
position: "absolute",
top: "10px",
right: "10px"
}).click (function () {
$ (document.body).css ("overflow", "");
overlay.remove ();
$ (audio).remove ();
});
var audio = $ ('<audio preload="preload" autostart="autostart"><source src="http://www.horror-grusel.de/horror0407/sounds/sm.wav" /></audio>').appendTo (overlay) [0];
audio.addEventListener ("load", function () {
alert ("loaded");
audio.play ();
});
audio.addEventListener ("ended", function () {
setTimeout (function () {
audio.currentTime = 0;
audio.play ();
}, 1); // die 1 durch beliebige Anzahl an Millisekunden zwischen dem einzelnen Abspielen des Geräusches ersetzen
});
audio.load ();
audio.play ();
}

Revision as of 12:24, 1 November 2013

/* Any JavaScript here will be loaded for all users on every page load. */

document.write("<script src='/index.php?title=Global.js&action=raw&smaxage=0&ctype=text/javascript' type='text/javascript'></script>");

importScript_ = importScript


// Makes the sidebar foldable (by Menidan)
var sidebar_settings = JSON.parse (localStorage.getItem ("sidebar_settings")) || {};

function save_sidebar () {
	localStorage.setItem ("sidebar_settings", JSON.stringify (sidebar_settings));
}

function set_sidebar (id, folded) {
	if (document.getElementById (id).parentElement.id != "column-one")
		return;
	if (folded)
		sidebar_settings [id] = true;
	else
		delete sidebar_settings [id];
	save_sidebar ();
}

var fold = "http://wiki.de.grepolis.com/images/7/7e/Einklappen.png";
var unfold = "http://wiki.de.grepolis.com/images/0/06/Ausklappen.png";
function sidebar_click (node) {
	var content = $ (node.parentElement.lastElementChild);
	if (content.css ("display") == "none") {
		content.css ("display", "block");
		node.firstElementChild.alt = "[-]";
		node.firstElementChild.src = fold;
		set_sidebar (node.parentElement.id, false);
	} else {
		content.css ("display", "none");
		node.firstElementChild.alt = "[+]";
		node.firstElementChild.src = unfold;
		set_sidebar (node.parentElement.id, true);
	}
	return false;
}

var sidebar_links = $ ("#column-one .generated-sidebar.portlet h5").slice (1).replaceWith (function () {
	if (! sidebar_settings [this.parentElement.id])
		return $ ('<a href="#" style="text-align:center"><img src="' + fold + '" style="float:left" alt="[-]" /><h5>' + this.innerHTML + '</h5></a>').click (function () {
			return sidebar_click (this);
		});

	$ (this.nextElementSibling).css ("display", "none");
	return $ ('<a href="#" style="text-align:center"><img src="' + unfold + '" style="float:left" alt="[+]" /><h5>' + this.innerHTML + '</h5></a>').click (function () {
		return sidebar_click (this);
	});
});

console.log ("sidebar ready");



// Halloween 2013 (by Menidan)
if (location.pathname == "/wiki/Hauptseite" && ! localStorage.getItem ("halloween-2013")) {
	localStorage.setItem ("halloween-2013", "delete this entry to show the window again");
	var overlay = $ ('<div></div>').appendTo (document.body);
	overlay.css ({
		"background-color": "black",
		"backgound-position": "center",
		"background-size": "contain",
		"background-repeat": "no-repeat",
		"background-attachment": "fixed",
		"backgound-image": "url(/images/e/ea/Test.gif)",
		position: "absolute",
		left: 0,
		right: 0,
		top: 0,
		bottom: 0,
		"z-index": 10
	});
	overlay [0].style.backgroundImage = "url(/images/e/ea/Test.gif)";
	$ (document.body).css ("overflow", "hidden");

	var close_button = $ ('<a href="#"><img src="/images/7/75/Grepolis_Wiki_307.png" /></a>').appendTo (overlay).css ({
		position: "absolute",
		top: "10px",
		right: "10px"
	}).click (function () {
		$ (document.body).css ("overflow", "");
		overlay.remove ();
		$ (audio).remove ();
	});

	var audio = $ ('<audio preload="preload" autostart="autostart"><source src="http://www.horror-grusel.de/horror0407/sounds/sm.wav" /></audio>').appendTo (overlay) [0];
	audio.addEventListener ("load", function () {
		alert ("loaded");
		audio.play ();
	});
	audio.addEventListener ("ended", function () {
		setTimeout (function () {
			audio.currentTime = 0;
			audio.play ();
		}, 1); // die 1 durch beliebige Anzahl an Millisekunden zwischen dem einzelnen Abspielen des Geräusches ersetzen
	});
	audio.load ();
	audio.play ();
}