Skip to content

Commit

Permalink
Allow tab as separator on lists of names to highlight
Browse files Browse the repository at this point in the history
So K can copy and paste the whole roster of an alliance, right from their
page.
  • Loading branch information
valitas committed Feb 25, 2018
1 parent 2e442a5 commit 5a83a3b
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions chrome/onlinelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

(function( doc, ConfigurationSet, Universe ) {

var SEPARATOR_RX = /[ \t]*[,\n][, \n\t]*/; // split on commas or new lines

var config, configured;

function start() {
Expand All @@ -16,20 +14,19 @@ function start() {
config = cs.makeTracker( applyColor );
}

// Parse the list as configured into a object array of lower-case names, and return
// it. Downcasing is so we can so we get fast case-insensitive lookups of
// the names on the page.
// Parse the list as typed by the user into a map of names, and return it.
// Split on commas, tabs, or newlines; index by downcased name, so we get fast
// case-insensitive lookups.
function parseList( str ) {
var names, name, index;

// Parse the options valule to an array. Downcase all names so we can
// so we get fast case-insensitive lookups of the names on the page.
names = str.split( SEPARATOR_RX );
names = str.split( /[,\t\n]+/ );
index = new Object();

for(var i = 0, end = names.length; i < end; i++ ) {
name = names[ i ];
index[ name.toLowerCase() ] = name;
name = names[ i ].trim();
if ( name !== '' )
index[ name.toLowerCase() ] = name;
}

return index;
Expand Down Expand Up @@ -87,9 +84,9 @@ function createNamesTable( links ) {
td.colSpan = 4;
var label;
if( links.length == 1 )
label = '1 Person Of Interest';
label = '1 Person of Interest';
else
label = '' + links.length + ' People Of Interest';
label = '' + links.length + ' People of Interest';
td.appendChild( doc.createTextNode(label) );
tr.appendChild( td );

Expand Down

0 comments on commit 5a83a3b

Please sign in to comment.