This is a sample block to read a list of names, order them and also create a random ordered list. The code even allows to drag and drop files into the text area for easier manipulation of long lists, and also to avoid storing any data on our server - because there is no need to do it.
The working area is next and below that is the description of the code
Description of the code
To be able to generate a random list, the code needs to iterate through the whole list of names and randomly select a new position for every entry:
To be able to manipulate files, the browser will generate events related to drag and drop, for which the program needs to handle dragOver, dragEnter, and drop. Within the drop handler, the program can instantiate the HTML5 FileReader object, that will read the local file. The reader works on events to avoid blocking the main (and only) thread executing the script. Within the handler of the reader, I load the contents of the file into the textarea using JQuery $.text() method.