Utilisateur:Gonioul/navigationsupp.js
Un article de Wikipédia, l'encyclopédie libre.
Note : Après avoir sauvegardé, vous devez forcer le rechargement de la page pour voir les changements : Mozilla / Konqueror / Firefox : Shift-Ctrl-R, IE / Opera : Ctrl-F5, Safari : Cmd-R.
// <pre><nowiki> // Source: Dake + Goto function NSclientSideGet(url, req, callback) { if ((req != null && callback == null) ||(req == null && callback != null)) { return("I need req && callback defined or not"); } // For Safari, Firefox, and other non-MS browsers if (window.XMLHttpRequest) { try { req = new XMLHttpRequest(); } catch (e) { req = false; } } else if (window.ActiveXObject) { // For Internet Explorer on Windows try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { req = false; } } } if (req) { if (callback == null) { // Synchronous request, wait till we have it all req.open('GET', url, false); req.send(null); return (req.responseText); } else { // Asynchronous request, set callback and go req.open('GET', url, true); req.onreadystatechange = callback; req.send(null); return (null); } } else { return ("XMLHTTPRequest not supported"); } } //function NSclientSideGetResponse() //{ // if (NSreq.readyState != 4) // return; // return(NSreq.responseText); //} function NSTodayDate() { var m = new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre") var today = new Date() var day = today.getDate() var year = today.getYear() if (year < 2000) year += 1900 return (day + " " + m[today.getMonth()] + " " + year) } function getWikiDefCon() { var nswikidefcon = NSclientSideGet("http://fr.wikipedia.org/wiki/Modèle:WikiDefcon"); if (nswikidefcon != null) { var nswdctable = new RegExp('.*<strong>WikiDefcon</strong> ([1-5]).*') var nswdc = nswdctable.exec(nswikidefcon) if (nswdc != null && nswdc.length >= 1) { return (nswdc[1]) } } } function getWikiDefConImage() { var nswikidefcon = NSclientSideGet("http://fr.wikipedia.org/wiki/Modèle:WikiDefcon") if (nswikidefcon != null) { var nswdctable = new RegExp('.*"(http://upload.wikimedia.org/.*/Dc_([^ "]*)\\.png)".*') var nswdc = nswdctable.exec(nswikidefcon) if (nswdc != null && nswdc.length >= 1) { return (nswdc[1]) } } } function NavigationSupp() { var a = document.getElementById("p-Navigation"); if (!a) { a = document.getElementById("p-navigation"); } if (a) { b = a.getElementsByTagName("ul"); if(b.length > 0) { var startUrl = '/w/index.php?title=' var endUrl = '&action=purge' // liste des URLs var urls = new Array() var labels = new Array() urls.push("Wikipédia:Le Bistro/" + NSTodayDate()) labels.push("Bistro") urls.push("Wikipédia:Bot/Requêtes") labels.push("Bot Req") urls.push("Wikipédia:Vandalisme en cours/Alertes en cours") labels.push("Vandalisme") if (location.href.indexOf('/Special:Watchlist') != -1 || (location.href.indexOf('/Special:Recentchanges') != -1 && location.href.indexOf('/Special:Recentchangeslinked') == -1) ) { urls.push("Modèle:WikiDefcon") //labels.push('WikiDefcon ' + getWikiDefCon()) //labels.push('<img src="' + getWikiDefConImage() + '" title="Defcon" id="p-defcon" width="50" height="100" border="1">') labels.push('<img src="" title="Defcon" id="p-defcon" width="50" height="100" border="1">') } b[0].innerHTML = b[0].innerHTML + "<br/>" for (var i=0;i<urls.length;i++) { tableHTML = '<li><a href="' + startUrl + urls[i] + endUrl + '">' + labels[i] + "</a>" b[0].innerHTML += tableHTML } var defcon = document.getElementById("p-defcon") if (defcon != null) { defcon.src = getWikiDefConImage() } } } } addLoadEvent(NavigationSupp); // </nowiki></pre>