Utente:Alex brollo/keywords.js
Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
- Opera: premi Ctrl-F5.
function addKw() {
var k = ['<span style="display:none;" class="keywords">', '</span>'];
if ($(".ourDiv").data("kwc") == undefined) $(".ourDiv").data("kwc", k);
if ($(".ourDiv").data("kw") == undefined) {
var kw = find_stringa(leggiBox(), k[0], k[1], 1);
if (kw != "") {
scriviBox(leggiBox().replace(kw, ""))
kw = find_stringa(kw, k[0], k[1], 0).toLocalLowerCase().split(" ");
} else {
kw = [];
}
$(".ourDiv").data("kw", kw);
} else {
kw = $(".ourDiv").data("kw");
}
var sel = selection();
if (sel[1] != "") {
var newKw = "kw" + sel[1].replace(/ /g, "").toLocaleLowerCase();
if ($.inArray(newKw, kw) == -1) {
kw.push(newKw);
$(".ourDiv").data("kw", kw);
}
}
console.log(kw);
}
function srcKw() {
var box = $("#powerSearchText");
var kws = box.val().split(" ");
for (i = 0; i < kws.length; i++) {
kws[i] = "kw" + kws[i];
}
box.val(kws.join(" "));
$("input[type=submit]").eq(0).click();
}
$(document).ready(function () {
var documentURL=document.URL;
if (documentURL.indexOf("http://it.wikisource.org/w/index.php?")==0 &&
documentURL.indexOf("title=Speciale%3ARicerca")>-1) {
$('<input type="button" value="Ricerca per keyword" id="ricKw" onclick="srcKw()" />').insertAfter($("input[type=submit]").eq(0));
}
});