Utilisateur:Tavernier/sous1/JS
Un article de Wikipédia, l'encyclopédie libre.
//
-
var cookieCacheRechercheExterneName = "cacheRechercheExterne";
-
var urls = new Array();
-
-
function ExternalSearch() { //génère le contenu
-
if (wgPageName != "Utilisateur:Tavernier/sous1") return;
-
var mainNode = document.getElementById("searchbox");
-
if (!mainNode) return;
-
-
var c = 0;
-
function CreateButton(name,value,parent,url) {
-
var button = document.createElement("input");
-
button.type = "button";
-
button.value = value;
-
button.setAttribute('onclick','SearchRedir(' + c + ');');
-
parent.appendChild(button);
-
-
urls[c] = url;
-
c++;
-
}
-
-
var span = document.createElement("span");
-
span.style.fontSize = "smaller";
-
-
var a = document.createElement("a");
-
a.href="javascript:affRechercheExterne(true);";
-
a.id = "AfficheRechercheExterne";
-
a.title = "En raison des limitations du moteur de recherche interne, des boutons vers des moteurs externes vous sont temporairement proposés afin de vous aider dans vos recherches";
-
a.style.marginLeft = "1ex";
-
a.appendChild(document.createTextNode(">>"));
-
span.appendChild(a);
-
-
var a = document.createElement("a");
-
a.href="javascript:affRechercheExterne(false);";
-
a.id = "CacheRechercheExterne";
-
a.style.marginLeft = "1ex";
-
a.appendChild(document.createTextNode("<<"));
-
span.appendChild(a);
-
-
getElementsByClass("searchboxSearchButton")[0].parentNode.appendChild(span);
-
-
var div = document.createElement("div");
-
div.id = "BoutonsRechercheExterne";
-
-
CreateButton('exalead','Exalead', div, "http://www.exalead.fr/wikipedia/results?$mode=+csource/15985787839675132773&q=");
-
CreateButton('google','Google', div, "http://www.google.fr/search?as_sitesearch=fr.wikipedia.org&q=");
-
CreateButton('wikiwix','Wikiwix', div, "http://fr.wikiwix.com/?lang=fr&action=");
-
CreateButton('live','Windows Live', div, "http://search.live.com/results.aspx?q1=site:fr.wikipedia.org&q=");
-
CreateButton('yahoo','Yahoo!', div, "http://fr.search.yahoo.com/search?vs=fr.wikipedia.org&p=");
-
-
mainNode.appendChild(div);
-
-
affRechercheExterne((getCookieVal(cookieCacheRechercheExterneName) != "1"));
-
}
-
-
function affRechercheExterne(visible) { //affiche / masque les boutons
-
var date = new Date();
-
var val = visible ? "=0" : "=1";
-
date.setTime(date.getTime() + 30*86400*1000);
-
document.cookie = cookieCacheRechercheExterneName + val + "; expires="+date.toGMTString() + "; path=/";
-
document.getElementById('BoutonsRechercheExterne').style.display = visible ? 'block' : 'none';
-
document.getElementById('CacheRechercheExterne').style.display = visible ? 'inline' : 'none';
-
document.getElementById('AfficheRechercheExterne').style.display = visible ? 'none' : 'inline';
-
}
-
-
function SearchRedir(index) { //lance recherche externe suite pression sur bouton
-
window.location.href = urls[index] + escape(getElementsByClass("searchboxInput")[0].value);
-
}
-
addOnloadHook(ExternalSearch);
-
//