MediaWiki:Common.js

Une nouvelle de Wikinews, la source d'informations que vous pouvez écrire.

Note : après avoir publié vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

  • Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou appuyez sur Ctrl + F5 ou Ctrl + R (⌘ + R sur un Mac).
  • Google Chrome : appuyez sur Ctrl + Maj + R (⌘ + Shift + R sur un Mac).
  • Internet Explorer / Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
  • Opera : appuyez sur Ctrl + F5.
wgfrwikinews_CommonJsVersion = "20140114001";
 
/**
 * Diverses fonctions manipulant les classes
 * Utilise des expressions régulières et un cache pour de meilleures perfs
 * isClass et whichClass depuis http://fr.wikibooks.org/w/index.php?title=MediaWiki:Common.js&oldid=140211
 * hasClass, addClass, removeClass et eregReplace depuis http://drupal.org.in/doc/misc/drupal.js.source.html
 * surveiller l'implémentation de .classList http://www.w3.org/TR/2008/WD-html5-diff-20080122/#htmlelement-extensions
 */

// Récupère proprement le contenu textuel d'un nœud et de ses nœuds descendants
// 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;
    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;
  }
  var _textContent = "";
  oNode = oNode.firstChild;
  while (oNode) {
    _textContent += getTextContent(oNode);
    oNode = oNode.nextSibling;
  }
  return _textContent;
}

/**
 * insertAfter : insérer un élément dans une page
 */
function insertAfter(parent, node, referenceNode)
{ parent.insertBefore(node, referenceNode.nextSibling); }

function isClass(element, classe) {
    return hasClass(element, classe);
}
 
function whichClass(element, classes) {
    var s=" "+element.className+" ";
    for(var i=0;i<classes.length;i++)
        if (s.indexOf(" "+classes[i]+" ")>=0) return i;
    return -1;
}
 
function hasClass(node, className) {
  if (node.className == className) {
    return true;
  }
  var reg = new RegExp('(^| )'+ className +'($| )')
  if (reg.test(node.className)) {
    return true;
  }
  return false;
}
 
function addClass(node, className) {
    if (hasClass(node, className)) {
        return false;
    }
    node.className += ' '+ className;
    return true;
}
 
function removeClass(node, className) {
  if (!hasClass(node, className)) {
    return false;
  }
  node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className);
  return true;
}
 
function eregReplace(search, replace, subject) {
    return subject.replace(new RegExp(search,'g'), replace);
}


// ============================================================
// BEGIN Enable multiple onload functions

// setup onload functions this way:
// aOnloadFunctions[aOnloadFunctions.length] = function_name; // without brackets!

if (!window.aOnloadFunctions) {
  var aOnloadFunctions = new Array();
}

window.onload = function() {
  if (window.aOnloadFunctions) {
    for (var _i=0; _i<aOnloadFunctions.length; _i++) {
      aOnloadFunctions[_i]();
    }
  }
}

// END Enable multiple onload functions
// ============================================================
function addLoadEvent(func) 
{
  if (window.addEventListener) 
    window.addEventListener("load", func, false);
  else if (window.attachEvent) 
    window.attachEvent("onload", func);
}

/* </pre>

=== Navigation interprojet ===

<pre>*/


/*
 * Chargement des styles Agora.
 */
if( [
	0,  1, // (Discussion) principal
	2, 	3, // (Discussion) Utilisateur:
	4, // Wikinews:
	10, // Modèle:
	12, // Aide:
	106, // Dossier:
].indexOf(mw.config.get('wgNamespaceNumber')) >= 0 ) {
    mw.loader.load( 'mediawiki.ui' );
}


// Initialisation de la navigation interprojets (code adapté de de:wikt:Mediawiki:monobook.js)

 function iProject() {
  if (document.getElementById("interProject")) {
   var iProject = document.getElementById("interProject").innerHTML;
   var interProject = document.createElement("div");
   interProject.style.marginTop = "0.7em";
   interProject.innerHTML = '<h5>Autres projets<\/h5><div class="pBody">'+iProject+'<\/div>';
   document.getElementById("p-tb").appendChild(interProject);
  }
 }
 $(iProject);

// Navigation interprojets

/* </pre>

=== Caractères spéciaux ===
<pre> */

/**
 * Caractères spéciaux
 *
 * Ajouter un menu pour choisir des sous-ensembles de caractères spéciaux.
 * Ecrit par Zelda, voir sur [[Utilisateur:Zelda/Edittools.js]].
 * Remplace l'ancienne fonction par une variante plus rapide.
 */
 
/**
 * Ajoute un menu déroulant permettant de choisir un jeu de caractères spéciaux
 * Les caractères spéciaux sont définis dans Mediawiki:Edittools
 */
function addCharSubsetMenu() {
  var specialchars = document.getElementById('specialcharsets');
  if (!specialchars) return;
 
  // Construction du menu de selection
  var charSubsetSelect = document.createElement("select");
  charSubsetSelect.setAttribute("style", "display:inline");
  charSubsetSelect.onchange = function () { chooseCharSubset(this.selectedIndex); };
 
  // Ajout des options au menu
  var p = document.getElementById('specialcharsets').getElementsByTagName('p');
  for (var i = 0; i < p.length ; i++) {
    var opt = document.createElement("option");
    var txt = document.createTextNode(p[i].title);
    opt.appendChild(txt);
    charSubsetSelect.appendChild(opt);
  }
 
  specialchars.insertBefore(charSubsetSelect, specialchars.childNodes[0]);
 
  /* default subset - try to use a cookie some day */
  chooseCharSubset(0);
}
 
/**
 * Affichage du jeu de caractères sélectionné
 */
function chooseCharSubset(index) {
  var p = document.getElementById('specialcharsets').getElementsByTagName('p');
  for (var i = 0; i < p.length ; i++) {
    // Initialisation du jeu de caractères sélectionné
    if (i == index) {
    	initializeCharSubset(p[i]);
    }
    // Affichage du jeu sélectionné, masquage des autres
    p[i].style.display = i == index ? 'inline' : 'none';
    p[i].style.visibility = i == index ? 'visible' : 'hidden';
  }
}
 
/**
 * Initialisation du jeu de caractères sélectionné
 * Paramètre : paragraphe contenant le jeu à initialiser. Initialise tous les
 * caractères contenus dans les sous-spans du paragraphe
 */
