MediaWiki:MenuChanges.js

/* */

/* ============== MENU CHANGES =============================== author:       Petr Kajzar User:Slepi date:         10/2009, last update 07/2010 dokumentation: -- description:  menu changes ==========================================================

/* ============================== Personal menu ========================================= */

// FUNCTION ADDING SANDBOX function piskoviste { // not logged in if(wgUserName==null) { // login vs anonlogin if(document.getElementById("pt-anonlogin")) piskovisteId = "pt-anonlogin"; if(document.getElementById("pt-login")) piskovisteId = "pt-login"; if(!piskovisteId) return;

addPortletLink('p-personal', wgServer + wgScriptPath + '/index.php?title=WikiLectures:Sandbox', 'My sandbox', 'pt-piskoviste', 'Place, where I can experiment', 'a', document.getElementById(piskovisteId));

} else { // personal sandbox addPortletLink('p-personal', wgServer + wgScriptPath + '/index.php?title=User:' + wgUserName + '/Sandbox', 'My sandbox', 'pt-piskoviste', 'Place, where I can experiment', 'a', document.getElementById('pt-preferences')); } }

/* ============================== Sidebar ====================================== */

// FUNCTION ADDING CATEGORY HISTORY LIK TO SIDEBAR function categoryHistory { addPortletLink('p-tb', wgServer + wgScriptPath + '/index.php/Special:CategoryHistory/'+wgTitle, 'Historie kategorie', 't-cathistory', 'History of changes of the articles in this category'); }

// FUNCTION ADDING EDUCATIONAL PORTALS TO SIDEBAR function addEdu {

// portal box novaSekce = document.createElement("div"); novaSekce.id = "p-edu"; novaSekce.className = "portal"; document.getElementById("mw-panel").appendChild(novaSekce);

// open section eduPortaly = ' ';

// MEFANET eduPortaly += '  ';

// Facebook eduPortaly += '  ';

// WebArchiv eduPortaly += '  '

// close section eduPortaly += ' ';

novaSekce.innerHTML = eduPortaly; }

// FUNCTION ADDING PORTALS WHICH CONTAIN THIS ARTICLE function odkazujiciPortaly {

// wait for data if(xmlPortaly.readyState != 4 || xmlPortaly.status != 200) return;

var jsonRes = xmlPortaly.responseText;

// response var output = ' '; var outputOtazky = ' '; var pocetOtazek = 0; // exam questions var jsonObj = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(jsonRes.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + jsonRes + ')');

// portals and exam questions separately pocetPortalu = jsonObj.query.backlinks.length; if(pocetPortalu == 0) return; // do not continue without portals

for(i=0;i'; zaznam += aktPortal.replace("Portal:", "") + '\n'; if (zaznam.indexOf("Exam") == -1 && zaznam.indexOf("exam") == -1) { output += zaznam; } else { outputOtazky += zaznam; pocetOtazek++; } }  output += " "; outputOtazky += "</ul> ";

// new portal section novaSekce = document.createElement("div"); novaSekce.id = "p-portal"; novaSekce.className = "portal"; document.getElementById("mw-panel").appendChild(novaSekce); document.getElementById("mw-panel").insertBefore(document.getElementById("p-portal"), document.getElementById("p-tb"));

novaSekceNadpis = document.createElement("h5"); novaSekceNadpis.id = "p-portal-nadpis"; document.getElementById("p-portal").appendChild(novaSekceNadpis); novaSekceNadpisText = document.createTextNode("Portals"); novaSekceNadpis.appendChild(novaSekceNadpisText);

novaSekceObsah = document.createElement("div"); novaSekceObsah.id = "p-portal-obsah"; novaSekceObsah.className = "pBody"; document.getElementById("p-portal").appendChild(novaSekceObsah);

document.getElementById("p-portal-obsah").innerHTML = output;

// exam section if(pocetOtazek>0) {

// new exam section novaSekceOt = document.createElement("div"); novaSekceOt.id = "p-portal-otazky"; novaSekceOt.className = "portal"; document.getElementById("mw-panel").appendChild(novaSekceOt); document.getElementById("mw-panel").insertBefore(document.getElementById("p-portal-otazky"), document.getElementById("p-tb"));

novaSekceOtNadpis = document.createElement("h5"); novaSekceOtNadpis.id = "p-portal-otazky-nadpis"; document.getElementById("p-portal-otazky").appendChild(novaSekceOtNadpis); novaSekceOtNadpisText = document.createTextNode("Exam materials ↓"); novaSekceOtNadpis.appendChild(novaSekceOtNadpisText);

novaSekceOtObsah = document.createElement("div"); novaSekceOtObsah.id = "p-portal-otazky-obsah"; novaSekceOtObsah.className = "pBody"; document.getElementById("p-portal-otazky").appendChild(novaSekceOtObsah);

document.getElementById("p-portal-otazky-obsah").innerHTML = outputOtazky; } // style of exam materials if(pocetOtazek>0) { otStyl = document.getElementById("p-portal-otazky-obsah"); otNadpStyl = document.getElementById("p-portal-otazky-nadpis"); otStyl.style.display = "none"; otNadpStyl.style.color = "darkblue"; otNadpStyl.style.textTransform = "none"; otNadpStyl.style.cursor = "pointer"; }

