User:Sebmol/addLogsLink.js

//*********************************************************************** // addLogsLink // by en:User:Thebainer // adds a 'logs for this page' link to the navigation bar // if the page is a user's page, talk page or subpage, the link will go to logs for the user instead // übernommen 1.6.2006 in dieser Version // siehe auch w:en:Wikipedia:WikiProject User scripts/Scripts/Logs link // w:de:Benutzer:PDD 1.6.2006 : Adaptierung für de.wikipedia, Zusatzlog für User: // w:de:Benutzer:PDD 2.6.2006 : optional Benutzerbeiträge für User: // User:sebmol 22 August 2006 : adaptation for Wikiversity //***********************************************************************

// function addLogsLink { // -  // Language support, adapted from godmode-light.js   // - var pagetitleRe=/[^:]*:\/\/en\.wikiversity\.org\/(wiki\/|w\/index\.php\?title=)([^&?]*)/; var urlstub = "http://en.wikiversity.org/w/index.php?title=Special%3ALog"; var contribstub = "http://en.wikiversity.org/wiki/Special:Contributions/"; var userpage = "User:"; var usertalkpage = "User_talk:"; var specialpage = "Special"; var regDropSubpages = /[User|User_talk]:([^&?\/]*)[\/]?.*/; var pagelogtext = "Page Log"; var userlogtext1 = "User Log 1"; var userlogtext2 = "User Log 2"; var usercontribtext = "User Contributions";  // im de.original: Benutzerbeiträge //  var userstatstext = "User:Stats"; //  var userstimmrechttext = "User:Stimmrecht"; switch (document.getElementsByTagName('html')[0].lang) { case 'fr': var pagetitleRe=/[^:]*:\/\/fr\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?]*)/; var urlstub = "http://fr.wikipedia.org/w/index.php?title=Special%3ALog"; var contribstub = "http://fr.wikipedia.org/wiki/Special:Contributions/"; var userpage = "Utilisateur:"; var usertalkpage = "Discussion_Utilisateur:"; var specialpage = "Special"; var regDropSubpages = /[Utilisateur|Discussion_Utilisateur]:([^&?\/]*)[\/]?.*/; break; case 'de': var pagetitleRe=/[^:]*:\/\/de\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?]*)/; var urlstub = "http://de.wikipedia.org/w/index.php?title=Spezial%3ALog"; var contribstub = "http://de.wikipedia.org/wiki/Spezial:Contributions/"; var userpage = "Benutzer:"; var usertalkpage = "Benutzer_Diskussion:"; var specialpage = "Spezial"; var regDropSubpages = /[Benutzer|Benutzer_Diskussion]:([^&?\/]*)[\/]?.*/; break; case 'es': var pagetitleRe=/[^:]*:\/\/es\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?]*)/; var urlstub = "http://es.wikipedia.org/w/index.php?title=Especial%3ALog"; var contribstub = "http://es.wikipedia.org/wiki/Especial:Contributions/"; var userpage = "Usuario:"; var usertalkpage = "Usuario_Discusi%C3%B3n:"; var specialpage = "Especial"; var regDropSubpages = /[Usuario|Usuario_Discusi%C3%B3n]:([^&?\/]*)[\/]?.*/; break; case 'it': var pagetitleRe=/[^:]*:\/\/it\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?]*)/; var urlstub = "http://it.wikipedia.org/w/index.php?title=Speciale%3ALog"; var contribstub = "http://it.wikipedia.org/wiki/Speciale:Contributions/"; var userpage = "Utente:"; var usertalkpage = "Discussioni_utente:"; var specialpage = "Speciale"; var regDropSubpages = /[Utente|Discussioni_utente]:([^&?\/]*)[\/]?.*/; break; case 'pt': var pagetitleRe=/[^:]*:\/\/pt\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?]*)/; var urlstub = "http://pt.wikipedia.org/w/index.php?title=Especial%3ALog"; var contribstub = "http://pt.wikipedia.org/wiki/Especial:Contributions/"; var userpage = "Usu%C3%A1rio:"; var usertalkpage = "Usu%C3%A1rio_Discuss%C3%A3o:"; var specialpage = "Especial"; var regDropSubpages = /[Usu%C3%A1rio|Usu%C3%A1rio_Discuss%C3%A3o]:([^&?\/]*)[\/]?.*/; break; } // get page title ptitle = pagetitleRe.exec(decodeURI(location.href))[2].split('_').join(' '); // get tabs tabs = document.getElementById('p-tb').getElementsByTagName('ul')[0]; // if this is a user, show the logs for the user (in addition to the page log) if ((window.location.href.indexOf(userpage) > -1) || (window.location.href.indexOf(usertalkpage) > -1)) { user = regDropSubpages.exec(ptitle)[1]; url = urlstub + "&user=" + user; l = addlilink(tabs, url, userlogtext1, "pt-u1logs"); url = urlstub + "&page=" + userpage + user; l = addlilink(tabs, url, userlogtext2, "pt-u2logs"); if (addusercontriblink) { if (document.getElementById("t-contributions")) document.getElementById("t-contributions").getElementsByTagName("a")[0].innerHTML = usercontribtext; else { url = contribstub + user; l = addlilink(tabs, url, usercontribtext, "t-contributions"); }    //url = "http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?user=" + user //     + "&dbname=" + document.getElementsByTagName('html')[0].lang + "wiki_p"; //l = addlilink(tabs, url, userstatstext, "t-userstats"); //url = "http://tools.wikimedia.de/~gunther/stimmberechtigung.php?user=" + user; //l = addlilink(tabs, url, userstimmrechttext, "t-stimmrecht"); } }  // show the page log (always) if ((window.location.href.indexOf(specialpage + ":") == -1) && (window.location.href.indexOf(specialpage + "%3A")) == -1) { url = urlstub + "&page=" + ptitle; l = addlilink(tabs, url, pagelogtext, "pt-logs"); } } addOnloadHook(addLogsLink); // HELPER FUNCTIONS function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) {  if(key && title) {   ta[id] = [key, title]; }  else if(key) {   ta[id] = [key, '']; }  else if(title) {   ta[id] = ['', title]; } }  // re-render the title and accesskeys from existing code in wikibits.js  akeytt; return li; } //