function initializeCharSubset(p) {
  // recherche des sous-elements de type span à traiter
  var spans = p.getElementsByTagName("span");
  if (!spans) return;
 
  // regexp pour echapper les caractères JS spéciaux : \ et '
  var re = new RegExp("(\\\\|')", "g");
  // gestion du caractère d'échappement '\'
  var escapeRe = new RegExp("[^\\\\](\\\\\\\\)*\\\\$", "g");
  var unescapeRe = new RegExp("\\\\\\\\", "g");
 
  // traitement des spans du paragraphe
  for (var j = 0; j < spans.length; j++) {
    // span deja traité
    if (spans[j].childNodes.length == 0 || spans[j].childNodes[0].nodeType != 3) continue;
 
    // On parse le contenu du span
    var chars = spans[j].childNodes[0].nodeValue.split(" ");
    for (var k = 0; k < chars.length; k++) {
      var a = document.createElement("a");
      var tags = chars[k];
 
      // regroupement des mots se terminant par un espace protégé par un \
      while (k < chars.length && chars[k].match(escapeRe)) {
      	k++;
	tags = tags.substr(0, tags.length - 1) + " " + chars[k];
      }
 
      // création du lien insertTag(tagBegin, tagEnd, defaultValue) en protegeant les caractères JS \ et '
      tags = (tags.replace(unescapeRe, "\\")).split("+");
      var tagBegin = tags[0].replace(re, "\\$1");
      var tagEnd = tags.length > 1 ? tags[1].replace(re, "\\$1") : "";
      var defaultValue = tags.length > 2 ? tags[2].replace(re, "\\$1") : "";
      a.href = "javascript:insertTags('" + tagBegin + "','" + tagEnd + "', '" + defaultValue + "')";
      //a.href="#";
      //eval("a.onclick = function() { insertTags('" + tagBegin + "','" + tagEnd + "', '" + defaultValue + "'); return false; }");
 
      a.appendChild(document.createTextNode((tagBegin + tagEnd).replace(unescapeRe, "\\")));
      spans[j].appendChild(a);
      spans[j].appendChild(document.createTextNode(" "));
    }
    // suppression de l'ancien contenu
    spans[j].removeChild(spans[j].firstChild);
  }
}
$(addCharSubsetMenu);
 
/**
 * Permet d'ajouter d'un jeu de caractères spéciaux dans le menu déroulant
 * paramètres :
 * - nom du jeu de caractères
 * - contenu HTML. Les caractères spéciaux doivent être dans des spans
 *   exemple : "caractères : <span>â ê î ô û</span>"
 */
function addSpecialCharsetHTML(title, charsHTML) {
  var specialchars = document.getElementById('specialcharsets');
  if (!specialchars) return;
 
  // Ajout des caractères spéciaux. Les liens seront initialisé par initializeCharSubset()
  // lors de la sélection
  var specialcharsets = document.getElementById('specialcharsets');
  var p = document.createElement("p");
  p.style.display = "none";
  p.title = title;
  p.innerHTML = charsHTML;
  specialcharsets.appendChild(p);
}
 
/**
 * Permet d'ajouter d'un jeu de caractères spéciaux dans le menu déroulant
 * paramètres :
 * - nom du jeu de caractères
 * - caractères spéciaux
 * exemple d'utilisation : addSpecialCharset("Français", "â ê î ô û");
 */
function addSpecialCharset(title, chars) {
  addSpecialCharsetHTML(title, "<span>" + chars + "</span>");
}
/*</pre>

=== Boites déroulantes ===
<pre> */

// set up the words in your language
var NavigationBarHide = 'Enrouler';
var NavigationBarShow = 'Dérouler';

// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = 0;


// shows and hides content and picture (if available) of navigation bars
// Parameters:
//     indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar)
{
    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
    var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);

    if (!NavFrame || !NavToggle) {
        return false;
    }

    // if shown now
    if (NavToggle.firstChild.data == NavigationBarHide) {
        for (
                var NavChild = NavFrame.firstChild;
                NavChild != null;
                NavChild = NavChild.nextSibling
            ) {
            if (NavChild.className == 'NavPic') {
                NavChild.style.display = 'none';
            }
            if (NavChild.className == 'NavContent') {
                NavChild.style.display = 'none';
            }
            if (NavChild.className == 'NavToggle') {
                NavChild.firstChild.data = NavigationBarShow;
            }
        }

    // if hidden now
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
        for (
                var NavChild = NavFrame.firstChild;
                NavChild != null;
                NavChild = NavChild.nextSibling
            ) {
            if (NavChild.className == 'NavPic') {
                NavChild.style.display = 'block';
            }
            if (NavChild.className == 'NavContent') {
                NavChild.style.display = 'block';
            }
            if (NavChild.className == 'NavToggle') {
                NavChild.firstChild.data = NavigationBarHide;
            }
        }
    }
}

// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
    var indexNavigationBar = 0;
    // iterate over all <div>-elements
    for(
            var i=0; 
            NavFrame = document.getElementsByTagName("div")[i]; 
            i++
        ) {
        // if found a navigation bar
        if (NavFrame.className == "NavFrame") {

            indexNavigationBar++;
            var NavToggle = document.createElement("a");
            NavToggle.className = 'NavToggle';
            NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
            NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');

            var NavToggleText = document.createTextNode(NavigationBarHide);
            NavToggle.appendChild(NavToggleText);

            // add NavToggle-Button as first div-element 
            // in <div class="NavFrame">
            NavFrame.insertBefore(
                NavToggle,
                NavFrame.firstChild
            );
            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
        }
    }
    // if more Navigation Bars found than Default: hide all
    if (NavigationBarShowDefault < indexNavigationBar) {
        for(
                var i=1; 
                i<=indexNavigationBar; 
                i++
        ) {
            toggleNavigationBar(i);
        }
    }

}

aOnloadFunctions[aOnloadFunctions.length] = createNavigationBarToggleButton;

/*</pre>

=== Générateur de tableaux ===
<pre>*/

//============================================================
// Générateur de tableaux
//============================================================

/**
 *
 * English: Generate an array using Mediawiki syntax
 *
 * @author: fr:user:dake
 * @version: 0.1
 */
 
function generateTableau(nbCol, nbRow, border, styleHeader, styleLine)
{
        var code = "\n";
        if (styleHeader==1) {
                code += '{{entête tableau charte}}\n';
        } else {
                code += '{| border="' + border + '"\n';
                code += '|+ Titre du tableau\n';
        }
        
        for (var i=0;i<nbCol;i++) code += '! en-tête ' + i + '\n'
        
        for (var j=0;j<nbRow;j++) {
                if ((j+1)%2==0 && styleLine==1) {
                        code += '|-{'+'{ligne grise}'+'}\n'
                } else {                
                        code += '|-----\n'
                }
                
                for (var i=0;i<nbCol;i++) code += '| élément\n';
        }
        
        code += '|}';
        insertTags('','', code); 
}

/**
 *
 * English: Open a popup with parameters to generate an array. 
 * The number of rows/columns can be modified. Some additional
 * parameters are related to templates available on :fr
 *
 * @author: fr:user:dake
 * @version: 0.1
 */
 
function popupTableau()
{
  var popup = window.open('','name','height=400,width=500');
  
  javaCode =  '<script type="text\/javascript">function insertCode(){';
  javaCode += 'var row = parseInt(document.paramForm.inputRow.value); '
  javaCode += 'var col = parseInt(document.paramForm.inputCol.value); '
  javaCode += 'var bord = parseInt(document.paramForm.inputBorder.value); '
  javaCode += 'var styleHeader = document.paramForm.inputHeader.checked; '
  javaCode += 'var styleLine = document.paramForm.inputLine.checked; '
  javaCode += 'window.opener.generateTableau(col,row,bord,styleHeader,styleLine); '
  javaCode += '}<\/script>';
  
  popup.document.write('<html><head><title>Paramètres du tableau</title>');
  popup.document.write(javaCode); 
  popup.document.write('</head><body>');
  popup.document.write('<p>Veuillez entrer les paramètres du tableau : </p>');
  popup.document.write('<form name="paramForm">');
  popup.document.write('Nombre de lignes : <input type="text" name="inputRow" value="3" ><p>');
  popup.document.write('Nombre de colonnes : <input type="text" name="inputCol" value="3" ><p>');
  popup.document.write('Largeur de la bordure : <input type="text" name="inputBorder" value="1" ><p>');
  popup.document.write('En-tête en gris (style « charte graphique ») : <input type="checkbox" name="inputHeader" checked="1" ><p>');
  popup.document.write('Lignes grises alternées (style « charte graphique ») : <input type="checkbox" name="inputLine" checked="1" ><p>');
  popup.document.write('</form">');
  popup.document.write('<p><a href="javascript:insertCode()"> Insérer le code dans la fenêtre d\'édition</a></p>');
  popup.document.write('<p><a href="javascript:self.close()"> Fermer</a></p>');
  popup.document.write('</body></html>');
  popup.document.close();
}

