Skip to content

Instantly share code, notes, and snippets.

@mschnitzler
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mschnitzler/18b5282fac8d87b553b4 to your computer and use it in GitHub Desktop.
Save mschnitzler/18b5282fac8d87b553b4 to your computer and use it in GitHub Desktop.
sorts the group names in the Wing FTP admin console
// ==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