User:Dixtosa/SearchInTranslations.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

$input = $("<input type='text' />").on("input", function(){
    var query = $(this).val().toLowerCase();
    $(this).closest(".NavFrame").children(".NavContent").show().find(".translations tr:first-child li").each(function(){
         this.style.display = this.textContent.toLowerCase().indexOf(query) != -1 ? "block" : "none";
    });
});

$searchDiv = $("<div>").css("display", "inline-block").css("position", "relative").css("left", "25px").append("Search in translations:").append($input);

$(".translations").closest(".NavFrame").children(".NavHead").append($searchDiv);