/*</pre>

=== Insertion de nouveaux boutons dans la barre d'outil ===

<pre>*/
/* NOUVEAUX CODE POUR LES BOUTON SUPPRIMÉS */

$(function() {

  if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) == -1)
    return;

  $.each([
    // Format : pour chaque bouton
    // [
    //   'Texte à insérer avant la sélection', 'Texte à insérer après la sélection',
    //   'Image du bouton (après « commons/ » et sans « .png » à la fin)',
    //   'Texte apparaissant dans la bulle au survol du bouton',
    //   'Identifiant de l'image ; importance faible, mais il faut s'assurer que l'identifiant est unique, ne change pas et n'utilise ni espace, ni caractères spéciaux'
    // ],
    [
     '<!--', '-->',
      '3/37/Btn_toolbar_commentaire',
      'Commentaire',
      'Commentaire'
    ],
    [
     '[[Catégorie:', ']]',
      'b/b4/Button_category03',
      'Catégorie',
      'Nom de la catégorie'
    ],
    [
     '{{', '}}',
      'e/eb/Button_plantilla',
      'Balise modèle',
      'Nom du modèle'
    ],
    [
     '* {{Source|langue=fr\n|url=', '\n|titre=\n|auteur=\n|publication=\n|date=\n}}',
      '0/01/Button_no_source',
      'Source d’information',
      'Lien'
    ],
    [
     '* {{source-cp|langue=\n|url=', '\n|titre=\n|publication=\n|date=\n}}',
      '3/3a/Button_av-img',
      'Communiqué de presse',
      'Lien'
    ],
    [
     '* {{wikinews|langue=fr\n|titre=', '\n|date=\n}}',
      '3/30/Button_wn',
      'Source wikinews',
      'Lien interne'
    ],
    [
     '* {{Source sans url|langue=fr\n|titre=','\n|auteur=\n|publication=\n|page=\n|édition=\n|date=\n}}',
      '3/38/Button_plume',
      'Source papier',
      'Titre'
    ],
    [
     '<ref>','</ref>',
      'c/c4/Button_ref',
      'Insère une note',
      'Texte'
    ],
    [
     , '{{notes}}',
      '9/9a/Button_references',
      'Notes de fin',
      ''
    ],
    [
     , '{{Développement}}',
      'c/c3/Button_travaux',
      'Mise en développement',
      ''
    ],
    [
     , '{{Publication|jour={{subst:#time:j}}|mois={{subst:#time:F}}|année={{subst:#time:Y}}|brève=non}}\n',
      '8/82/Button_publication',
      'Publication de la page',
      ''
    ],
    [
     '{{Traduction\n|langue=\n|titre=','\n|date=\n|old=\n}}',
      'b/b8/Button_Globe',
      'Page traduite',
      'Titre'
    ],
    [
     '{{Brève\n|texte=','\n \n|u1=\n|s1=\n|L1=\n|n1=\n \n|u2=\n|s2=\n|L2=\n\|n2=\n \n|u3=\n|s3=\n|L3=\n|n3=\n \n|v1=\n|d1=\n \n|v2=\n|d2=\n}}\n',
      '1/12/Button_breve',
      'Brève',
      'Texte de la brève'
    ],
    [
     '{{subst:#ifeq:{{subst:#time:j}}|1|1er|{{subst:#time:j}}}} {{subst:#time:F Y}}','',
     '3/3f/Button_attendre',
     'Date du jour courant',
     ''
    ],
    [
     '{{Résultat-sport\n|largeur=75%\n|date=','\n|équipe1=\n|drapeau1=\n|résultat=\n|équipe2=\n|drapeau2=\n|rapport=\n|buts1=\n|buts2=\n|stade=\n|affluence=\n|arbitre=\n}}',
      'b/b4/Button_lienjournal',
      'Résultat sportif',
      'date'
    ],
    [
     '{{Wikipédiapar|','}}',
      'c/cb/Button_wikipedia',
      'Liens vers wikipédia',
      'Titre de la page'
    ],
    [
     '{{w|','}}',
      '6/65/Button_wikificare',
      'Lien vers le portail ou la catégorie',
      'Titre'
    ],
    [
     '{{Interprojet\n|nolink\n|etiq=','\n|w=\n|w-it=\n|w-en=\n|w-es=\n|w-de=\n|w-ca=\n|w-pt=\n|s=\n|wikt=\n|b=\n|q=\n|v=\n|wikispecies=\n|commons=\n|m=\n}}',
      '4/4c/Button_interprojet',
      'Lien interprojet',
      'Étiquette'
    ],
    [
     '{{Citation|','}}',
      '4/44/Button_comillas_latinas',
      'Citation',
      'Texte de la citation'
    ],
    [
     '{{Citation1|','}}',
      '2/26/Button_latinas',
      'Citation en italique',
      'Texte de la citation'
    ],
    [
     ,'&nbsp\;',
      '4/4b/Button_nbsp',
      'Espace insécable',
      ''
    ],
    [
    	'{{Encadré\n|align=\n|longueur=\n|titre=\n|1=','\n}}', 
    	'c/cf/Button_encadr%C3%A9',
    	'Encadré',
    	'Texte de l’encadré'
    ],
    [
    	'{{Texte|','| | }}',
    	'1/1e/Button_font_color',
    	'Taille et couleur du texte',
    	'Texte'
    ],
    
], function(_, button) {
    mw.toolbar.addButton('//upload.wikimedia.org/wikipedia/commons/' + button[2] + '.png', button[3], button[0], button[1], (button[0] ? button[4] : ''), 'mw-editbutton-' + button[4]);
  });

});


/* </pre>

== bouton Remplacement ==

<pre> */

