Last active
July 19, 2016 09:25
-
-
Save wolph/9115fefa1795dc39c9fd1d58fe5f7e10 to your computer and use it in GitHub Desktop.
Computer futures usability enhancer
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 Computer Futures Worksheet Usability Enhancer | |
| // @namespace http://wol.ph/ | |
| // @description try to take over the world! | |
| // @author Wolph | |
| // @match https://worksheets.computerfutures.com/index.php?* | |
| // @grant none | |
| // ==/UserScript== | |
| /* jshint -W097 */ | |
| 'use strict'; | |
| function sortSelect(selElem) { | |
| var tmpAry = new Array(); | |
| if(!selElem || !selElem.options)return; | |
| var options = selElem.options; | |
| for (var i=0;i<options.length;i++) { | |
| var option = options[i]; | |
| tmpAry[i] = new Array(); | |
| tmpAry[i][0] = option.value; | |
| tmpAry[i][1] = option.text; | |
| tmpAry[i][2] = selElem.selectedIndex == i; | |
| } | |
| tmpAry.sort(); | |
| while (selElem.options.length > 0) { | |
| selElem.options[0] = null; | |
| } | |
| for (var i=0;i<tmpAry.length;i++) { | |
| var op = new Option(tmpAry[i][1], tmpAry[i][0]); | |
| selElem.options[i] = op; | |
| if(tmpAry[i][2]){ | |
| selElem.selectedIndex = i; | |
| } | |
| } | |
| return; | |
| } | |
| sortSelect(document.getElementById('projectSelector')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment