Aller au contenu

Utilisateur:Guillaumito/monobook.js

Définition, traduction, prononciation, anagramme et synonyme sur le dictionnaire libre Wiktionnaire.

Remarque: après avoir sauvegardé, vous devez vider le cache de votre navigateur pour que les changements prennent effet. Mozilla, cliquez sur Actualiser (ou ctrl-r). Internet Explorer / Opera: ctrl-f5. Safari: cmd-r. Konqueror ctrl-r.

// Amélioration de la page de recherche v3
// Auteur : Marc Mongenet (Wikipédia : [[w:Utilisateur:Marc Mongenet]])
// Adaptation au Wiktionnaire par Darkdadaah (modifications mineures)
// Sous licence GFDL & GPL
 
function SpecialSearchEnhancedY() 
{
 
  function SearchForm(search_action_url, engine_url, engine_name, logo_url,
                      search_field_name, search_field_value, site_field_name, site_field_value)
  {
    var span = document.createElement("span");
    span.style.marginRight = "1em";
    span.style.whiteSpace = "nowrap";
 
    var form = document.createElement("form");
    form.method = "get";
    form.action = search_action_url;
    form.style.display = "inline";
    span.appendChild(form);
 
    var input = document.createElement("input");
    input.type = "hidden";
    input.name = search_field_name;
    form.appendChild(input);
 
    var site = document.createElement("input");
    site.type = "hidden";
    site.name = site_field_name;
    site.value = site_field_value;
    form.appendChild(site);
 
    var submit = document.createElement("input");
    submit.type = "submit";
    submit.value = "Recherche";
    form.appendChild(submit);
 
    try {
      form.addEventListener('submit', function() {
        var searchInput = document.getElementById("searchText");

        if (! searchInput) searchInput = document.getElementById("powerSearchText");
 
        input.value = searchInput.value;
      }, false);
    } catch(someerror) {
      form.attachEvent('onsubmit', function() {
        var searchInput = document.getElementById("searchText");

        if (! searchInput) searchInput = document.getElementById("powerSearchText");
 
        input.value = searchInput.value;
      });
    }
 
    var a = document.createElement("a");
    a.href = engine_url;
    span.appendChild(a);
 
    var img = document.createElement("img");
    img.src = logo_url;
    img.alt = engine_name;
    img.style.borderWidth = "0";
    img.style.padding = "5px";
    a.appendChild(img);
 
    return span;
  }
 
  if (typeof SpecialSearchEnhanced3Disabled != 'undefined') return;
  if ((wgNamespaceNumber == -1) && (wgCanonicalSpecialPageName == "Recherche")) return;
 
  var mainNode = document.getElementsByTagName("form");
  if (!mainNode) return;
  mainNode = mainNode[0];
  if (mainNode.nextSibling) {
    mainNode = mainNode.nextSibling;
    mainNode = mainNode.parentNode.insertBefore(document.createElement("center"), mainNode);
  } else {
    mainNode = mainNode.parentNode.appendChild(document.createElement("center"));
  }

  var searchInput = document.getElementById("searchText");

  if (! searchInput) searchInput = document.getElementById("powerSearchText");
 
  var searchValue = searchInput.value;

  var engine;
  engine = SearchForm("http://partner.exalead.fr/search", "http://www.exalead.fr/", "Exalead",
                      "http://www.exalead.com/apogee/exalead-wikipedia-logo-small.gif", "q", searchValue,
                      "site", "fr.wiktionary.org");
  mainNode.appendChild(engine);
  engine = SearchForm("http://www.google.fr/search", "http://www.google.fr/", "Google",
                      "http://www.google.com/logos/Logo_25wht.gif", "q", searchValue,
                      "as_sitesearch", "fr.wiktionary.org");
  mainNode.appendChild(engine);
  engine = SearchForm("http://fr.wikiwix.com", "http://fr.wikiwix.com/", "WikiWix",
                      "http://logo.wikiwix.com/logo_mini.png", "action", searchValue,
                      "disp", "dict");
  mainNode.appendChild(engine);
  engine = SearchForm("http://search.live.com/results.aspx", "http://search.live.com/", "Live",
                      "http://search.live.com/s/affillogoLive.gif", "q", searchValue,
                      "q1", "site:http://fr.wiktionary.org");
  mainNode.appendChild(engine);
  engine = SearchForm("http://fr.search.yahoo.com/search", "http://fr.search.yahoo.com/", "Yahoo!",
                      "http://us.yimg.com/i/yahootogo/y88red2.gif", "p", searchValue,
                      "vs", "fr.wiktionary.org");
  mainNode.appendChild(engine);
}
 
$(SpecialSearchEnhancedY);