MediaWiki:Common.js : Diferéncia entre lei versions

Contengut suprimit Contengut apondut
Spacebirdy (discussion | contribucions)
m iconas
Cedric31 (discussion | contribucions)
Cap resum de modificació
Linha 98 :
return cookieValue;
}
 
// Recupèra pròpriament lo contengut textual d'un nos e de sos noses descendents
// Copyright Harmen Christophe, http://openweb.eu.org/articles/validation_avancee, CC
function getTextContent(oNode) {
if (typeof(oNode.textContent)!="undefined") {return oNode.textContent;}
switch (oNode.nodeType) {
case 3: // TEXT_NODE
case 4: // CDATA_SECTION_NODE
return oNode.nodeValue;
break;
case 7: // PROCESSING_INSTRUCTION_NODE
case 8: // COMMENT_NODE
if (getTextContent.caller!=getTextContent) {
return oNode.nodeValue;
}
break;
case 9: // DOCUMENT_NODE
case 10: // DOCUMENT_TYPE_NODE
case 12: // NOTATION_NODE
return null;
break;
}
var _textContent = "";
oNode = oNode.firstChild;
while (oNode) {
_textContent += getTextContent(oNode);
oNode = oNode.nextSibling;
}
return _textContent;
}
 
 
 
Linha 262 ⟶ 293:
* Copyright 2006, Marc Mongenet. Licéncia GPL e GFDL.
*
* The function looks for <span class="editseccioneditsection">, and move them
* at the end of their parent and display them inline in small font.
* var oldEditseccionLinks=true disables the function.
Linha 275 ⟶ 306:
var span=list[i].firstChild
if (span.className == "editseccioneditsection")
{
span.style.fontSize = "xx-small";
Linha 288 ⟶ 319:
try
{
if (!(typeof oldEditseccionLinksoldEditsectionLinks == 'undefined' || oldEditseccionLinksoldEditsectionLinks == false)) return;
process(document.getElementsByTagName("h2"));
process(document.getElementsByTagName("h3"));
Linha 460 ⟶ 491:
buttonImage: 'http://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Geographylogo.svg/18px-Geographylogo.svg.png'
}
 
/**
* Aficha un modèl Informacion sus la pagina de telecargament de fichièrs [[Especial:Telecargament]]
* Vejatz tanben [[MediaWiki:Onlyifuploading.js]]
*/
 
function includePage(name) {
document.write('<script type="text/javascript" src="' + wgScript + '?title='
+ name + '&action=raw&ctype=text/javascript&dontcountme=s"><\/script>'); // smaxage=3600
}
 
if (wgCanonicalSpecialPageName == "Upload") {
includePage("MediaWiki:Onlyifuploading.js");
}
 
/**
Linha 503 ⟶ 549:
leftlink = document.createElement("a");
leftlink.href = "javascript:toggleImage("+i+","+j+","+(j-1)+");";
leftlink.innerHTML="?";
} else {
leftlink = document.createElement("span");
Linha 511 ⟶ 557:
rightlink = document.createElement("a");
rightlink.href = "javascript:toggleImage("+i+","+j+","+(j+1)+");";
rightlink.innerHTML="?";
} else {
rightlink = document.createElement("span");
Linha 531 ⟶ 577:
}
addOnloadHook(imageGroup);
 
 
/**
Linha 765 ⟶ 812:
addOnloadHook(rewritePageH1bis);
 
/**
* aplicacion de [[Wikipèdia:Presa de decision/Sistèma d'amagatal]]
* un <span class="noarchive"> a l'entorn del ligam l'empacha d'èsser pres en compte
* per aqueste unicament
* un no_external_cache=true dins un monobook personal desactiva l'escript
*/
 
addOnloadHook(function () {
 
if (wgNamespaceNumber == 0) {
if ((typeof no_external_cache != "undefined") && (no_external_cache)) return;
addcache();
}
function addcache() {
var external_links;
if (document.getElementsByClassName) {
external_links = document.getElementsByClassName('external');
} else {
external_links = getElementsByClass('external',document.getElementById("bodyContent"),'a');
}
 
for( i = 0;i < external_links.length;i++)
{
var chemin = external_links[i].href;
 
if(chemin.indexOf("http://wikiwix.com/cache/")==-1 && chemin.indexOf("http://web.archive.org/web/*/")==-1 && chemin.indexOf("wikipedia.org")==-1 && chemin.indexOf("wikimedia.org")==-1 && chemin.indexOf("stable.toolserver.org")==-1)
{
var li = external_links[i].parentNode;
if (li.className == "noarchive") continue;
var depth = 0;
while ((depth < 3) && (li.tagName != "OL") && (li.parentNode != null)) {
li = li.parentNode;
depth++;
}
if (li.tagName != "OL" || !(hasClass(li, 'references')) ) continue;
var titre = getTextContent(external_links[i]);
var last = document.createElement("small");
last.setAttribute("class", "cachelinks");
last.style.color = "#3366BB";
last.appendChild(document.createTextNode("\u00a0["));
insertAfter(external_links[i].parentNode, last, external_links[i]);
var link = document.createElement("a");
link.setAttribute("href", "http://wikiwix.com/cache/?url=" + chemin.replace(/&/g, "%26"));
link.setAttribute("title", "archive de "+ titre);
link.appendChild(document.createTextNode("archive"));
link.style.color = "#3366BB";
last.appendChild(link);
last.appendChild(document.createTextNode("]"));
}
}
}
}
);
 
/**
* Aplicacion de [[Wikipèdia:Presa de decision/Ligam interprojècte]]
* Còpia los ligams interprojèctes del modèl {{Autres projèctes}}
* dins lo menut en colomna d'esquèrra.
* remove_other_projects = true; dins lo monobook personal per activar
* en mai la supression del modèl {{Autres projèctes}} en bas dels articles.
* no_other_projects = true; dins lo monobook personal per desactivar
* entièrament l'escript e l'apondon dins la colomna d'esquèrra.
*/
 
function autresProjets() {
if ((typeof no_other_projects != "undefined") && (no_other_projects)) return;
if(!(wgNamespaceNumber==0)) return;
if(!(wgAction=="view")) return;
var div = document.getElementById('autres_projets');
if(!div) return;
var list = div.getElementsByTagName('LI');
var newlist = document.createElement("UL");
for (var i = 0; i < list.length ; i++) {
list.link = list[i].getElementsByTagName('A')[0];
list.text = list.link.getElementsByTagName('SPAN')[0];
var newlistitem = document.createElement("LI");
var newlink = document.createElement("A");
var newlinktext = document.createTextNode(getTextContent(list.text));
newlink.appendChild(newlinktext);
newlink.title=getTextContent(list.link);
newlink.href=list.link.href;
newlistitem.appendChild(newlink);
newlist.appendChild(newlistitem);
}
var interProject = document.createElement("DIV");
interProject.className = 'portlet';
interProject.innerHTML = '<h5>Autres projets<\/h5><div class="pBody"><ul>'+newlist.innerHTML+'</ul></div>';
insertAfter(document.getElementById('column-one'),interProject,document.getElementById('p-tb'));
if ((typeof remove_other_projects != "undefined") && (remove_other_projects)) {
document=document.getElementById('bodyContent').removeChild(div);
}
}
addOnloadHook(autresProjets);
 
/**************************************************************/
Linha 1 218 ⟶ 1 362:
}
addLoadEvent(urgentSynchroneJsLoad);
/* Permet d'afichar un compte a rebors sus una pagina amb lo modèl [[Modèl:Compte a rebors]] */
/* Plyd - 3 de febrièr de 2009 */
function Rebours() {
if(wgNamespaceNumber==0) return;
try {
if (document.getElementById("rebors")) {
destime = document.getElementById("rebors").title.split(";;");
Ara = (new Date).getTime();
Future = new Date(Date.UTC(destime[0], (destime[1]-1), destime[2], destime[3], destime[4], destime[5])).getTime();
Diff = (Future-Maintenant);
if (Diff < 0) {Diff = 0}
TempsDemorantJ = Math.floor(Diff/(24*3600*1000));
TempsDemorantH = Math.floor(Diff/(3600*1000)) % 24;
TempsDemorantM = Math.floor(Diff/(60*1000)) % 60;
TempsDemorantS = Math.floor(Diff/1000) % 60;
TempsDemorant = "" + destime[6] + " ";
if (TempsDemorantJ == 1) {
TempsDemorant = TempsDemorant + TempsDemorantJ + " jorn ";
} else if (TempsDemorantJ > 1) {
TempsDemorant = TempsDemorant + TempsDemorantJ + " jorns ";
}
TempsDemorant = TempsDemorant + TempsDemorantH + " h " + TempsDemorantM + " min " + TempsDemorantS + " s";
document.getElementById("rebors").innerHTML = TempsDemorant;
setTimeout("Rebors()", 1000)
}
} catch (e) {}
}
addLoadEvent(Rebours);
 
 
/* Desactivacion de la MESA EN GRAS DE L'ONGLET MODIFICAR (copiat de en:)
E de la MESA EN BLANC SUS FONS BLAU DE L'ONGLET MODIFICAR (copiat de pl:) */
if (window.BotonModificar==true)
{
importStylesheet('MediaWiki:AncianBotonModificar.css');
}
 
