The script sorts File Links (list of pages using the image) on Image pages. Articles are shown first, all other pages are sorted by namespace.
The script sorts File Links (list of pages using the image) on Image pages. Articles are shown first, all other pages are sorted by namespace.
Limitation: for English projects only (namespaces are hardcoded).
You can test the script for example here: Image:Crypto_key.svg.
Questions or suggestions are welcome either on this talk page or on the author talk page.
All the code below should go to your monobook.js
Main function:
//Sort Image Links
function sortImageFileLinks(){
var rg = /^(Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal)( talk)?:/
var li, i, removed = [], ul = document.getElementById('filelinks')
if (!ul) return
while ((ul=ul.nextSibling) && ul.nodeName != 'UL')
if (!ul) return
li = ul.getElementsByTagName('LI')
for (i=0; i<li.length; i++)
if (li[i].firstChild.title.match(rg))
removed.push(li[i])
removed.sort(function(a,b){ return (a.firstChild.title > b.firstChild.title)?1:-1})
ul.appendChild(document.createElement('hr'))
for (i=0; i<removed.length; i++)
ul.appendChild(removed[i])
}
Depends on how you want the script to work.
if (mw.config.get('wgNamespaceNumber') == 6)
addOnloadHook(sortImageFileLinks);
if (mw.config.get('wgNamespaceNumber') == 6)
addOnloadHook(function(){
addPortletLink('p-cactions', 'javascript:sortImageFileLinks()', 'sort links')
})
if (mw.config.get('wgNamespaceNumber') == 6)
addOnloadHook(function(){
var fl = document.getElementById('filelinks')
if (fl) fl.innerHTML += ' <small>[<a href="https://profilbaru.com/en/javascript:sortImageFileLinks()">sort</a>]</small>'
})
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.