MediaWiki:MenuChanges.js: Difference between revisions
From WikiLectures
(no Wave and no WebArchiv) |
m (typo) |
||
Line 226: | Line 226: | ||
links.id = "myLfFooter"; | links.id = "myLfFooter"; | ||
document.getElementById("footer").appendChild(links); | document.getElementById("footer").appendChild(links); | ||
links.innerHTML = 'WikiLectures, project of the medical faculties network <a href="http://www.mefanet.cz/index-en.php">MEFANET</a> • e-mail: <a href="mailto:info%40wikilectures.eu">info@wikilectures.eu</a><br /><a href="http://www.lf1.cuni.cz/en">1st LF UK</a>, <a href="http://www.lf2.cuni.cz/homepage.htm">2nd LF UK</a>, <a href="http://www.lf3.cuni.cz/en/index.html"> | links.innerHTML = 'WikiLectures, project of the medical faculties network <a href="http://www.mefanet.cz/index-en.php">MEFANET</a> • e-mail: <a href="mailto:info%40wikilectures.eu">info@wikilectures.eu</a><br /><a href="http://www.lf1.cuni.cz/en">1st LF UK</a>, <a href="http://www.lf2.cuni.cz/homepage.htm">2nd LF UK</a>, <a href="http://www.lf3.cuni.cz/en/index.html">3rd LF UK</a> in Prague • <a href="http://www.lfp.cuni.cz/switch.php?lid=EN">LF UK in Pilsen</a> • <a href="http://www.med.muni.cz/index.php?change=en&id=1">LF MU in Brno</a> • <a href="http://www.lf.upol.cz/en/">LF UP in Olomouc</a> • <a href="http://www.upjs.sk/en/faculty-of-medicine/">LF UPJS in Kosice</a> • <a href="http://www.fmed.uniba.sk/index.php?id=633">LF UK in Bratislava</a> • <a href="http://eng.jfmed.uniba.sk/">JLF UK in Martin</a>'; | ||
} | } | ||
Revision as of 14:06, 11 July 2011
/* <pre> */
/* ============== MENU CHANGES ===============================
author: Petr Kajzar [[User:Slepi]]
date: 10/2009, last update 06/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');
}
// 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 = '<div style="text-align: center;">';
// MEFANET
eduPortaly += '<br/><a href="http://www.mefanet.cz/index-en.php" class="popup"><img src="http://www.wikiskripta.eu/images/2/22/Mefanet_logo.png" alt="MEFANET" width="120" height="27" /></a><br />';
// Facebook
eduPortaly += '<br /><a href="https://www.facebook.com/pages/WikiLectures/218186098203607" class="popup"><img src="http://www.wikilectures.eu/images/6/6e/WikiFacebook.png" alt="Facebook" width="120" height="27" /></a><br />';
// close section
eduPortaly += '</div>';
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;
}
// check user rights - bureaucrat
if (wgUserGroups) {
userrights = wgUserGroups.toString();
ur_bureaucrat = userrights.search("bureaucrat");
} else {
ur_bureaucrat = -1;
}
if (ur_bureaucrat != -1) {
addPortletLink('p-extern-url', 'http://www.wikiskripta.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 = '<br /><img src="http://upload.wikimedia.org/wikipedia/commons/b/bb/Crystal_Project_kedit.png" width="16" height="16"> Join us! If this article is incomplete, inaccurate or false, <a href="' + wgServer + wgScript + '?title=' + wgPageName + '&action=edit">correct it</a>! Or <a href="' + wgServer + wgScript + '?title=' + wgFormattedNamespaces[1] + ':' + wgPageName + '&action=edit§ion=new">tell us</a> about the shortcomings.<br />';
// link to fb
fbShareButton.innerHTML += '<a href="http://www.facebook.com/sharer.php?u=' + encodeURI(wgServer + wgScript + '/' + wgPageName) + '&t=' + encodeURI(wgTitle) + '" class="popup"><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><br />';
}
// FOOTER
function addLfFooter() {
links = document.createElement("div");
links.id = "myLfFooter";
document.getElementById("footer").appendChild(links);
links.innerHTML = 'WikiLectures, project of the medical faculties network <a href="http://www.mefanet.cz/index-en.php">MEFANET</a> • e-mail: <a href="mailto:info%40wikilectures.eu">info@wikilectures.eu</a><br /><a href="http://www.lf1.cuni.cz/en">1st LF UK</a>, <a href="http://www.lf2.cuni.cz/homepage.htm">2nd LF UK</a>, <a href="http://www.lf3.cuni.cz/en/index.html">3rd LF UK</a> in Prague • <a href="http://www.lfp.cuni.cz/switch.php?lid=EN">LF UK in Pilsen</a> • <a href="http://www.med.muni.cz/index.php?change=en&id=1">LF MU in Brno</a> • <a href="http://www.lf.upol.cz/en/">LF UP in Olomouc</a> • <a href="http://www.upjs.sk/en/faculty-of-medicine/">LF UPJS in Kosice</a> • <a href="http://www.fmed.uniba.sk/index.php?id=633">LF UK in Bratislava</a> • <a href="http://eng.jfmed.uniba.sk/">JLF UK in Martin</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": "{{Spam}} \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);
/* </pre> */