MediaWiki:Common.js: mudanças entre as edições
De CIGAM WIKI
Sem resumo de edição |
Sem resumo de edição Etiqueta: Reversão manual |
||
| (21 revisões intermediárias por 2 usuários não estão sendo mostradas) | |||
| Linha 1: | Linha 1: | ||
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */ | /* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */ | ||
if (!mw.config.get('wgUserGroups').includes('sysop')) { | |||
document.querySelector("#site-tools").style.setProperty("display", "none", "important"); | |||
document.querySelector("#page-tools").style.setProperty("display", "none", "important"); | |||
} | |||
if (mw.config.get('wgUserGroups').includes('sysop')) { | |||
var tbList = document.querySelector("#p-tb ul"); | |||
if (tbList) { | |||
var li = document.createElement("li"); | |||
li.className = "mw-list-item"; | |||
li.innerHTML = '<a href="/wiki/index.php?title=Especial:P%C3%A1ginas_especiais"><span>Páginas especiais</span></a>'; | |||
tbList.appendChild(li); | |||
} | |||
} | |||
var customInput = document.getElementById("p-search"); | var customInput = document.getElementById("p-search"); | ||
var path = window.location.href; | var path = window.location.href; | ||
ChamaRemoveTags(); | ChamaRemoveTags(); | ||
console.log(path); | console.log(path); | ||
if (path.includes("Especial:Busca")) { | if (path.includes("Especial:Busca")) { | ||
customInput = null; | customInput = null; | ||
} | } | ||
if (path.includes("Chat_com_IA")) { | 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>"; | 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 { | ||
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>"; | ||
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=' | |||
} | } | ||
function listener() { | function listener() { | ||
var inputPrincipal = document.getElementById("bingPrincipalSearchInput"); | var inputPrincipal = document.getElementById("bingPrincipalSearchInput"); | ||
inputPrincipal.addEventListener("keyup", function (event) { | inputPrincipal.addEventListener("keyup", function (event) { | ||
if (event.keyCode === 13) { | if (event.keyCode === 13) { | ||
event.preventDefault(); | event.preventDefault(); | ||
document.getElementById("bingPrincipalSearchButton").click(); | document.getElementById("bingPrincipalSearchButton").click(); | ||
} | } | ||
}); | }); | ||
} | } | ||
function listenerChat() { | function listenerChat() { | ||
var inputPrincipal = document.getElementById("bingPrincipalChatInput"); | var inputPrincipal = document.getElementById("bingPrincipalChatInput"); | ||
inputPrincipal.addEventListener("keyup", function(event) { | inputPrincipal.addEventListener("keyup", function (event) { | ||
if (event.keyCode === 13) { | if (event.keyCode === 13) { | ||
event.preventDefault(); | event.preventDefault(); | ||
document.getElementById("bingPrincipalChatButton").click(); | document.getElementById("bingPrincipalChatButton").click(); | ||
} | |||
}); | |||
} | } | ||
var input = document.getElementById("bingSearchInput"); | var input = document.getElementById("bingSearchInput"); | ||
input.addEventListener("keyup", function (event) { | if (input) { | ||
if (event.keyCode === 13) { | input.addEventListener("keyup", function (event) { | ||
event.preventDefault(); | if (event.keyCode === 13) { | ||
document.getElementById("bingSearchButton").click(); | event.preventDefault(); | ||
document.getElementById("bingSearchButton").click(); | |||
} | |||
}); | |||
} | } | ||
/* Método ajustado para chamada do Google, mantendo nomes e IDs inalterados para evitar possíveis problemas de indexação. */ | |||
function PesquisaPrincipalBing() { | function PesquisaPrincipalBing() { | ||
var search = document.getElementById("bingPrincipalSearchInput"); | var search = document.getElementById("bingPrincipalSearchInput"); | ||
if (search.value != "") { | if (search.value != "") { | ||
window.open( | window.open( | ||
"https://www. | "https://www.google.com/search?q=site:www.cigam.com.br+" + search.value, | ||
search.value, | "_self" | ||
"_self" | ); | ||
); | } | ||
} | } | ||
/* Método ajustado para chamada do Google, mantendo nomes e IDs inalterados para evitar possíveis problemas de indexação. */ | |||
function PesquisaBing() { | function PesquisaBing() { | ||
var search = document.getElementById("bingSearchInput"); | var search = document.getElementById("bingSearchInput"); | ||
if (search.value != "") { | if (search.value != "") { | ||
window.open( | window.open( | ||
"https://www. | "https://www.google.com/search?q=site:www.cigam.com.br+" + search.value, | ||
search.value, | "_self" | ||
"_self" | ); | ||
); | } | ||
} | |||
} | } | ||
function ChatBing() { | function ChatBing() { | ||
var search = document.getElementById("bingSearchInput"); | var search = document.getElementById("bingSearchInput"); | ||
if (search.value != "") { | if (search.value != "") { | ||
window.open( | window.open( | ||
"https://www.bing.com/search?form=WSBCSL&showconv=1&sendquery=1&q=site:www.cigam.com.br+" + | "https://www.bing.com/search?form=WSBCSL&showconv=1&sendquery=1&q=site:www.cigam.com.br+" + search.value, | ||
search.value, | "_self" | ||
"_self" | ); | ||
); | } | ||
} | } | ||
function removeTags(str) { | function removeTags(str) { | ||
if ((str===null) || (str==='')) | if ((str === null) || (str === '')) | ||
return false; | return false; | ||
else | else | ||
str = str.toString(); | str = str.toString(); | ||
return str.replace(/(<([^>]+)>)/ig, ''); | |||
return str.replace( /(<([^>]+)>)/ig, ''); | |||
} | } | ||
function ChamaRemoveTags() { | function ChamaRemoveTags() { | ||
const testElements = document.getElementsByClassName("searchresult"); | |||
var i = 0; | |||
while (testElements[i] != null) { | |||
testElements[i].innerText = removeTags(testElements[i].innerText); | |||
i = i + 1; | |||
} | |||
} | } | ||
/* Redireciona o site da Cigam para uma nova aba */ | |||
$(function () { | |||
$('.cigam-cta-wrapper a').attr('target', '_blank').attr('rel', 'noopener noreferrer'); | |||
}); | |||
/* Botão flutuante redireciona o site da Cigam para uma nova aba */ | |||
$(function () { | |||
var floatingBtn = $('<a>', { | |||
href: 'https://www.cigam.com.br/', | |||
target: '_blank', | |||
rel: 'noopener noreferrer', | |||
title: 'Acessar site', | |||
class: 'cigam-cta-floating' | |||
}); | |||
var icon = $('<span>', { class: 'cigam-cta-floating-icon' }); | |||
var text = $('<span>', { class: 'cigam-cta-floating-text', text: 'Acessar site' }); | |||
floatingBtn.append(icon).append(text); | |||
$('body').append(floatingBtn); | |||
}); | |||
/* Botão ao lado do buscar que redireciona o site da Cigam para uma nova aba */ | |||
$(function () { | |||
var siteBtn = $('<a>', { | |||
href: 'https://www.cigam.com.br/', | |||
target: '_blank', | |||
rel: 'noopener noreferrer', | |||
text: 'Site', | |||
class: 'cigam-header-btn' | |||
}); | |||
$('#bingPrincipalSearchButton').after(siteBtn); | |||
}); | |||
/* Ícone Cigam by Senior que redireciona pro site */ | |||
$(function () { | |||
var headerLogoLink = $('<a>', { | |||
href: 'https://www.cigam.com.br/', | |||
target: '_blank', | |||
rel: 'noopener noreferrer', | |||
title: 'Acessar site' | |||
}); | |||
var headerLogo = $('<img>', { | |||
src: 'https://www.cigam.com.br/wiki/thumb.php?f=Logo%20cigam.png&width=140', | |||
alt: 'CIGAM', | |||
class: 'cigam-header-logo' | |||
}); | |||
headerLogoLink.append(headerLogo); | |||
$('#p-logo-text').prepend(headerLogoLink); | |||
}); | |||
Edição atual tal como às 12h02min de 31 de agosto de 2026
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
if (!mw.config.get('wgUserGroups').includes('sysop')) {
document.querySelector("#site-tools").style.setProperty("display", "none", "important");
document.querySelector("#page-tools").style.setProperty("display", "none", "important");
}
if (mw.config.get('wgUserGroups').includes('sysop')) {
var tbList = document.querySelector("#p-tb ul");
if (tbList) {
var li = document.createElement("li");
li.className = "mw-list-item";
li.innerHTML = '<a href="/wiki/index.php?title=Especial:P%C3%A1ginas_especiais"><span>Páginas especiais</span></a>';
tbList.appendChild(li);
}
}
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");
if (input) {
input.addEventListener("keyup", function (event) {
if (event.keyCode === 13) {
event.preventDefault();
document.getElementById("bingSearchButton").click();
}
});
}
/* Método ajustado para chamada do Google, mantendo nomes e IDs inalterados para evitar possíveis problemas de indexação. */
function PesquisaPrincipalBing() {
var search = document.getElementById("bingPrincipalSearchInput");
if (search.value != "") {
window.open(
"https://www.google.com/search?q=site:www.cigam.com.br+" + search.value,
"_self"
);
}
}
/* Método ajustado para chamada do Google, mantendo nomes e IDs inalterados para evitar possíveis problemas de indexação. */
function PesquisaBing() {
var search = document.getElementById("bingSearchInput");
if (search.value != "") {
window.open(
"https://www.google.com/search?q=site:www.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:www.cigam.com.br+" + search.value,
"_self"
);
}
}
function removeTags(str) {
if ((str === null) || (str === ''))
return false;
else
str = str.toString();
return str.replace(/(<([^>]+)>)/ig, '');
}
function ChamaRemoveTags() {
const testElements = document.getElementsByClassName("searchresult");
var i = 0;
while (testElements[i] != null) {
testElements[i].innerText = removeTags(testElements[i].innerText);
i = i + 1;
}
}
/* Redireciona o site da Cigam para uma nova aba */
$(function () {
$('.cigam-cta-wrapper a').attr('target', '_blank').attr('rel', 'noopener noreferrer');
});
/* Botão flutuante redireciona o site da Cigam para uma nova aba */
$(function () {
var floatingBtn = $('<a>', {
href: 'https://www.cigam.com.br/',
target: '_blank',
rel: 'noopener noreferrer',
title: 'Acessar site',
class: 'cigam-cta-floating'
});
var icon = $('<span>', { class: 'cigam-cta-floating-icon' });
var text = $('<span>', { class: 'cigam-cta-floating-text', text: 'Acessar site' });
floatingBtn.append(icon).append(text);
$('body').append(floatingBtn);
});
/* Botão ao lado do buscar que redireciona o site da Cigam para uma nova aba */
$(function () {
var siteBtn = $('<a>', {
href: 'https://www.cigam.com.br/',
target: '_blank',
rel: 'noopener noreferrer',
text: 'Site',
class: 'cigam-header-btn'
});
$('#bingPrincipalSearchButton').after(siteBtn);
});
/* Ícone Cigam by Senior que redireciona pro site */
$(function () {
var headerLogoLink = $('<a>', {
href: 'https://www.cigam.com.br/',
target: '_blank',
rel: 'noopener noreferrer',
title: 'Acessar site'
});
var headerLogo = $('<img>', {
src: 'https://www.cigam.com.br/wiki/thumb.php?f=Logo%20cigam.png&width=140',
alt: 'CIGAM',
class: 'cigam-header-logo'
});
headerLogoLink.append(headerLogo);
$('#p-logo-text').prepend(headerLogoLink);
});
