Aller au contenu

Utilisateur:Manecke/monobook.js

Une page de Wikipédia, l'encyclopédie libre.
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
mw.loader.using('mediawiki.util', function () {

/*
 * Appel des fonctions
 * Pour ceux qui seraient étonnés de voir autant de fonctions, en fait j'ai désactivé toute fonction du wikibit.js et du mediawiki:common.js et n'autorise que celles dont j'ai besoin
 * wikibits.js : 2/8
 * mw:common.js : 7/22
 * personnelles : +12
 * total : 21/30
 */

onloadFuncts = [];

obtenir('AdvancedResearch');
adSearchButtons = Array('l','gg','g','reset','c');

//$(addCharSubsetMenu);

obtenir('QPreview');

$(navigation_main);

$(toolbox_main);

$(titre);

$(rewritePageH1);

obtenir('LastContrib');
lastContribNiveau2 = 12*60;
lastContribNiveau3 = 60*60;

$(function(){
 if(!mw.config.get('wgIsArticle')) return;
 h = document.getElementsByTagName('head');
 l = document.createElement('link');
 l.setAttribute('rel', 'next');
 l.setAttribute('href', '/w/index.php?title='+mw.config.get('wgPageName')+'&action=edit');
 h[0].appendChild(l);
});

obtenir('LiensRouges');

$(WAO);

$(IconesDeTitre);

$(createNavigationBarToggleButton);

$(LienAdQouBAouPdQ);

obtenir('RestaurationDeluxe');

obtenir('SuppressionDeluxe');

$(InitPage);

if(mw.config.get('wgAction') == 'edit') addOnloadHook(minorEdit);

$(addBibSubsetMenu);

//-------------------------------------------------------------------------------------------------------------
// Attention : certains de ces scripts sont fait maison spécifiquement pour Opera, et peuvent ne pas marcher pour d'autres navigateurs

/****************************************/
/* Mettre certains namespaces en mineur */
/****************************************/
function minorEdit()
{
 var minor = ',0,8,12,14,104,';
 if(minor.indexOf(','+mw.config.get('wgNamespaceNumber')+',') != -1) document.editform[6].checked = true;
 else document.editform[6].checked = false;
}

/****************************************/
/* Changement de la boîte de navigation */
/* Auteur : Seb35                       */
/****************************************/
function navigation_main()
{
 var d = new Array('janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre');
 var today = new Date(), temp = new String(''), i, j;
 var pages = new Array(
  'Administration',
      new Array('/wiki/Wikipédia:Pages_protégées_à_la_création/'+ucfirst(d[today.getMonth()])+'_'+today.getFullYear()+'?action=edit', 'WP:PPC',
                '/wiki/Wikipédia:Requête_aux_administrateurs', 'WP:RA',
                '/wiki/Wikipédia:Demande_de_suppression_immédiate', 'WP:SI',
                '/wiki/Wikipédia:Vandalisme_en_cours', 'WP:-(',
                '/wiki/Wikipédia:Demande_de_protection_de_page', 'Protection',
                '/wiki/Wikipédia:Demande_d\'intervention_sur_une_page_protégée', 'Intervention',
                '/wiki/Wikipédia:Demande_d\'intervention_sur_un_message_système', 'WP:DIMS',
                '/wiki/Special:Protectedpages', 'Pages protégées',
                '/wiki/Wikipédia:Demande_de_renommage', 'Renommage',
                '/wiki/Wikipédia:Demande_de_restauration_de_page', 'Restauration',
                '/wiki/Wikipédia:Pages_à_supprimer', 'WP:PàS',
                '/wiki/Wikipédia:Images_à_supprimer', 'WP:IàS',
                '/wiki/Wikipédia:Pages_soupçonnées_de_violation_de_copyright', 'WP:PCP',
                '/wiki/Special:Log', 'Journaux',
                '/wiki/Special:Log/newusers', ' /nouveaux',
                '/wiki/Special:Allmessages', 'Allmessages',
                '/wiki/Special:Undelete', 'Undelete',
                '/wiki/Special:Blockip', 'Blockip',
                '/wiki/Special:Ipblocklist', 'Ipblocklist'
               ),
  'Maintenance',
      new Array('/wiki/Special:Recentchanges?hideliu=1&limit=200', 'RC IP',
                '/wiki/Special:Contributions/newbies', 'RC newbies',
                '/wiki/Special:Newpages', 'Nouvelles pages',
                '/wiki/Special:Newimages', 'Nouvelles images',
                '/wiki/Special:Deadendpages', 'Impasses',
                '/wiki/Wikipédia:Pages_en_impasse', ' WP:PeI',
                '/wiki/Special:CrossNamespaceLinks', 'Croisés',
                '/wiki/Special:Withoutinterwiki', 'Sans interwiki',
                '/wiki/Catégorie:Article_à_wikifier', 'À wikifier',
                '/wiki/Special:Wantedcategories', 'Wantedcategories',
                '/wiki/Wikipédia:Pages_à_fusionner', 'WP:PàF',
                '/wiki/Projet:Maintenance', 'WP:CM'
               ),
  'Autres',
      new Array('/wiki/Wikipédia:Bulletin_des_administrateurs', 'WP:BA',
                '/wiki/Wikipédia:Le_Bistro/'+today.getDate()+'_'+d[today.getMonth()]+'_'+today.getFullYear(), 'Le Bistro '+today.getDate()+'/'+(today.getMonth()+1),
                '/wiki/Wikipédia:Conventions_typographiques', 'WP:CTYP',
                '/wiki/Wikipédia:Conditions_d\'admissibilité_des_articles', 'WP:Cdada',
                '/wiki/Wikipédia:Conventions_filmographiques/Présentation_des_films', 'CTYP films',
                '/wiki/Wikipédia:Modèles', 'Modèles',
                '/wiki/Catégorie:Modèle:Racine', 'Modèle:Racine',
                '/wiki/Special:Prefixindex/MediaWiki:JSScripts', 'JSScripts',
                '/wiki/Utilisateur:Seb35/monobook.js', 'JS perso',
                '/wiki/Utilisateur:Seb35/monobook.css', 'CSS perso',
                '/wiki/MediaWiki:Common.js', 'Common.js',
                '/wiki/MediaWiki:Common.css', 'Common.css',
                '/wiki/MediaWiki:Monobook.css', 'Monobook.css',
                '/wiki/Projet:Mathématiques', 'Projet maths',
                '/wiki/Projet:Accueil', 'WP:PROJ',
                '/wiki/Projet:Traduction', 'WP:PT'
               )
 );
 
 document.getElementById('n-aboutwp').style.display = 'none';
 document.getElementById('n-sitesupport').style.display = 'none';
 for(i=0; i<(pages.length)/2; i++)
 {
  temp += '<li><a style="cursor:pointer;" onMouseOver="timerNavigation = setTimeout(toggleMenu, 300, this.parentNode.nextSibling, 1);" onMouseOut="clearTimeout(timerNavigation);" onClick="clearTimeout(timerNavigation); toggleMenu(this.parentNode.nextSibling);">';
  temp += pages[2*i];
  temp += '</a></li><span style="display:none;">';
  for(j=0; j<(pages[2*i+1].length)/2; j++) { temp += '<li><a href="'; temp += pages[2*i+1][2*j]; temp += '">'; temp += pages[2*i+1][2*j+1]; temp += '</a></li>'; }
  temp += '</span>';
 }
 document.getElementById('p-Contribuer').getElementsByTagName('ul')[0].innerHTML += temp;
}

/************************************************/
/* Ouvre un menu créé par la fonction ci-dessus */
/************************************************/
function toggleMenu(a, o)
{
 if(a.style.display == 'inline' && o != 1) a.style.display = 'none';
 else if(a.style.display == 'none') a.style.display = 'inline';
}
function ucfirst(w) { return w.charAt(0).toUpperCase()+w.substr(1); }

/************************************************/
/* Ajoute des liens vers certains outils sympas */
/************************************************/
function toolbox_main()
{
 var temp = new String(''), utilisateur = new String('');
 
 try { document.getElementById('t-print').style.display = 'none'; } catch(e) {};
 try { document.getElementById('t-cite').style.display = 'none'; } catch(e) {};
 
 if(mw.config.get('wgCanonicalSpecialPageName') == 'Newpages') {
   timerNewpages = setTimeout("location.replace(document.URL); return;", 210*1000);
   temp += '<hr />';
   temp += '<li id="newpages-stop"><a href="javascript:clearTimeout(timerNewpages);document.getElementById(\'newpages-stop\').style.display=\'none\';return;">Arrêter le rechargement</a></li>';
   temp += '<li><a href="javascript:location.replace(document.URL); return false;">Purger la page</a></li>';
 }
 
 if(mw.config.get('wgNamespaceNumber') != -1) {
   temp += '<hr />';
   temp += '<li><a href="/wiki/'+mw.config.get('wgPageName')+'?action=purge">Purger la page</a></li>';
   temp += '<li><a href="http://www.google.com/search?num=100&amp;q=' + mw.config.get('wgTitle') + '+site:wikipedia.org+-site:fr.wikipedia.org">Google</a> <a href="http://www.google.com/search?num=100&amp;q=' + mw.config.get('wgTitle') + '+site:en.wikipedia.org">(en)</a> <a href="http://www.google.com/search?num=100&amp;q=' + mw.config.get('wgTitle') + '+site:de.wikipedia.org">(de)</a> <a href="http://www.google.com/search?num=100&amp;q=' + mw.config.get('wgTitle') + '+site:fr.wikipedia.org">(fr)</a></li>';
 }
 
 if(mw.config.get('wgNamespaceNumber') == 2 || mw.config.get('wgNamespaceNumber') == 3 || mw.config.get('wgCanonicalSpecialPageName') == 'Contributions')
 {
  if(mw.config.get('wgNamespaceNumber') == -1)
  {
   if(document.URL.indexOf('target\=') != -1) utilisateur = document.URL.replace(/.*target\=(.+)/i, '$1').replace(/&/, '>').replace(/(.+)>(?:.*)/, '$1');
   else utilisateur = /.*Special:Contributions\/(.+)/i.exec(document.URL)[1];
  }
  else utilisateur = mw.config.get('wgTitle').replace(/\//, '>').replace(/(.*)>.*/, '$1');
  temp += '<hr />';
  temp += '<li><a href="/wiki/Special:Log?user=' + utilisateur + '">Journaux</a></li>';
  temp += '<li><a href="http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=frwiki_p&user=' + utilisateur + '">Ancienneté</a></li>';
 }
 
 document.getElementById('p-tb').getElementsByTagName('ul')[0].innerHTML += temp;
 
 mw.util.addPortletLink('p-personal', '/wiki/Utilisateur:Seb35/Potager?action=edit', 'Potager', '', '', '', document.getElementById('pt-preferences'));
 mw.util.addPortletLink('p-personal', '/wiki/Special:Log?user=Seb35', 'Actions', '', '', '', document.getElementById('pt-logout'));
}

//Quelques raccourcis pour Opera dont les normaux ne sont pas très pratiques
function shortcutsOpera(ev)
{
 if(ev.ctrlKey && ev.keyCode == 32 && document.getElementById('wpTextbox1')) document.editform.wpTextbox1.focus();
 if(ev.ctrlKey && ev.shiftKey) document.adsearch.adinput.focus();
}
hookEvent('keydown', shortcutsOpera);

//Aide à la wikification
var WAOAjax = null;
var WAOMaj = false;
function WAO()
{
 if(!document.getElementById('wpTextbox1')) return;
 
 WAOAjax = new XMLHttpRequest();
 var coche = WAOCookie(1, 'WAO');
 
 var labeltag = document.editform.getElementsByTagName('label');
 var i = 0; while(labeltag[i].getAttribute('for') != 'wpWatchthis') i++;
 var suivant = labeltag[i].nextSibling;
 
 var span = document.createElement('span');
 span.innerHTML =
  ' <input type="checkbox" name="WAOCheckbox" id="WAOCheckbox"'+coche+' onclick="WAOCookie(0, \'WAO\', this);" /> <label for="WAOCheckbox">WAO</label>' +
  '<span id="WAOAutres" style="display:'+(coche ? 'inline' : 'none')+';">' +
  ' <input type="checkbox" name="WAOAjax" id="WAOAjax"'+WAOCookie(1,'WAOAjax')+' onclick="WAOCookie(0, \'WAOAjax\', this);" /> <label for="WAOAjax">Ajax</label>' +
  ' <input type="checkbox" name="WAOGoog" id="WAOGoog"'+WAOCookie(1,'WAOGoogle')+' onclick="WAOCookie(0, \'WAOGoogle\', this);" /> <label for="WAOGoog">Google</label>' +
  ' <input type="checkbox" name="WAOWP" id="WAOWP"'+WAOCookie(1,'WAOWP')+' onclick="WAOCookie(0, \'WAOWP\', this);" /> <label for="WAOWP">Wikipédia</label>' +
  ' <input type="checkbox" name="WAOAdsearch" id="WAOAdsearch"'+WAOCookie(1,'WAOAdsearch')+' onclick="WAOCookie(0, \'WAOAdsearch\', this);" /> <label for="WAOAdsearch">Rechercher</label>' +
  '</span>';
 suivant.parentNode.insertBefore(span, suivant);
 
 if(WAOAjax)
 {
  var a = document.getElementById('column-one');
  a.innerHTML = a.innerHTML
   + '<div id="p-WAO" class="portlet" style="display:'+(WAOAjax && coche && WAOCookie(1,'WAOAjax') ? 'block' : 'none')+';">'
   + '<h5>WAO</h5>'
   + '<div class="pBody">'
   + '<ul>'
   + '<li><u>Mot</u> : <span id="WAOMot"></span></li>'
   + '<li>Google : <span id="WAOGoogle"></span></li>'
   + '<li>Article : <span id="WAOArticle"></span></li>'
   + '<li>Pages liées : <span id="WAOLiees"></span></li>'
   + '</ul>'
   + '</div>'
   + '</div>';
 }
 
 document.editform.wpTextbox1.setAttribute('onkeyup', 'if(event.shiftKey == false) WAOOuvrir();');
 document.editform.wpTextbox1.setAttribute('onkeydown', 'WAOMaj = event.shiftKey;');
 document.editform.wpTextbox1.setAttribute('onselect', 'if(WAOMaj == false) WAOOuvrir();');
}

function WAOCookie(lire, nom, objet)
{
 if(lire)
 {
  var cookiePos = document.cookie.indexOf(nom+'=');
  if (cookiePos > -1 && document.cookie.charAt(cookiePos+nom.length+1) == '1') return ' checked="checked"';
  else return '';
 }
 else
 {
  if(objet.checked) document.cookie = nom+'=1';
  else document.cookie = nom+'=0';
  if(nom == 'WAO')
  {
   if(objet.checked) document.getElementById('WAOAutres').style.display = 'inline';
   else document.getElementById('WAOAutres').style.display = 'none';
  }
  if(WAOAjax && (nom == 'WAO' || nom == 'WAOAjax'))
  {
   if(document.editform.WAOCheckbox.checked && document.editform.WAOAjax.checked) document.getElementById('p-WAO').style.display = 'block';
   else document.getElementById('p-WAO').style.display = 'none';
  }
 }
}

function WAOOuvrir()
{
 WAOMaj = false;
 var txtarea = document.editform.wpTextbox1;
 if(!document.editform.WAOCheckbox.checked) return;
 if(txtarea.selectionStart || txtarea.selectionStart == '0')
 {
  var startPos = txtarea.selectionStart;
  var endPos = txtarea.selectionEnd;
  if(startPos == endPos) return;
  var myText = (txtarea.value).substring(startPos, endPos);
  var dat = new Date();
  
  if(myText.length >= 255 || myText.search(/[\f\n\r\t\v\|\[\]]/) != -1) return;
  
  if(WAOAjax && document.editform.WAOAjax.checked)
  {
   WAOAjax.open('get', mw.config.get('wgServer')+'/w/api.php?action=query&format=xml&list=backlinks&bllimit=20&prop=info&titles=' + myText, false);
   WAOAjax.onreadystatechange = WAOResponse;
   WAOAjax.send(null);
  }
  if(document.editform.WAOGoog.checked)
  {
   var fenetre = window.open('http://www.google.com/search?num=100&q='+myText+'+site:fr.wikipedia.org', 'f1'+dat.getTime(), 'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
   fenetre.blur();
  }
  if(document.editform.WAOWP.checked)
  {
   var fenetre = window.open('http://fr.wikipedia.org/wiki/'+myText, 'f2'+dat.getTime(), 'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
   fenetre.blur();
  }
  if(document.editform.WAOAdsearch.checked) document.adsearch.adinput.value = myText;
 }
}

function WAOResponse()
{
 if(WAOAjax.readyState == 4)
 {
  xmlDoc = WAOAjax.responseXML;
  mot = xmlDoc.getElementsByTagName('page')[0].getAttribute('title');
  
  document.getElementById('WAOMot').innerHTML = mot;
  
  document.getElementById('WAOGoogle').innerHTML = '<a href="http://www.google.com/search?num=100&as_occt=any&q=' + mot + '+site:fr.wikipedia.org">??</a>';
  
  page = xmlDoc.getElementsByTagName('page');
  mot = mot.replace(/ /g, '_');
  redirect = (page[0].getAttribute('redirect') == '');
  if(page[0].getAttribute('missing') == '') document.getElementById('WAOArticle').innerHTML = 'non';
  else document.getElementById('WAOArticle').innerHTML = '<a href="'+mw.config.get('wgServer')+'/wiki/'+mot+'">'+(redirect ? '<i>Existe !</i>' : 'Existe !')+'</a>';
  
  nb = xmlDoc.getElementsByTagName('bl').length;
  if(nb == 0) document.getElementById('WAOLiees').innerHTML = '0';
  else document.getElementById('WAOLiees').innerHTML = '<a href="'+mw.config.get('wgServer')+'/wiki/Special:Whatlinkshere/'+mot+'">'+(nb == 20 ? 'beaucoup' : nb)+'</a>';
 }
}

function titre() {
 if(document.getElementById('wpTextbox1')) { document.getElementsByTagName('h1')[0].innerHTML = mw.config.get('wgPageName').replace(/_/g,' '); }
}

// Remplacement de cette fonction pour ne pas effectuer des trucs inutiles (pour moi)
function runOnloadHook() {
  if (doneOnloadHook) {
    return;
  }
  doneOnloadHook = true;
  unhidetzbutton();
  sortables_init();
  for (var i = 0; i < onloadFuncts.length; i++) {
    onloadFuncts[i]();
  }
}

});