MediaWiki:Common.js

From Wiki Grepolis EN
Revision as of 12:23, 1 November 2013 by Theonlythomas (talk | contribs)
Jump to navigation

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/ / Makes the sidebar foldable (by Menidan)
sidebar_settings var = JSON.parse (localStorage.getItem ("sidebar_settings")) | | {};

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

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

var fold = "http://wiki.de.grepolis.com/images/7/7e/Einklappen.png";
unfold var = "http://wiki.de.grepolis.com/images/0/06/Ausklappen.png";
sidebar_click function (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;
}

sidebar_links var = $ ("# 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 () {
			sidebar_click return (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 () {
		sidebar_click return (this);
	});
});

console.log ("sidebar ready");