/***
	*Expressions régulières
	*Auteur: ThomasV, Pathoschild
	*Note : cet outil utilise la syntaxe javascript : on utilise $ (et pas \) pour appeler un groupe dans la chaîne de remplacement.
	*Tutoriel : http://www.regular-expressions.info/tutorial.html
	****/
 
	/* create form */
	function custom() {
 
		/* if already open */
		if(document.getElementById('regexform')) customremove()
		else {	
                        editbox = document.getElementById('wpTextbox1');
			/* container */
			regexform = document.createElement('div');
			regexform.setAttribute('id','regexform');
			editbox.parentNode.insertBefore(regexform,editbox.parentNode.firstChild);
 
			/* form tag */
			var formform = document.createElement('form');
			formform.setAttribute('id','regexformform');
			formform.setAttribute('onSubmit','customgo(); return false;');
			regexform.appendChild(formform);
 
			// add input boxes
		        var newinput = document.createElement('input');
		        newinput.setAttribute('id','formsearch');
		        newlabel = document.createElement('label');
		        newlabel.setAttribute('for','formsearch');
			newlabel.appendChild(document.createTextNode("Remplacer "));
 
			formform.appendChild(newlabel);
			formform.appendChild(newinput);
 
			var newinput = document.createElement('input');
			newinput.setAttribute('id','formreplace');
			newlabel = document.createElement('label');
			newlabel.setAttribute('for','formreplace');
			newlabel.appendChild(document.createTextNode(' par '));
 
			formform.appendChild(newlabel);
			formform.appendChild(newinput);
 
			// go! link
			var go_button = document.createElement('input');
			go_button.setAttribute('type',"submit");
			go_button.setAttribute('title',"go!");
			go_button.setAttribute('value',"go!");
			formform.appendChild(go_button);
 
		}
	}
 
 
 
	/* run patterns */
	function customgo() {
		/* get search and replace strings */
 
                search = document.getElementById('formsearch').value;
		search = search.replace(/\\n/g, '\n');
 
                replace = document.getElementById('formreplace').value;
		replace = replace.replace(/\\n/g, '\n');
 
		/* convert input to regex */
 
		// without delimiters
		if(!search.match(/^\s*\/[\s\S]*\/[a-z]*\s*$/i)) {
			search = new RegExp(search,'g');
		}
		// with delimiters
		else {
			// break into parts
			var regpattern = search.replace(/^\s*\/([\s\S]*)\/[a-z]*\s*$/i,'$1');
			var regmodifiers = search.replace(/^\s*\/[\s\S]*\/([a-z]*)\s*$/,'$1');
			// filter invalid flags
			regmodifiers = regmodifiers.replace(/[^gim]/ig,'');
 
			search = new RegExp(regpattern, regmodifiers);
		}
 
		/* perform */
		editbox.value = editbox.value.replace(search,replace);
 
	}
 
	/* remove form */
	function customremove() {
		regexform.parentNode.removeChild(regexform);
		patterncount = -1;
	}
 
 
	/*******************
	*** create button
	********************/
        function add_regexp_button(){
 
             toolbar = document.getElementById("toolbar");
		  if(toolbar){
			var image = document.createElement("img");
			image.width = 23;
			image.height = 22;
			image.border = 0;
			image.className = "mw-toolbar-editbutton";
			image.style.cursor = "pointer";
			image.alt = "regexp";
			image.title = "Expression régulière";
			image.src = "//upload.wikimedia.org/wikipedia/commons/a/a0/Button_references_alt.png";
			image.onclick = custom;
			toolbar.appendChild(image);
                 }
       }
 
       $(add_regexp_button)

/**
 * Fonctions de remplissage automatique des pages de brèves
 */
function InitBreve(page_name)
{
    m = new Array('janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre');
    mb= new Array('de janvier','de février','de mars','d\'avril','de mai','de juin','de juillet','d\'août','de septembre','d\'octobre','de novembre','de décembre');
    n = new Array('01','02','03','04','05','06','07','08','09','10','11','12'); 
    j = new Array('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31'); 
    jc = new Array('1er','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31'); 
    today = new Date();
    jour = today.getDate();
    mois = today.getMonth();
    jourmois = jour + ' ' + m[mois];
    jourmoisb = mb[mois];
    annee = today.getFullYear();
    anneemoisjour = annee + ', ' + n[mois] + ', ' + jour;
    jourmoisannee = jc[jour-1] + " " + m[mois] + " " + annee;
    return "<!-- Entête de la page de la brève (pré-complété avec la date du jour) -->\n" +
         "{{Brèves|" + jourmois + "|" + annee + "|" + anneemoisjour + "}}\n\n" +
         "{{Modèle:Brèves " + jourmoisb + "-0|3=2011|float=right}} <!--Indiquez le jour de début de mois situé après le tiret après ce mois. Le 0 indique le lundi -->\n\n" +
         "== À retenir aujourd'hui ==\n<DynamicPageList>\ncategory=" + jourmoisannee + "\ncategory=Article publié\nnotcategory=sport\nnotcategory=Météo en France\nnotcategory=Bulletin d'enneigement\nnamespace=main\nordermethod=categorysortkey\norder = ascending\nsuppresserrors=true\n</DynamicPageList>\n\n" +
         "== Actualité sportive ==\n<!-- Les brèves concernant le sport doivent être insérées ici -->\n\n<DynamicPageList>\ncategory=" + jourmoisannee + "\ncategory=sport\ncategory=Article publié\nnamespace=main\nordermethod=categorysortkey\norder = ascending\nsuppresserrors=true\n</DynamicPageList>\n\n{{DEFAULTSORT:Brèves : " + annee + "-" + n[mois] + "-" + j[jour-1] + "}}"
}
 
var init_if_empty = new Array(
  new Array('Brèves_:', InitBreve)
);


/**
 * Remplit la zone d'édition si elle est vide avec le texte retourné par
 * un pointeur de fonction sélectionné par le nom de la page.
 */
function InitPage() {
  // Tester si editform et wpTextbox1 existe sinon il y a une erreur lorsqu'on
  // ouvre l'historique d'une page qui match un des noms de init_if_empty[],
  // tester seulement le nom de la page n'est pas suffisant.
  if (document.editform == undefined || document.editform.wpTextbox1 == undefined) return;
  var text_area = document.editform.wpTextbox1;
  if (text_area.value.length != 0) return;
  for (var i = 0; i < init_if_empty.length; ++i) {
    var page_match = init_if_empty[i][0];
    var index = mw.config.get('wgPageName').indexOf(page_match);
    if (index != -1) {
      page_name = mw.config.get('wgPageName').slice(page_match.length);
      page_name = page_name.replace(/_/g, ' ');
      text_area.value = init_if_empty[i][1](page_name);
      break;
    }
  }
}
$(InitPage);

/*</pre>*/

// MEDIAWIKI IMPORTE AUTOMATIQUEMENT LE CSS ET LE JAVASCRIPT COMMUN POUR UNE PAGE //
if (mw.config.get('wgPageName') === 'Wikinews:Article_principal') {
 importStylesheet("MediaWiki:Common.css/" + mw.config.get('wgPageName'));
 importScript("MediaWiki:Common.js/" + mw.config.get('wgPageName'));
}

// Utilisé pour la nouvelle Ticker (Modèle:Ticker) //
//Bawolff's modified ticker. if all goes well, will switch over shortly
 addLoadEvent(function () {if ((window.disable_ticker2 !== true) && (document.getElementById("singleTickerForPage") || document.getElementById('enableTickers'))) importScript("MediaWiki:ticker2.js");});

/*
==Tabber code==
 */

/*
This was originally from http://www.barelyfitz.com/projects/tabber/
This has been modified very slightly for wikinews by [[user:Bawolff]] (you can use any of my modifications under the same license as the original author specified)

Please note, only the tabber code is under the MIT license. (the rest is probably either cc-by, GPL, or some combination thereof. its not really clear)

Note i'm slowly modifying to use hasClass() as it is supposedly more efficient

==================================================
  $Id: tabber.js,v 1.9 2006/04/27 20:51:51 pat Exp $
  tabber.js by Patrick Fitzgerald pat@barelyfitz.com

  Documentation can be found at the following URL:
  http://www.barelyfitz.com/projects/tabber/

  License (http://www.opensource.org/licenses/mit-license.php)

  Copyright (c) 2006 Patrick Fitzgerald, modifed by Bawolff

  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation files
  (the "Software"), to deal in the Software without restriction,
  including without limitation the rights to use, copy, modify, merge,
  publish, distribute, sublicense, and/or sell copies of the Software,
  and to permit persons to whom the Software is furnished to do so,
  subject to the following conditions:

  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
  ==================================================*/