// jQuery animation $(document).ready(function{   $("#p-portal").slideDown("normal");    if(pocetOtazek>0) $("#p-portal-otazky-nadpis").click(function{$("#p-portal-otazky").slideToggle;});  });

// deleting variables delete output; delete outputOtazky; delete jsonRes; delete xmlPortaly; }

// FUNCTION ADDING LINK TO CITATION SERVER CITACE.COM function addCitaceCom { if(wgNamespaceNumber != 0) return;

ctAdresa = "http://www.citace.com/import.php?druh=14&nazev=" + encodeURI(wgTitle) + "&casopis_nazev=WikiLectures&misto=Praha&nakl=" + encodeURI("MEFANET") + "&rok=2008-&url=" + wgServer + wgScript + "?title=" + encodeURI(wgPageName) + "%26oldid=" + wgCurRevisionId;

addPortletLink('p-tb', ctAdresa, 'Create citation', 't-citacecom', 'Create citation by Citace.com'); document.getElementById("t-citacecom").className = "popup"; }

/* ============================== Footer ============================================== */

// FUNCTION ADDING FACEBOOK LIKE BUTTON // to the end of the article function addFbLikeButton { // check NS // only main namespace or portal if (wgNamespaceNumber != 0 && wgNamespaceNumber != 100) return false; // check main page if (wgTitle == "Main page") return false; // action ahould be "view" only if (wgAction != "view") return false; // create button fbLikeButton = document.createElement("div"); fbLikeButton.className = "fb_likebutton"; fbLikeButton.id = "fb_likebutton"; document.getElementById("content").appendChild(fbLikeButton); if (document.getElementById("catlinks")) { fbLikeButton.parentNode.insertBefore(document.getElementById("catlinks"), fbLikeButton.nextSibling); } fbLikeButton.innerHTML = ' <iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&href=' + encodeURI(window.location) + '&amp;layout=button_count&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"> '; }

// FOOTER function addLfFooter { links = document.createElement("div"); links.id = "myLfFooter"; document.getElementById("footer").appendChild(links); links.innerHTML = '<a href="http://www.mefanet.cz/index-en.php">MEFANET</a> | <a href="http://www.lf1.cuni.cz/">1st LF UK in Prague</a> | e-mail: <a href="mailto:info%40wikilectures.eu">info&#64;wikilectures.eu</a>'; }

/* =========================== Edit buttons ==================== */

// add Redirect if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png", "speedTip": "Redirect", "tagOpen": "#REDIRECT ",   "tagClose": "", "sampleText": "Page"} }

// checkuserrights if (wgUserGroups) { userrights = wgUserGroups.toString; ur_sysop = userrights.search("sysop"); } else { ur_sysop = -1; }

// spam button for sysops if ((ur_sysop != -1) && mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/1/1b/Button_miss_signature.png", "speedTip": "SPAM to talk page", "tagOpen": " \nIP blocked and reported to provider. --~", "tagClose": "", "sampleText": ""} }

/* ============================== Recent changes ====================================== */

// SHOW REAL NAMES IN RECENT CHANGES function showRealName { jmena = getElementsByClass("mw-recent-realname"); for(i=0; i<jmena.length; i++) jmena[i].style.display = "inline"; }

/* ============================== Focus at logging in ============================== */

// FOCUS FIELDS DURING LOGGING IN function focusLogIn {

// only Special:Userlogin if (wgPageName!="Special:Userlogin") return false;

// name of form that is shown jmenoForm = ""; if (document.forms["userlogin"]) jmenoForm = "userlogin"; if (document.forms["userlogin2"]) jmenoForm = "userlogin2"; if (jmenoForm=="") return false;

// identificators of fields with username and password // - log in if (document.forms[jmenoForm].elements["wpName1"]) { jmenoName = "wpName1" jmenoHeslo = "wpPassword1"; }

// - registration if (document.forms[jmenoForm].elements["wpName2"]) { jmenoName = "wpName2"; jmenoHeslo = "wpPassword2"; }

// focus if (!document.forms[jmenoForm].elements[jmenoName].value) document.forms[jmenoForm].elements[jmenoName].focus; else document.forms[jmenoForm].elements[jmenoHeslo].focus; }

/* ============================== Start! ===================================== */

// ONLY LOGGED IN USERS if (wgUserName!=null) { addOnloadHook(showRealName); if (wgCanonicalNamespace == "Category" && wgTitle) addOnloadHook(categoryHistory); } else {

// ONLY GUESTS } // end else

// EVERYONE addOnloadHook(addCitaceCom); addOnloadHook(addEdu); addOnloadHook(addFbLikeButton);

if (wgNamespaceNumber == 0 && wgTitle != "Main page" && wgAction != "markpatrolled") { var xmlPortaly; addOnloadHook(function{   getXMLHttpRequest("xmlPortaly", wgServer + "/api.php?action=query&list=backlinks&bltitle=" + wgPageName + "&blnamespace=100&format=json", "odkazujiciPortaly")  }); }

addOnloadHook(addLfFooter); addOnloadHook(focusLogIn); addOnloadHook(piskoviste);

/* */