For faster navigation, this Iframe is preloading the Wikiwand page for Utilisateur:Dr Brains/myName.js.

Utilisateur:Dr Brains/myName.js

/*
Code original : [[:en:User:ais523/highlightmyname2.js]] 
 
Ajoute un bouton dans la zone de recherche permettant de surligner dans la page toutes les occurrences du texte rentré.

((Projet:JavaScript/Script))
((Boîte déroulante début|titre=Code source))<!--
*/
// --><syntaxhighlight lang=javascript>
//<nowiki>
var countcolors = 0;
var surlignerCouleurs = new Array();

///////////////////////////////////////////////// PARTIE PERSONNALISABLE //////////////////////////////////////////

// Couleurs successives de surlignage 

surlignerCouleurs[0] = "#DDBBBB"
surlignerCouleurs[1] = "#BBBBBB"
surlignerCouleurs[2] = "#DDBBDD"
surlignerCouleurs[3] = "#DDDDBB"
surlignerCouleurs[4] = "#BBBBDD"
surlignerCouleurs[5] = "#DDBB99"
surlignerCouleurs[6] = "#DD99BB"
surlignerCouleurs[7] = "#DD9999"
surlignerCouleurs[8] = "#BB99BB"
surlignerCouleurs[9] = "#BBBB99"
surlignerCouleurs[10] = "#99BB99"
surlignerCouleurs[11] = "#9999BB"

///////////////////////////////////////////////// FIN DE LA PARTIE PERSONNALISABLE //////////////////////////////////////////

var maxcountcolors = surlignerCouleurs.length;
function surlignerUnMot(n, p, string){ // node, parent node, string                    
      while(n!=null) {
            if(n.nodeType==3) {
                  if(n.data.toLowerCase().indexOf(string.toLowerCase())!=-1) {
                        var ix=n.data.toLowerCase().indexOf(string.toLowerCase());
                        var t1=ix?document.createTextNode(n.data.substr(0,ix)):null;
                        var t2=document.createTextNode(n.data.substr(ix,string.length));
                        var t3=ix+string.length==n.data.length?null:
                        document.createTextNode(n.data.substr(ix+string.length));
                        var s1=document.createElement("span");
                        s1.style.backgroundColor=surlignerCouleurs[countcolors];
                        s1.appendChild(t2);
                        var s2=document.createElement("span");
                        if(t1!=null) s2.appendChild(t1);
                        s2.appendChild(s1);
                        if(t3!=null) s2.appendChild(t3);
                        p.replaceChild(s2,n);
                        if(t3!=null) surlignerUnMot(t3,s2, string ); //find remaining occurences in the new nodes
                        n=s2.nextSibling;
                  } else {
                        n=n.nextSibling;
                  }
            } else{
                  if(n.firstChild!=null) surlignerUnMot(n.firstChild,n,string);
                  n=n.nextSibling;
            }
      }
}

function surlignerLeMot(){

        var Document = document.getElementById('bodyContent');                // Monobook, Poussin, Mon Interface, Simple, Vector
        if(!Document)Document = document.getElementById('mw_contentholder');  // Moderne
        if(!Document)Document = document.getElementById('article');           // Bleu de Cologne, Nostalgia, Standard
        if(!Document)Document = document.body;                                // Autres

        var Input = document.getElementById('searchInput');
        if(!Input) return;
        var Mot = Input.value;
        if( (Mot!=null) && (Mot!='') ){
              surlignerUnMot( Document.firstChild , Document , Mot);
              countcolors = (countcolors+1);
              if(countcolors>maxcountcolors) countcolors = 0;
        }
}

function ajouterBoutonSurlignage(){
        var OldSearchForm = document.getElementById("searchform");
        if(!OldSearchForm) return;
        if(typeof(surlignerCouleurs_Custom)==="object") surlignerCouleurs = surlignerCouleurs_Custom;
        OldSearchForm.setAttribute("style", "text-align:center"); 
        var NewForm = '<input type="button" class="searchButton" style="width:123px;display:inline;" title="Cliquer pour surligner" value="Surligner" onclick="surlignerLeMot();" onselect="surlignerLeMot();"/>';
        OldSearchForm.innerHTML = OldSearchForm.innerHTML + NewForm;
}
 
$( ajouterBoutonSurlignage);

//</nowiki>
//</syntaxhighlight>
//((Boîte déroulante fin))
{{bottomLinkPreText}} {{bottomLinkText}}
Utilisateur:Dr Brains/myName.js
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?