/* WikiForm per la generacion facilitat de modèls */
/* Plyd - 10/02/2008 */
if (document.getElementById("WikiForm")) {
importScript("MediaWiki:Gadget-WikiForm.js");
}
 
 
/* foncionetas practicas - Darkoneko, 09/01/2008 */
 
//crèa un ligam e o retorna.
//lo parametre onclick es facultatiu.
function createAdressNode(href, texte, onclick) {
var a = document.createElement('a')
a.href = href
a.appendChild(document.createTextNode( texte ) )
if(arguments.length == 3) { a.setAttribute("onclick", onclick ) }
 
return a
}
 
//Crèa un cookie. existissiá pas qu'una version dedicada a l'acuèlh. Aquesta es mai generic
//lo parametre durada es en jorns
function setCookie(nom, valor, durada ) {
var expDate = new Date()
expDate.setTime(expDate.getTime() + ( durada * 24 * 60 * 60 * 1000))
document.cookie = nom + "=" + escape(valor) + ";expires=" + expDate.toGMTString() + ";path=/"
}
 
/*
/!\ incompatible amb IE dins sa forma actuala /!\
 
get_editcounts() TODO :
 
*/
function get_editcounts(noms) {
var http_request;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http_request = new XMLHttpRequest()
if (http_request.overrideMimeType)
http_request.overrideMimeType('text/xml')
} else {
alert("la partida editcount de addContribLinkNearTalkPageInContributions es pas compatibla internet explorer")
return;
/*
if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
 
 
*/
}
var address = "/w/api.php?format=xml&action=query&list=users&usprop=editcount&ususers=" + noms.join('|')
http_request.open('GET', address , false)
http_request.send(null)
 
var users = http_request.responseXML.documentElement.getElementsByTagName("user")
var usersEditCount =new Array() //tablèu de las valors (nom user => editcount)
for (var a=0 ; a < users.length ; a++) {
//aparentament impossible de far de claufs nomenadas.
if( typeof( users[ a ].attributes['editcount'] ) != 'undefined' ) {
usersEditCount[ users[ a ].attributes['name'].value ] = users[a].attributes['editcount'].value
} else {
usersEditCount[ users[ a ].attributes['name'].value ] = 'N/A'
}
}
return usersEditCount
}
 
 
/* /foncionetas practicas */