MediaWiki:MenuChanges.js

/* */

/* ============== MENU CHANGES =============================== author:       Petr Kajzar User:Slepi date:         10/2009, last update 09/2011 documentation: -- 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, 'Category history', 't-cathistory', 'History of changes of the articles in this category'); }

function commonsFileUpload { addPortletLink('p-tb', 'http://commons.wikimedia.org/wiki/Special:UploadWizard', 'Upload to Commons', 't-commonsfile', 'Upload a file to Wikimedia Commons', 'c', document.getElementById('t-specialpages')); }

function addPrintablePDFVersion { addPortletLink('p-coll-print_export', document.getElementById("coll-download-as-rl").getElementsByTagName("a")[0].href, 'Print version (PDF)', 't-printPDF', 'Print to PDF'); }

function addPrintPDFHelp { addPortletLink('p-coll-print_export', wgServer + wgScript + '/Help:Books', 'Create PDF - help', 't-printhelp', 'Help making collections, books and PDF files'); }

// FUNKCE PŘIDÁVAJÍCÍ KRÁTKOU VERZI URL ČLÁNKU DO MENU function shortURL { if(wgNamespaceNumber in (['0', '2','100','101','102','103']) == false) return; addPortletLink('p-tb', 'JavaScript:prompt("URL:", "http://" + top.location.host + "/article-" + wgArticleId)', 'Short URL', 'short_url', 'Zobrazení krátké verze odkazu na článek'); }

// 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); // check user rights - patrol if (wgUserGroups) { userrights = wgUserGroups.toString; ur_patrol = userrights.search("patrol"); } else { ur_patrol = -1; }

// open section eduPortaly = ' ';

// WikiSkripta eduPortaly += '  ';

// MEFANET eduPortaly += '  ';

// Facebook eduPortaly += '  ';

// Twitter eduPortaly += '  ';

// close section eduPortaly += ' ';

novaSekce.innerHTML = eduPortaly; }

// FUNCTION ADDING LIST OF RELATED PORTALS AND EXAM QUESTIONS function odkazujiciPortaly {

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

var jsonRes = xmlPortaly.responseText;

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

// portals to output pocetPortalu = jsonObj.query.backlinks.length; if(pocetPortalu == 0) return; // do not continue without portals

for(i=0;i<pocetPortalu;i++) { // name of portal aktPortal = jsonObj.query.backlinks[i].title; aktPortalNazev = aktPortal.replace("Portal:", "");

// test of exam questions var zjisteniOtazek = new RegExp("(exam|Exam|questions|Questions)");

if(zjisteniOtazek.test(aktPortalNazev)) { idPortalu = "p-rel-exam"; pocetOtazek++; } else { idPortalu = "p-rel-portals"; pocetSkutPortalu++; }

// add portal to menu addOnloadHook(function{     addPortletLink(idPortalu, wgServer + wgScript + '/' + aktPortal, aktPortalNazev, , aktPortalNazev, );    }); }

// portals if(pocetSkutPortalu > 0) { $j(document).ready(function {     $j("#p-rel-portals").slideDown;    }); }

// unfold portals $j(document).ready(function {   if(document.getElementById("p-rel-portals").className.indexOf("collapsed") != -1) {      $j('#mw-panel > div#p-rel-portals').toggleClass('collapsed').toggleClass('expanded').find('div.body').slideToggle('fast');    }  });

// exam questions if(pocetOtazek>0) { $j(document).ready(function {     $j("#p-rel-exam").slideDown;    }); }

// delete variables 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"; }

// FUNCTION ADDING LINKS TO SYSOPS AND ADMINS function addExtAdminLinks {

// check user rights - patrol if (wgUserGroups) { userrights = wgUserGroups.toString; ur_patrol = userrights.search("patrol"); } else { ur_patrol = -1; }

if (ur_patrol != -1) { addPortletLink('p-extern-url', 'http://www.wikilectures.eu/otrs', 'OTRS Mail', 't-otrs', 'Editorial mail in OTRS system'); }

}

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

// FUNCTION ADDING "Share Button" FROM FACEBOOK // to the end of an article // and links to stimulate editors function addFbShareButton {

// check NS // only main NS, portal or studium guide if (wgNamespaceNumber != 0 && wgNamespaceNumber != 100 && wgTitle.indexOf("guide") == -1) return false;

// check main page if (wgTitle == wgMainPageTitle) return false;

// check action if (wgAction != "view") return false;

// create button fbShareButton = document.createElement("div"); fbShareButton.className = "fb_sharebutton"; fbShareButton.id = "fb_likebutton"; document.getElementById("content").appendChild(fbShareButton);

if (document.getElementById("catlinks")) { fbShareButton.parentNode.insertBefore(document.getElementById("catlinks"), fbShareButton.nextSibling); }

// link to editations fbShareButton.innerHTML = '  Join us! If this article is incomplete, inaccurate or false, correct it! Or tell us</a> about the shortcomings. ';

// link to fb fbShareButton.innerHTML += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/Facebook_icon.svg/16px-Facebook_icon.svg.png" alt="Facebook - icon" style="border: none;" /> Share</a> ';

}

// FOOTER function addLfFooter { links = document.createElement("div"); links.id = "myLfFooter"; document.getElementById("footer").appendChild(links); links.innerHTML = 'WikiLectures, project of the medical faculties network MEFANET</a> • ISSN 1804-9885 • e-mail: info&#64;wikilectures.eu</a>'; }

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

// add Table if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png", "speedTip": "Insert a table", "tagOpen": '\n{| class="wikitable"\n', "tagClose": "\n|}\n", "sampleText": " ! header cell 1\n ! header cell 2 \n |- \n | row 1 cell 1 \n | row 1 cell 2 \n |- \n | row 2 cell 1 \n | row 2 cell 2"} }

// 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_patrol = userrights.search("patrol"); } else { ur_patrol = -1; }

// spam button for patrols if ((ur_patrol != -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": ""} }

/* ============================== 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 fucntions ===================================== */

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

// ONLY ANONYMOUS USERS

} // end else

// START EVERYTIME addOnloadHook(addCitaceCom); addOnloadHook(addEdu); addOnloadHook(addFbShareButton); if (wgNamespaceNumber == 0 && wgAction=="view") addOnloadHook(addPrintablePDFVersion); addOnloadHook(addPrintPDFHelp);

if (wgNamespaceNumber == 0 && wgTitle != wgMainPageTitle && 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); addOnloadHook(shortURL);

/* */