User:Automatik/common.js

jQuery( function( $ ) { var NSWithoutSubpages = new Array(-1, 0, 6, 14);  if (document.getElementById('p-tb') && NSWithoutSubpages.indexOf( mw.config.get( 'wgNamespaceNumber' )) == -1)    {    var lienSouspages = '/wiki/Special:PrefixIndex/' +  mw.config.get( 'wgPageName' ) + '/';    addPortletLink('p-tb', lienSouspages, 'Sous-pages', 't-subpages', 'Sous-pages de cette page');    } } );

/////////////////////// SpecialChars ////////////////////// // remplacement des séquences de caractères function SpecChar_Main{ tb = document.getElementById("wpTextbox1"); if (!tb) return; tb.onkeyup = function(e) { var key = (window.event) ? event.keyCode : e.keyCode; startPos = tb.selectionStart; endPos = tb.selectionEnd; if ( endPos==startPos && (key>=12 && key<=255) ) { m = tb.value.substring(startPos-2, startPos); m3 = tb.value.substring(startPos-3, startPos); f = tb.value.substring(startPos); todo = true; i = 2;

switch (m) { //traitement de des séquences de 2 caractères case "$s":m="ſ";break; case "$à":m="À";break; case "$é":m="É";break; case "$è":m="È";break; case "$ç":m="Ç";break; case "$-":m="– ";break; case "$_":m="— ";break; case "<<":m="« ";break; case ">>":m=" »";break; case "$ù":m="Ù";break; default:todo=false; }   if (!todo) {     //traitement de des séquences de 3 caractères m = m3; todo = true; i = 3; switch (m) { case "$oe":m="œ";break; case "$ae":m="æ";break; case "$OE":m="Œ";break; case "$AE":m="Æ";break; case "$aa":m="ā";break; case "$ii":m="ī";break; case "$ee":m="ē";break; case "$uu":m="ū";break; case "$oo":m="ō";break; case "$AA":m="Ā";break; case "$II":m="Ī";break; case "$EE":m="Ē";break; case "$UU":m="Ū";break; case "$OO":m="Ō";break; case "...":m="…";break; default:todo=false; }}   if (todo) { var textScroll = tb.scrollTop; h = tb.value.substring(0, startPos-i); tb.value = h+m+f; tb.selectionStart = startPos-i + m.length; tb.selectionEnd = tb.selectionStart; tb.scrollTop = textScroll; }  }  }; } // hookage de la fonction, sauf sur les pages en JS ou CSS // (ce gadget serait une nuisance sur de telles pages) var P3 = wgTitle.substring(wgTitle.length-3); var P4 = wgTitle.substring(wgTitle.length-4); if ((P3 != ".js") && (P4 != ".css")) $(SpecChar_Main);