Last active
August 29, 2015 14:27
-
-
Save mschnitzler/18b5282fac8d87b553b4 to your computer and use it in GitHub Desktop.
sorts the group names in the Wing FTP admin console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name sort group names in select group | |
// @namespace http://your.homepage | |
// @version 0.2 | |
// @description Sorts the options in the select by the inner content. The match contains "localhost" as a SSH tunnel is required to access the web interface | |
// @author Michael Schnitzler | |
// @match http://localhost:5466/admin_userlist.html* | |
// @grant none | |
// ==/UserScript== | |
var selectGroup = document.getElementById("select_group"); | |
var opts = []; | |
/* | |
First option is the "ALL" option. Do not remove this one. | |
WARNING: The while loop will not work if you want to sort the first option as well. | |
*/ | |
while (selectGroup.options.length>1) { | |
opts.push(selectGroup.removeChild(selectGroup.options[1])); | |
} | |
opts.sort(function(a,b) { | |
return a.innerHTML.localeCompare(b.innerHTML); | |
}); | |
while (opts.length) { | |
selectGroup.appendChild(opts.shift()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment