MediaWiki:Common.js: mudanças entre as edições
Aparência
Sem resumo de edição |
Sem resumo de edição |
||
Linha 7: | Linha 7: | ||
}); | }); | ||
/* | /* Listar Categorias */ | ||
fetch('/api.php?action=query&list=allcategories&aclimit=100&format=json&origin=*') | fetch('/api.php?action=query&list=allcategories&aclimit=100&format=json&origin=*') | ||
.then(res => res.json()) | .then(res => res.json()) | ||
.then(data => { | .then(data => { | ||
const ul = document.getElementById(' | const ul = document.getElementById('categories-list'); | ||
data.query.allcategories.forEach(cat => { | data.query.allcategories.forEach(cat => { | ||
const li = document.createElement('li'); | const li = document.createElement('li'); | ||
const link = document.createElement('a'); | const link = document.createElement('a'); | ||
const catName = cat['*']; | const catName = cat['*']; | ||
link.href = '/wiki/ | link.href = '/wiki/Category:' + encodeURIComponent(catName); | ||
link.textContent = catName; | link.textContent = catName; | ||
li.appendChild(link); | li.appendChild(link); |
Edição das 23h17min de 1 de julho de 2025
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */ /* Esse script seleciona todos os links na barra lateral que começam com http (ou seja, links externos) e adiciona target="_blank", fazendo com que abram em nova aba. */ $(document).ready(function () { // Alvo: links externos na barra lateral $('#mw-site-navigation a[href^="http"]').attr('target', '_blank'); }); /* Listar Categorias */ fetch('/api.php?action=query&list=allcategories&aclimit=100&format=json&origin=*') .then(res => res.json()) .then(data => { const ul = document.getElementById('categories-list'); data.query.allcategories.forEach(cat => { const li = document.createElement('li'); const link = document.createElement('a'); const catName = cat['*']; link.href = '/wiki/Category:' + encodeURIComponent(catName); link.textContent = catName; li.appendChild(link); ul.appendChild(li); }); });