function tabberObj(argsObj)
{
  var arg; /* name of an argument to override */

  /* Element for the main tabber div. If you supply this in argsObj,
     then the init() method will be called.
  */
  this.div = null;

  /* Class of the main tabber div */
  this.classMain = "tabber";

  /* Rename classMain to classMainLive after tabifying
     (so a different style can be applied)
  */
  this.classMainLive = "tabberlive";

  /* Class of each DIV that contains a tab */
  this.classTab = "tabbertab";

  /* Class to indicate which tab should be active on startup */
  this.classTabDefault = "tabbertabdefault";

  /* Class for the navigation UL */
  this.classNav = "tabbernav";

  /* add space between tabs to force line break. use class UseTabBreaks*/
  this.spaceTabs = false;



  /* When a tab is to be hidden, instead of setting display='none', we
     set the class of the div to classTabHide. In your screen
     stylesheet you should set classTabHide to display:none.  In your
     print stylesheet you should set display:block to ensure that all
     the information is printed.
  */
  this.classTabHide = "tabbertabhide";

  /* Class to set the navigation LI when the tab is active, so you can
     use a different style on the active tab.
  */
  this.classNavActive = "tabberactive";

  /* Elements that might contain the title for the tab, only used if a
     title is not specified in the TITLE attribute of DIV classTab.
  */
  this.titleElements = ['h2','h3','h4','h5','h6'];

  /* Should we strip out the HTML from the innerHTML of the title elements?
     This should usually be true.
  */
  this.titleElementsStripHTML = true;

  /* If the user specified the tab names using a TITLE attribute on
     the DIV, then the browser will display a tooltip whenever the
     mouse is over the DIV. To prevent this tooltip, we can remove the
     TITLE attribute after getting the tab name.
  */
  this.removeTitle = true;

  /* If you want to add an id to each link set this to true */
  this.addLinkId = false;

  /* If addIds==true, then you can set a format for the ids.
     <tabberid> will be replaced with the id of the main tabber div.
     <tabnumberzero> will be replaced with the tab number
       (tab numbers starting at zero)
     <tabnumberone> will be replaced with the tab number
       (tab numbers starting at one)
     <tabtitle> will be replaced by the tab title
       (with all non-alphanumeric characters removed)
   */
  this.linkIdFormat = '<tabberid>nav<tabnumberone>';

  /* You can override the defaults listed above by passing in an object:
     var mytab = new tabber({property:value,property:value});
  */
  for (arg in argsObj) { this[arg] = argsObj[arg]; }

  /* Create regular expressions for the class names; Note: if you
     change the class names after a new object is created you must
     also change these regular expressions.
  */
  this.REclassMain = new RegExp('\\b' + this.classMain + '\\b', 'gi');
  this.REclassMainLive = new RegExp('\\b' + this.classMainLive + '\\b', 'gi');
  this.REclassTab = new RegExp('\\b' + this.classTab + '\\b', 'gi');
  this.REclassTabDefault = new RegExp('\\b' + this.classTabDefault + '\\b', 'gi');
  this.REclassTabHide = new RegExp('\\b' + this.classTabHide + '\\b', 'gi');

  /* Array of objects holding info about each tab */
  this.tabs = new Array();

  /* If the main tabber div was specified, call init() now */
  if (this.div) {

    this.init(this.div);

    /* We don't need the main div anymore, and to prevent a memory leak
       in IE, we must remove the circular reference between the div
       and the tabber object. */
    this.div = null;
  }
}


/*--------------------------------------------------
  Methods for tabberObj
  --------------------------------------------------*/


tabberObj.prototype.init = function(e)
{
  /* Set up the tabber interface.

     e = element (the main containing div)

     Example:
     init(document.getElementById('mytabberdiv'))
   */

  var
  childNodes, /* child nodes of the tabber div */
  i, i2, /* loop indices */
  t, /* object to store info about a single tab */
  defaultTab=0, /* which tab to select by default */
  DOM_ul, /* tabbernav list */
  DOM_li, /* tabbernav list item */
  DOM_a, /* tabbernav link */
  aId, /* A unique id for DOM_a */
  headingElement; /* searching for text to use in the tab */

  /* Verify that the browser supports DOM scripting */
  if (!document.getElementsByTagName) { return false; }

  /* If the main DIV has an ID then save it. */
  if (e.id) {
    this.id = e.id;
  }

  /* Clear the tabs array (but it should normally be empty) */
  this.tabs.length = 0;

  /* Loop through an array of all the child nodes within our tabber element. */
  childNodes = e.childNodes;
  for(i=0; i < childNodes.length; i++) {

    /* Find the nodes where class="tabbertab" */
    if(childNodes[i].className &&
       hasClass(childNodes[i], this.classTab)) {
      
      /* Create a new object to save info about this tab */
      t = new Object();
      
      /* Save a pointer to the div for this tab */
      t.div = childNodes[i];
      
      /* Add the new object to the array of tabs */
      this.tabs[this.tabs.length] = t;

      /* If the class name contains classTabDefault,
	 then select this tab by default.
      */
      if (childNodes[i].className.match(this.REclassTabDefault)) {
	defaultTab = this.tabs.length-1;
      }
    }
  }

  /* Create a new UL list to hold the tab headings */
  DOM_ul = document.createElement("ul");
  DOM_ul.className = this.classNav;
  
  /* Loop through each tab we found */
  for (i=0; i < this.tabs.length; i++) {

    t = this.tabs[i];

    /* Get the label to use for this tab:
       From the title attribute on the DIV,
       Or from one of the this.titleElements[] elements,
       Or use an automatically generated number.
     */
    t.headingText = t.div.title;

    /* Remove the title attribute to prevent a tooltip from appearing */
    if (this.removeTitle) { t.div.title = ''; }

    if (!t.headingText) {

      /* Title was not defined in the title of the DIV,
	 So try to get the title from an element within the DIV.
	 Go through the list of elements in this.titleElements
	 (typically heading elements ['h2','h3','h4'])
      */
      for (i2=0; i2<this.titleElements.length; i2++) {
	headingElement = t.div.getElementsByTagName(this.titleElements[i2])[0];
	if (headingElement) {
	  t.headingText = headingElement.innerHTML;
	  if (this.titleElementsStripHTML) {
	    t.headingText.replace(/<br>/gi," ");
	    t.headingText = t.headingText.replace(/<[^>]+>/g,"");
	  }
	  break;
	}
      }
    }

    if (!t.headingText) {
      /* Title was not found (or is blank) so automatically generate a
         number for the tab.
      */
      t.headingText = i + 1;
    }

    /* Create a list element for the tab */
    DOM_li = document.createElement("li");

    /* Save a reference to this list item so we can later change it to
       the "active" class */
    t.li = DOM_li;

    /* Create a link to activate the tab */
    DOM_a = document.createElement("a");
    DOM_a.appendChild(document.createTextNode(t.headingText));
    DOM_a.href = "javascript:void(null);";
    DOM_a.title = t.headingText;
    DOM_a.onclick = this.navClick;

    /* Add some properties to the link so we can identify which tab
       was clicked. Later the navClick method will need this.
    */
    DOM_a.tabber = this;
    DOM_a.tabberIndex = i;

    /* Do we need to add an id to DOM_a? */
    if (this.addLinkId && this.linkIdFormat) {

      /* Determine the id name */
      aId = this.linkIdFormat;
      aId = aId.replace(/<tabberid>/gi, this.id);
      aId = aId.replace(/<tabnumberzero>/gi, i);
      aId = aId.replace(/<tabnumberone>/gi, i+1);
      aId = aId.replace(/<tabtitle>/gi, t.headingText.replace(/[^a-zA-Z0-9\-]/gi, ''));

      DOM_a.id = aId;
    }

    /* Add the link to the list element */
    DOM_li.appendChild(DOM_a);

    /* Add the list element to the list */
    DOM_ul.appendChild(DOM_li);

     /* add a space to get line breaks */
    if (this.spaceTabs) {
    DOM_ul.appendChild(document.createTextNode(" "));
    }


  }

  /* Add the UL list to the beginning of the tabber div */
  e.insertBefore(DOM_ul, e.firstChild);

  /* Make the tabber div "live" so different CSS can be applied */
  e.className = e.className.replace(this.REclassMain, this.classMainLive);

  /* Activate the default tab, and do not call the onclick handler */
  this.tabShow(defaultTab);

  /* If the user specified an onLoad function, call it now. */
  if (typeof this.onLoad == 'function') {
    this.onLoad({tabber:this});
  }

  return this;
};


