MediaWiki:Common.js: mudanças entre as edições
De CIGAM WIKI
Sem resumo de edição |
Sem resumo de edição |
||
| Linha 5: | Linha 5: | ||
var customInput = document.getElementById("p-search"); | var customInput = document.getElementById("p-search"); | ||
var path = window.location.href; | var path = window.location.href; | ||
ChamaRemoveTags(); | |||
console.log(path); | console.log(path); | ||
if (path.includes("Especial:Busca")) { | if (path.includes("Especial:Busca")) { | ||
| Linha 88: | Linha 91: | ||
// HTML tag with a null string. | // HTML tag with a null string. | ||
return str.replace( /(<([^>]+)>)/ig, ''); | return str.replace( /(<([^>]+)>)/ig, ''); | ||
} | |||
function ChamaRemoveTags() { | |||
const testElements = document.getElementsByClassName("searchresult") | |||
/* for(let i = 0; i < testElements.length; i = i + 1 ) { | |||
if(testElements[i] != null) { | |||
testElements[i].innerText = removeTags(testElements[i].innerText); | |||
} | |||
} */ | |||
console.log(testElements); | |||
} | } | ||
Edição das 14h42min de 11 de julho de 2023
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
document.querySelector("#site-tools").style.setProperty("display", "none", "important"); document.querySelector("#page-tools").style.setProperty("display", "none", "important");
var customInput = document.getElementById("p-search");
var path = window.location.href;
ChamaRemoveTags();
console.log(path);
if (path.includes("Especial:Busca")) {
customInput = null;
}
if (path.includes("Chat_com_IA")) {
customInput.innerHTML = "<div class='search'><input type='text' id='bingPrincipalChatInput' placeholder='Pergunte-me qualquer coisa...' onFocus='listenerChat()'/><input type='submit' id='bingPrincipalChatButton' value='Buscar' onclick='ChatPrincipalBing();' /></div>";
}
else {
customInput.innerHTML = "<div class='search'><input type='text' id='bingPrincipalSearchInput' placeholder='Pergunte-me qualquer coisa...' onFocus='listener()'/><input type='submit' id='bingPrincipalSearchButton' value='Buscar' onclick='PesquisaPrincipalBing();' /></div>";
}
function listener() {
var inputPrincipal = document.getElementById("bingPrincipalSearchInput");
inputPrincipal.addEventListener("keyup", function (event) {
if (event.keyCode === 13) {
event.preventDefault();
document.getElementById("bingPrincipalSearchButton").click();
}
});
}
function listenerChat() {
var inputPrincipal = document.getElementById("bingPrincipalChatInput");
inputPrincipal.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
event.preventDefault();
document.getElementById("bingPrincipalChatButton").click();
}
});
}
var input = document.getElementById("bingSearchInput");
input.addEventListener("keyup", function (event) {
if (event.keyCode === 13) {
event.preventDefault();
document.getElementById("bingSearchButton").click();
}
});
function PesquisaPrincipalBing() {
var search = document.getElementById("bingPrincipalSearchInput");
if (search.value != "") {
window.open(
"https://www.bing.com/search?q=site:cigam.com.br+" +
search.value,
"_self"
);
}
}
function PesquisaBing() {
var search = document.getElementById("bingSearchInput");
if (search.value != "") {
window.open(
"https://www.bing.com/search?q=site:cigam.com.br+" +
search.value,
"_self"
);
}
}
function ChatBing() {
var search = document.getElementById("bingSearchInput");
if (search.value != "") {
window.open(
"https://www.bing.com/search?form=WSBCSL&showconv=1&sendquery=1&q=site:cigam.com.br+" +
search.value,
"_self"
);
}
}
function removeTags(str) {
if ((str===null) || (str===''))
return false;
else
str = str.toString();
// Regular expression to identify HTML tags in
// the input string. Replacing the identified
// HTML tag with a null string.
return str.replace( /(<([^>]+)>)/ig, '');
}
function ChamaRemoveTags() {
const testElements = document.getElementsByClassName("searchresult")
/* for(let i = 0; i < testElements.length; i = i + 1 ) {
if(testElements[i] != null) {
testElements[i].innerText = removeTags(testElements[i].innerText);
}
} */
console.log(testElements);
}
