<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=MyWiki%3AWikiProject_User_scripts%2FScripts%2FSort_Image_Links</id>
	<title>MyWiki:WikiProject User scripts/Scripts/Sort Image Links - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=MyWiki%3AWikiProject_User_scripts%2FScripts%2FSort_Image_Links"/>
	<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=MyWiki:WikiProject_User_scripts/Scripts/Sort_Image_Links&amp;action=history"/>
	<updated>2026-04-22T14:54:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>http://70.231.62.181/index.php?title=MyWiki:WikiProject_User_scripts/Scripts/Sort_Image_Links&amp;diff=13877348&amp;oldid=prev</id>
		<title>imported&gt;WOSlinker: change source to syntaxhighlight</title>
		<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=MyWiki:WikiProject_User_scripts/Scripts/Sort_Image_Links&amp;diff=13877348&amp;oldid=prev"/>
		<updated>2021-02-07T14:59:16Z</updated>

		<summary type="html">&lt;p&gt;change source to syntaxhighlight&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Description==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Limitation: for English projects only (namespaces are hardcoded).&lt;br /&gt;
 &lt;br /&gt;
You can test the script for example here: [[:Image:Crypto_key.svg]].&lt;br /&gt;
&lt;br /&gt;
Questions or suggestions are welcome either on this [[{{TALKPAGENAME}}|talk page]] or on the [[User_talk:Alex Smotrov|author talk page]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
All the code below should go to [[Special:Mypage/monobook.js|your monobook.js]]&lt;br /&gt;
&lt;br /&gt;
===Step 1===&lt;br /&gt;
Main function:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=javascript&amp;gt;&lt;br /&gt;
//Sort Image Links&lt;br /&gt;
function sortImageFileLinks(){&lt;br /&gt;
 var rg = /^(Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal)( talk)?:/&lt;br /&gt;
 var li, i, removed = [], ul = document.getElementById(&amp;#039;filelinks&amp;#039;)&lt;br /&gt;
 if (!ul) return&lt;br /&gt;
 while ((ul=ul.nextSibling) &amp;amp;&amp;amp; ul.nodeName != &amp;#039;UL&amp;#039;)&lt;br /&gt;
 if (!ul) return&lt;br /&gt;
 li = ul.getElementsByTagName(&amp;#039;LI&amp;#039;)&lt;br /&gt;
 for (i=0; i&amp;lt;li.length; i++)&lt;br /&gt;
   if (li[i].firstChild.title.match(rg))&lt;br /&gt;
     removed.push(li[i])&lt;br /&gt;
 removed.sort(function(a,b){ return (a.firstChild.title &amp;gt; b.firstChild.title)?1:-1})&lt;br /&gt;
 ul.appendChild(document.createElement(&amp;#039;hr&amp;#039;))&lt;br /&gt;
 for (i=0; i&amp;lt;removed.length; i++)&lt;br /&gt;
   ul.appendChild(removed[i])&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2===&lt;br /&gt;
Depends on how you want the script to work.&lt;br /&gt;
&lt;br /&gt;
* immediately on page load&lt;br /&gt;
&amp;lt;syntaxhighlight lang=javascript&amp;gt;&lt;br /&gt;
if (mw.config.get(&amp;#039;wgNamespaceNumber&amp;#039;) == 6) &lt;br /&gt;
 addOnloadHook(sortImageFileLinks);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* when you click new &amp;lt;span style=&amp;quot;border:1px solid gray&amp;quot;&amp;gt;sort links&amp;lt;/span&amp;gt; tab on top&lt;br /&gt;
&amp;lt;syntaxhighlight lang=javascript&amp;gt;&lt;br /&gt;
if (mw.config.get(&amp;#039;wgNamespaceNumber&amp;#039;) == 6) &lt;br /&gt;
 addOnloadHook(function(){&lt;br /&gt;
  addPortletLink(&amp;#039;p-cactions&amp;#039;, &amp;#039;javascript:sortImageFileLinks()&amp;#039;, &amp;#039;sort links&amp;#039;)&lt;br /&gt;
 })&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* when you click new [&amp;lt;u&amp;gt;sort&amp;lt;/u&amp;gt;] link next to &amp;quot;File links&amp;quot; heading&lt;br /&gt;
&amp;lt;syntaxhighlight lang=javascript&amp;gt;&lt;br /&gt;
if (mw.config.get(&amp;#039;wgNamespaceNumber&amp;#039;) == 6) &lt;br /&gt;
 addOnloadHook(function(){&lt;br /&gt;
   var fl = document.getElementById(&amp;#039;filelinks&amp;#039;)&lt;br /&gt;
   if (fl) fl.innerHTML += &amp;#039; &amp;lt;small&amp;gt;[&amp;lt;a href=&amp;quot;javascript:sortImageFileLinks()&amp;quot;&amp;gt;sort&amp;lt;/a&amp;gt;]&amp;lt;/small&amp;gt;&amp;#039;&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;WOSlinker</name></author>
	</entry>
</feed>