tabberObj.prototype.navClick = function(event)
{
  /* This method should only be called by the onClick event of an <A>
     element, in which case we will determine which tab was clicked by
     examining a property that we previously attached to the <A>
     element.

     Since this was triggered from an onClick event, the variable
     "this" refers to the <A> element that triggered the onClick
     event (and not to the tabberObj).

     When tabberObj was initialized, we added some extra properties
     to the <A> element, for the purpose of retrieving them now. Get
     the tabberObj object, plus the tab number that was clicked.
  */

  var
  rVal, /* Return value from the user onclick function */
  a, /* element that triggered the onclick event */
  self, /* the tabber object */
  tabberIndex, /* index of the tab that triggered the event */
  onClickArgs; /* args to send the onclick function */

  a = this;
  if (!a.tabber) { return false; }

  self = a.tabber;
  tabberIndex = a.tabberIndex;

  /* Remove focus from the link because it looks ugly.
     I don't know if this is a good idea...
  */
  a.blur();

  /* If the user specified an onClick function, call it now.
     If the function returns false then do not continue.
  */
  if (typeof self.onClick == 'function') {

    onClickArgs = {'tabber':self, 'index':tabberIndex, 'event':event};

    /* IE uses a different way to access the event object */
    if (!event) { onClickArgs.event = window.event; }

    rVal = self.onClick(onClickArgs);
    if (rVal === false) { return false; }
  }

  self.tabShow(tabberIndex);

  return false;
};


tabberObj.prototype.tabHideAll = function()
{
  var i; /* counter */

  /* Hide all tabs and make all navigation links inactive */
  for (i = 0; i < this.tabs.length; i++) {
    this.tabHide(i);
  }
};


tabberObj.prototype.tabHide = function(tabberIndex)
{
  var div;

  if (!this.tabs[tabberIndex]) { return false; }

  /* Hide a single tab and make its navigation link inactive */
  div = this.tabs[tabberIndex].div;

  /* Hide the tab contents by adding classTabHide to the div */
  if (!div.className.match(this.REclassTabHide)) {
    div.className += ' ' + this.classTabHide;
  }
  this.navClearActive(tabberIndex);

  return this;
};


tabberObj.prototype.tabShow = function(tabberIndex)
{
  /* Show the tabberIndex tab and hide all the other tabs */

  var div;

  if (!this.tabs[tabberIndex]) { return false; }

  /* Hide all the tabs first */
  this.tabHideAll();

  /* Get the div that holds this tab */
  div = this.tabs[tabberIndex].div;

  /* Remove classTabHide from the div */
  div.className = div.className.replace(this.REclassTabHide, '');

  /* Mark this tab navigation link as "active" */
  this.navSetActive(tabberIndex);

  /* If the user specified an onTabDisplay function, call it now. */
  if (typeof this.onTabDisplay == 'function') {
    this.onTabDisplay({'tabber':this, 'index':tabberIndex});
  }

  return this;
};

tabberObj.prototype.navSetActive = function(tabberIndex)
{
  /* Note: this method does *not* enforce the rule
     that only one nav item can be active at a time.
  */

  /* Set classNavActive for the navigation list item */
  this.tabs[tabberIndex].li.className = this.classNavActive;

  return this;
};


tabberObj.prototype.navClearActive = function(tabberIndex)
{
  /* Note: this method does *not* enforce the rule
     that one nav should always be active.
  */

  /* Remove classNavActive from the navigation list item */
  this.tabs[tabberIndex].li.className = '';

  return this;
};


/*==================================================*/


function tabberAutomatic(tabberArgs)
{
  /* This function finds all DIV elements in the document where
     class=tabber.classMain, then converts them to use the tabber
     interface.

     tabberArgs = an object to send to "new tabber()"
  */

  var
    tempObj, /* Temporary tabber object */
    divs, /* Array of all divs on the page */
    i; /* Loop index */

  if (!tabberArgs) { tabberArgs = {}; }

  /* Create a tabber object so we can get the value of classMain */
  tempObj = new tabberObj(tabberArgs);

  /* Find all DIV elements in the document that have class=tabber */

  /* First get an array of all DIV elements and loop through them */
  divs = document.getElementsByTagName("div");
  for (i=0; i < divs.length; i++) {
    
    /* Is this DIV the correct class? */
    if (divs[i].className &&
	hasClass(divs[i], tempObj.classMain)) {

    if (hasClass(divs[i], "UseTabBreaks")) {
        tabberArgs.spaceTabs =  true;
    }
      
      /* Now tabify the DIV */
      tabberArgs.div = divs[i];
      divs[i].tabber = new tabberObj(tabberArgs);
    }
  }
/******
Begin special case links for the howdy template.
This is kind of ugly, but as good a place as any to stick the code.

Creates magic links for certain ids, in certain tab boxes
*/
  var howdy = document.getElementById('HowdyWelcomeTemplate');
  if (howdy) {
    var policy = document.getElementById('HowdyWelcomeTemplatePolicy');
    var talk = document.getElementById('HowdyWelcomeTemplateDiscussions');
    var a;
    if (talk) {
      a = document.createElement('a');
      a.href = "#";
      a.onclick = function() {howdy.tabber.tabShow(2); return false;} //show tab 3
      a.appendChild(talk.firstChild);
      talk.appendChild(a);

    }
    if (policy) {
      a = document.createElement('a');
      a.href = "#";
      a.onclick = function() {howdy.tabber.tabShow(1); return false;} //show tab 2
      a.appendChild(policy.firstChild);
      policy.appendChild(a);
    }
  }

/*******
End special case code for special links
*****/
  
  return this;
}


/*==================================================*/


function tabberAutomaticOnLoad(tabberArgs) {

  /* This function adds tabberAutomatic to the window.onload event,
     so it will run after the document has finished loading.
  */
//  var oldOnLoad;

  if (!tabberArgs) { tabberArgs = {}; }

  /* Taken from: http://simon.incutio.com/archive/2004/05/26/addLoadEvent */

  // Use dom-ready from wiki instead of window-onload
  $(function() {
      tabberAutomatic(tabberArgs);
  });
}


/*==================================================*/


