„MediaWiki:Common.js” változatai közötti eltérés

Innen: Tribalwars Wiki HU
Jump to navigation
(Új oldal, tartalma: „→‎Az ide elhelyezett JavaScript kód minden felhasználó számára lefut az oldalak betöltésekor.: function ModifySidebar(action, section, name, link) { try { …”)
 
Nincs szerkesztési összefoglaló
 
(17 közbenső módosítás, amit 4 másik szerkesztő végzett, nincs mutatva)
1. sor: 1. sor:
/* Az ide elhelyezett JavaScript kód minden felhasználó számára lefut az oldalak betöltésekor. */
/* 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>");


function ModifySidebar(action, section, name, link) {
importScript_ = importScript
    try {
 
        switch (section) {
 
          case "languages":
// Makes the sidebar foldable (by Menidan)
            var target = "p-lang";
var sidebar_settings = JSON.parse (localStorage.getItem ("sidebar_settings")) || {};
            break;
 
          case "toolbox":
function save_sidebar () {
            var target = "p-tb";
localStorage.setItem ("sidebar_settings", JSON.stringify (sidebar_settings));
            break;
          case "navigation":
            var target = "p-navigation";
            break;
          default:
            var target = "p-" + section;
            break;
        }
        if (action == "add") {
            var node = document.getElementById(target)
                              .getElementsByTagName('div')[0]
                              .getElementsByTagName('ul')[0];
            var aNode = document.createElement('a');
            var liNode = document.createElement('li');
            aNode.appendChild(document.createTextNode(name));
            aNode.setAttribute('href', link);
            liNode.appendChild(aNode);
            liNode.className='plainlinks';
            node.appendChild(liNode);
        }
        if (action == "remove") {
            var list = document.getElementById(target)
                              .getElementsByTagName('div')[0]
                              .getElementsByTagName('ul')[0];
            var listelements = list.getElementsByTagName('li');
            for (var i = 0; i < listelements.length; i++) {
                if (listelements[i].getElementsByTagName('a')[0].innerHTML == name ||
                    listelements[i].getElementsByTagName('a')[0].href == link) {
                    list.removeChild(listelements[i]);
                }
            }
        }
    } catch(e) {
      // lets just ignore what's happened
      return;
    }
}
}
 
function CustomizeModificationsOfSidebar() {
function set_sidebar (id, folded) {
    //adds [[Special:CategoryTree]] to toolbox
if (document.getElementById (id).parentElement.id != "column-one")
    ModifySidebar("add", "toolbox", "CategoryTree", "http://en.wikipedia.org/wiki/Special:CategoryTree");
return;
    //removes [[Special:Upload]] from toolbox
if (folded)
    ModifySidebar("remove", "toolbox", "Upload file", "http://en.wikipedia.org/wiki/Special:Upload");
sidebar_settings [id] = true;
else
delete sidebar_settings [id];
save_sidebar ();
}
}
   
 
addOnloadHook(CustomizeModificationsOfSidebar);
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");
*/
 
 
 
// Rewrite of announcement display. (by Menidan)
$ (function () {
// Changes the announcement to the next announcement in the list.
function changeAnnouncement () {
  $ (announcementList [currentAnnouncement]).fadeOut ("normal", function () {
  ++currentAnnouncement;
  if (currentAnnouncement >= announcementList.length)
    currentAnnouncement = 0;
  $ (announcementList [currentAnnouncement]).fadeIn ();
  });
}
 
var announcementList = $ (".announcement");
var currentAnnouncement = 0;
var announcementVisibilityTime = 5000; // ms
 
announcementList.hide ();
if (announcementList.length > 1) {
  $ (announcementList [0]).fadeIn ();
  setInterval (changeAnnouncement, announcementVisibilityTime);
  } else if (announcementList.length > 0)
  announcementList.fadeIn ();
 
 
// Piwik is undefined -> comment it out.
/*
try {
  var piwikTracker = Piwik.getTracker (pkBaseURL + "piwik.php", 2);
  piwikTracker.trackPageView ();
  piwikTracker.enableLinkTracking ();
} catch (err) {}
*/
});
 
// ?
var importScript_ = importScript;

A lap jelenlegi, 2019. szeptember 29., 13:21-kori változata

/* 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");
*/



// Rewrite of announcement display. (by Menidan)
$ (function () {
 // Changes the announcement to the next announcement in the list.
 function changeAnnouncement () {
  $ (announcementList [currentAnnouncement]).fadeOut ("normal", function () {
   ++currentAnnouncement;
   if (currentAnnouncement >= announcementList.length)
    currentAnnouncement = 0;
   $ (announcementList [currentAnnouncement]).fadeIn ();
  });
 }

 var announcementList = $ (".announcement");
 var currentAnnouncement = 0;
 var announcementVisibilityTime = 5000; // ms

 announcementList.hide ();
 if (announcementList.length > 1) {
  $ (announcementList [0]).fadeIn ();
  setInterval (changeAnnouncement, announcementVisibilityTime);
 } else if (announcementList.length > 0)
  announcementList.fadeIn ();


 // Piwik is undefined -> comment it out.
 /*
 try {
  var piwikTracker = Piwik.getTracker (pkBaseURL + "piwik.php", 2);
  piwikTracker.trackPageView ();
  piwikTracker.enableLinkTracking ();
 } catch (err) {}
 */
});

// ?
var importScript_ = importScript;