Content deleted Content added
undo documentation hack |
var SearchRegexes should add to, not replace, the default values. |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1:
/*<
Based on [[User:SiBr4/TemplateSearch.js]] by [[User:SiBr4]], with added support for the Vector 2022 and Minerva Neue skins.
Line 14:
if (searchbox.classList.contains("cdx-text-input__input") || searchbox.classList.contains("search") || searchbox.id == "searchInput") {
searchbox.setAttribute("onkeyup","replaceBracesInSearch(this);");
searchbox.setAttribute("onpaste","replaceBracesInSearch(this);");
replaceBracesInSearch(searchbox);
}
Line 19 ⟶ 20:
}
var SearchRegexes =
"^(\\\{\\\{#invoke|[Mm][Dd]):":"Module:",
"^(\\\{\\\{|[Tt][Pp]:)":"Template:",
"\\\}\\\}$":"",
...SearchRegexes
};
function replaceBracesInSearch(box) {
for (var search in SearchRegexes) {
Line 25 ⟶ 31:
if(re.test(box.value)) {
box.value=box.value.replace(re,SearchRegexes[search]);
box.dispatchEvent(new Event('input'));
}
}
Line 38 ⟶ 45:
} );
} );
//</syntaxhighlight></
|