/* Run tabberAutomaticOnload() unless the "manualStartup" option was specified */

if (typeof tabberOptions == 'undefined') {

    tabberAutomaticOnLoad();

} else {

  if (!tabberOptions.manualStartup) {
    tabberAutomaticOnLoad(tabberOptions);
  }

}


/*
End Tabber. Note, code after this line probably is not under the MIT license.
*/

 // hasClass()
 // Description: Uses regular expressions and caching for better performance.
 // Stolen from en wikipedia where it was maintained by: w:User:Mike Dillon, w:User:R. Koot, w:User:SG
 
 var hasClass = (function () {
    var reCache = {};
    return function (element, className) {
      return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
    };
 })();

/*  Partage des articles de Wikinews         */
/*                                           */
/*  Affiche une image, puis un tableau si    */
/*  le curseur de la souris se trouve sur    */
/*  l'image. Partage possible sur Facebook,  */
/*  Reddit, Digg, Twitter, ...               */
/*                                           */
/*  Auteurs : Chphe & Stef48                 */
/*  Création : 09/08/09  |  MàJ : 16/08/09   */
 
function sharefunction() {
   tab_cree=false;
   tab_cpt=0;
   var shareTemplate = document.getElementById('share');
   if (shareTemplate) {
      shareTemplate.innerHTML = '<br /><br /><a href="http://fr.wikinews.org/wiki/Accueil" onmouseover="openwindow()" onmouseout="setTimeout(\'closewindow()\', 300)"><img alt="Partager cet article" src="//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/ShareThisArticle-wn-fr.svg/380px-ShareThisArticle-wn-fr.svg.png" /></a>' + shareTemplate.innerHTML;
   }
 }
 
$(sharefunction);
 
function openwindow() {
   if( (++tab_cpt) != 1) return;
 
   var table1 = document.getElementById('tableshare');
   if(tab_cree) table1.style.display="inline";
   else
   {
      table1.innerHTML = '<table width="380px" style="border:1px solid #aaa" onmouseover="openwindow()" onmouseout="setTimeout(\'closewindow()\', 10)" cellspacing="0" cellpadding="5" class="plainlinks"><tr><th colspan="3" style="border-bottom:1px solid #aaa" align="left"><div style="font-size:89%">Partager cet article sur</div></th></tr><tr><td><a href="mailto:?subject=' + mw.config.get('wgPageName') + '_-_Wikinews&amp;body=http%3A//fr.wikinews.org/wiki/' + encodeURIComponent(mw.config.get('wgPageName')) + '">Courriel</a><br><a href="http://www.facebook.com/sharer.php?u=http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '&t=' + mw.config.get('wgPageName') + '_-_Wikinews">Facebook</a><br><a href="http://twitter.com/home/?status=Trouvé%20sur%20Wikinews:%20http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '">Twitter</a><br><a href="https://plusone.google.com/_/+1/confirm?hl=fr&url=http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '&title=' + mw.config.get('wgPageName') +' sur Wikinews francophone">Google+</a></span><br><a href="http://identi.ca//index.php?action=newnotice&status_textarea=Trouvé%20sur%20Wikinews:%20http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '">Identi.ca</a></td><td><a href="http://reddit.com/submit?url=http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '&title=' + mw.config.get('wgPageName') + '_-_Wikinews">Reddit</a><br><a href="http://digg.com/submit?url=http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '&title=' + mw.config.get('wgPageName') + '_-_Wikinews">Digg</a><br /><a href="http://buzz.yahoo.com/buzz?targetUrl=http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '&headline=' + mw.config.get('wgPageName') + '_-_Wikinews">Yahoo!</a><br><a href="http://de'+'l.icio.us/post?url=http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '&title=' + mw.config.get('wgPageName') + '_-_Wikinews">del.icio.us</a></td><td><a href="http://www.simpy.com/simpy/LinkAdd.do?href=http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '&title=' + mw.config.get('wgPageName') + '_-_Wikinews">Simpy</a><br><a href="http://stumbleupon.com/submit?url=http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '&title=' + mw.config.get('wgPageName') + '_-_Wikinews">StumbleUpon</a><br /><a href="http://www.technorati.com/faves?add=http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '">Technorati</a><br><a href="http://cgi.fark.com/cgi/farkit.pl?u=http://fr.wikinews.org/wiki/' + mw.config.get('wgPageName') + '&h=' + mw.config.get('wgPageName') + '_-_Wikinews">Fark</a></td></tr></table>';
      tab_cree=true;
   }
}
 
function closewindow()
{
   if( (--tab_cpt)==0 )
   {
      var table2 = document.getElementById('tableshare');
      table2.style.display="none";
   }
}

/**
 * Réécriture des titres
 *
 * Fonction utilisée par [[Modèle:Titre incorrect]]
 * 
 * La fonction cherche un bandeau de la forme
 * <div id="RealTitleBanner">
 *   <span id="RealTitle">titre</span>
 * </div>
 *
 * Un élément comportant id="DisableRealTitle" désactive la fonction
 */
function rewritePageH1() {
  var realTitleBanner = document.getElementById('RealTitleBanner');
  if (realTitleBanner) {
    if (!document.getElementById('DisableRealTitle')) {
      var realTitle = document.getElementById('RealTitle');
      var h1 = document.getElementById('firstHeading');
      var realH1 = h1.innerHTML;     
      if (realTitle && h1) {
        var titleText = realTitle.innerHTML;
        if (titleText == '') h1.style.display = 'none';
        else h1.innerHTML = titleText;
        realTitleBanner.style.display = 'none';
        if(mw.config.get('wgNamespaceNumber')==0) {
          var avert = document.createElement('p')
          avert.style.fontSize = '90%';
          avert.innerHTML = 'Titre à utiliser pour créer un lien interne : <b>'+realH1+'</b>';
          insertAfter(document.getElementById('content'),avert,h1);
        }
 
      }
    }
  }
}
$(rewritePageH1);

/**
 * WikiMiniAtlas is a popup click and drag world map.
 * See [[meta:WikiMiniAtlas]] for more information.
 */
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript');
var wma_settings = { 
  buttonImage: '//upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Geographylogo.svg/18px-Geographylogo.svg.png'
};

/**
 * Déplacement de coordonnées qui apparaissent en haut de la page depuis fr.wp
 */
function moveCoord() {
  var h1 = document.getElementById('firstHeading');
  var coord = document.getElementById('coordinates');
  if ( !coord || !h1 ) return;
  coord.id = "coordinates-title";
  h1.parentNode.insertBefore(coord, h1); /* déplacement de l'élément */
}
$(moveCoord);

 	
/**
 * application de [[w:Wikipédia:Prise de décision/Système de cache]], puis [[Wikiversité:La_salle_café/33_2010]]
 * un <span class="noarchive"> autour du lien l'empêche d'être pris en compte
 * pour celui-ci uniquement
 * un no_external_cache=true dans un monobook personnel désactive le script
 */
 
$(function () {
 
  if (mw.config.get('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(mw.config.get('wgServer'))==-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/?org=" + mw.config.get('wgServer') + "&url=" + chemin.replace(/%/g, "%25").replace(/&/g, "%26") + "&title=" + encodeURIComponent(titre));
      link.setAttribute("title", "archive de "+ titre);
      link.appendChild(document.createTextNode("archive"));
      link.style.color = "#3366BB";
      last.appendChild(link);
      last.appendChild(document.createTextNode("]"));
      }
    }
  }
}
);

