Thursday, October 8, 2020

One-line web page tools - example: sorting text

Sometimes you need to quickly get a small job done, such as sorting text.

I created a few tools that are coded in just the URL alone.  The whole web page app is just entered into a data URL. These can be saved as a bookmark and the tool is ready to go quickly any time, offline, without sending data anywhere.

Coders are likely to handle this in their favorite text editor, or command line tool.  But why not in a new tab for the browser you're already in?

There are many online tools to do this type of work too, but there's always the risk that you don't know where the data is going.  These one line tools give me the confidence the text stays private.

To use these tools:

  1. Copy one of the URLs below and paste into your browser (just like you'd enter a webpage URL).
  2. Optionally bookmark it, so that you can get to it in the future easily.
  3. Put text into the text box.
  4. Click off the text area, or use Tab key, to move focus away.  The code runs and sorts the text.
  5. Copy sorted text, ..., profit.

Sort Lines

data:text/html,<textarea autofocus style="height:100%; width:100%" onchange="value = value.split('\n').map(x => x.trim()).filter(removeEmpty => removeEmpty).sort().join('\n')" >

Sort Line by Commas

data:text/html,<textarea autofocus style="height:100%; width:100%" onchange="value = value.split(',').map(x => x.trim()).filter(removeEmpty => removeEmpty).sort().join(', ')" >

Sort Line by Spaces

data:text/html,<textarea autofocus style="height:100%; width:100%" onchange="value = value.split(' ').map(x => x.trim()).filter(removeEmpty => removeEmpty).sort().join(' ')" >

To Uppercase

data:text/html,<textarea autofocus style="height:100%; width:100%" onchange="value = value.toLocaleUpperCase()" >

To Lowercase

data:text/html,<textarea autofocus style="height:100%; width:100%" onchange="value = value.toLowerCase()" >

Once you've started, it's easy to make new ones for future needs.  Leave a comment if you've found a new variation helpful.