Diferencia entre revisiones de «MediaWiki:Gadget-artist-portal.js»
Ir a la navegación
Ir a la búsqueda
m (pass in content to jQuery things) |
(Cambiar Coppermind:Artists por Coppermind:Artistas) |
||
Línea 1: | Línea 1: | ||
− | mw.hook('Coppermind: |
+ | mw.hook('Coppermind:Artistas').add(function artist_portal(content) { |
console.debug('artist-portal:', content) |
console.debug('artist-portal:', content) |
||
− | Array.from(jQuery('a[title^="Coppermind: |
+ | Array.from(jQuery('a[title^="Coppermind:Artistas/"]',content)).forEach(function each_artist(el) { |
// replace text with artist name |
// replace text with artist name |
||
− | el.innerText = el.innerText.replace('Coppermind: |
+ | el.innerText = el.innerText.replace('Coppermind:Artistas/','') |
}) |
}) |
||
− | Array.from(jQuery('a[title^="Coppermind: |
+ | Array.from(jQuery('a[title^="Coppermind:Artistas/"]',content).closest('ul')).forEach(function sort_list(ul) { |
const kids = Array.from(ul.children) |
const kids = Array.from(ul.children) |
||
console.debug('sorting:', kids.length, 'elements from', ul) |
console.debug('sorting:', kids.length, 'elements from', ul) |
Revisión actual del 08:05 11 jun 2022
mw.hook('Coppermind:Artistas').add(function artist_portal(content) { console.debug('artist-portal:', content) Array.from(jQuery('a[title^="Coppermind:Artistas/"]',content)).forEach(function each_artist(el) { // replace text with artist name el.innerText = el.innerText.replace('Coppermind:Artistas/','') }) Array.from(jQuery('a[title^="Coppermind:Artistas/"]',content).closest('ul')).forEach(function sort_list(ul) { const kids = Array.from(ul.children) console.debug('sorting:', kids.length, 'elements from', ul) kids.sort(function sort_kids(a,b) { return a.innerText < b.innerText ? -1 : +1 }) kids.forEach(function reinsert(li) { ul.append(li) }) }) // END })