// Verwendung von OpenStreetMap in Wikipedia.
// (c) 2008 by Magnus Manske
// Released under GPL
// Modifié pour marcher après moveCoord() ci-dessus
function openStreetMapInit () {
  var c = document.getElementById ( 'coordinates-title' ) ;
  if ( !c ) return ;
 
  var a = c.getElementsByTagName ( 'a' ) ;
  var geohack = false;
  for ( var i = 0 ; i < a.length ; i++ ) {
    var h = a[i].href ;
    if ( !h.match(/geohack/) ) continue ;
    geohack = true ;
    break ;
  }
  if ( !geohack ) return ;
 
  var na = document.createElement ( 'a' ) ;
  na.href = 'javascript:openStreetMapToggle();' ;
  na.title = 'Afficher/Masquer la carte' ;
  na.appendChild ( document.createTextNode ( 'carte' ) ) ;
  c.appendChild ( document.createTextNode ( ' (' ) ) ;
  c.appendChild ( na ) ;
  c.appendChild ( document.createTextNode ( ')   ' ) ) ;
}
 
function openStreetMapToggle () {
  var c = document.getElementById ( 'coordinates-title' ) ;
  var cs = document.getElementById ( 'contentSub' ) ;
  if ( !c || !cs ) return ;
  var osm = document.getElementById ( 'openstreetmap' ) ;
 
  if ( cs && osm ) {
    if ( osm.style.display == 'none' ) {
      osm.style.display = 'block' ;
    } else {
      osm.style.display = 'none' ;
    }
    return;
  }
 
  var found_link = false ;
  var a = c.getElementsByTagName ( 'a' ) ;
  var h;
  for ( var i = 0 ; i < a.length ; i++ ) {
    h = a[i].href ;
    if ( !h.match(/geohack/) ) continue ;
    found_link = true ;
    break ;
  }
  if ( !found_link ) return ; // No geohack link found
 
  h = h.split('params=')[1] ;
 
  var i = document.createElement ( 'iframe' ) ;
  var url = 'https://tools.wmflabs.org/wiwosm/osm-on-ol/kml-on-ol.php?lang=' + mw.config.get('wgUserLanguage') + '&params=' + h ;
 
  i.id = 'openstreetmap' ;
  i.style.width = '100%' ;
  i.style.height = '350px' ;
  i.style.clear = 'both' ;
  i.src = url ;
  cs.appendChild ( i ) ;
}
 
$(openStreetMapInit);

/* Permet d'afficher un compte à rebours sur une page avec le modèle [[Modèle:Compte à rebours]] */
/* Plyd - 3 février 2009 */
/* Importé depuis [[w:MediaWiki:Common.js]] */
function Rebours() {
  if( mw.config.get('wgNamespaceNumber') ==0) return;
  try {
   if (document.getElementById("rebours")) {
      destime = document.getElementById("rebours").title.HTMLize().split(";;");
      Maintenant = (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}
      TempsRestantJ = Math.floor(Diff/(24*3600*1000));
      TempsRestantH = Math.floor(Diff/(3600*1000)) % 24;
      TempsRestantM = Math.floor(Diff/(60*1000)) % 60;
      TempsRestantS = Math.floor(Diff/1000) % 60;
      TempsRestant = "" + destime[6] + " ";  
      if (TempsRestantJ == 1) {
         TempsRestant = TempsRestant + TempsRestantJ + " jour ";
      } else if (TempsRestantJ > 1) {
         TempsRestant = TempsRestant + TempsRestantJ + " jours ";
      }
      TempsRestant = TempsRestant + TempsRestantH + " h " + TempsRestantM  + " min " + TempsRestantS + " s";
      document.getElementById("rebours").innerHTML = TempsRestant;
      setTimeout("Rebours()", 1000)
    }
  } catch (e) {}
}
$(Rebours);

/*extern api, importScript, wgPageName */
/****
fonction qui enlève automatiquement {{m|developpement}} et ajoute {{m|relecture}}
 
****/
$(function () {
    var changeDevelopToReviewButton = document.getElementById('develop_to_review_link');
    if (changeDevelopToReviewButton) {
        try {
            //in a try since this makes some assumptions about the format of
            //the {{tl|developpement}} template, which could change.
            mw.loader.load('//en.wikinews.org/w/index.php?title=User%3ABawolff/mwapilib2.js&action=raw&ctype=text/javascript&scrver=2');
            var button = document.createElement('button');
            button.type = 'button';
            button.appendChild(changeDevelopToReviewButton.firstChild.firstChild);
            changeDevelopToReviewButton.replaceChild(button, changeDevelopToReviewButton.firstChild);
            button.onclick = function () {
                this.disabled = true;
                if (this && this.firstChild && this.firstChild.firstChild && this.firstChild.firstChild.data) this.firstChild.firstChild.data = "Chargement...";
                api(mw.config.get('wgPageName')).getPage().
                    push().
                    setDefaultSummary("Merci de relire cet article (bouton cliquable)").
                    lift( function( input ) { return !input.match( /\{\{[Rr]electure\}\}/ ); }).
                    abortIfFalse().
                    pop().
                    replace(/\{\{[dD]éveloppement?(?:\|[^}]*)?\}\}(?:\n)?/g, "").
                    replace(/^/, "\{\{relecture}}\n").
                    savePage().
                    lift(function () {
                        alert("L'article est maintenant en attente de relecture");
                        location.reload();
                    }).
                    exec();
            }
        }
        catch (e) {}
    }
});

/*extern api, importScript, mw.config.get('wgPageName') */
/****
fonction qui enlève automatiquement {{m|relecture|????}} et ajoute {{m|relecture}}
 
****/
$(function () {
    var changeReviewToReviewButton = document.getElementById('Review_to_review_link');
    if (changeReviewToReviewButton) {
        try {
            //in a try since this makes some assumptions about the format of
            //the {{tl|developpement}} template, which could change.
            mw.loader.load('//en.wikinews.org/w/index.php?title=User%3ABawolff/mwapilib2.js&action=raw&ctype=text/javascript&scrver=2');
            var button = document.createElement('button');
            button.type = 'button';
            button.appendChild(changeReviewToReviewButton.firstChild.firstChild);
            changeReviewToReviewButton.replaceChild(button, changeReviewToReviewButton.firstChild);
            button.onclick = function () {
                this.disabled = true;
                if (this && this.firstChild && this.firstChild.firstChild && this.firstChild.firstChild.data) this.firstChild.firstChild.data = "Chargement...";
                api(mw.config.get('wgPageName')).getPage().
                    push().
                    setDefaultSummary("Merci de relire cet article (bouton cliquable)").
                    lift( function( input ) { return !input.match( /\{\{[Rr]electure\}\}/ ); }).
                    abortIfFalse().
                    pop().
                    replace(/\{\{[Rr]electure\|([^\}]+)\}\}/g, "\{\{relecture}}\n").
                    savePage().
                    lift(function () {
                        alert("L'article est maintenant en attente de relecture");
                        location.reload();
                    }).
                    exec();
            }
        }
        catch (e) {}
    }
});
/**
 * Ajoute la date de dernière modification
 */
function LastModCopy( $ ) {
	// L'id change entre Monobook et Modern d'une part, et Vector d'autre part
	$( '.lastmodcopy' ).html( $( '#lastmod, #footer-info-lastmod' ).html() );
}
$( LastModCopy );