diff options
| author | Phil Crosby | 2012-01-20 00:48:03 -0800 |
|---|---|---|
| committer | Phil Crosby | 2012-01-20 00:50:03 -0800 |
| commit | 3d72775b3c5100a44e441eda89120b7de920af45 (patch) | |
| tree | 9035ad30c9b31ce2a1a7075d017b4ef1d4c7aac2 /linkHints.js | |
| parent | 44d3f575b30c044e67db40d8d55bbf9f87273400 (diff) | |
| download | vimium-3d72775b3c5100a44e441eda89120b7de920af45.tar.bz2 | |
Scatter the link hints less naively.
Diffstat (limited to 'linkHints.js')
| -rw-r--r-- | linkHints.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/linkHints.js b/linkHints.js index f30425aa..24fa7946 100644 --- a/linkHints.js +++ b/linkHints.js @@ -352,7 +352,23 @@ var alphabetHints = { for (var i = start; i < start + longHintCount; i++) hintStrings.push(this.numberToHintString(i, digitsNeeded, linkHintCharacters)); - return hintStrings; + return this.shuffleHints(hintStrings, linkHintCharacters.length); + }, + + /* + * This shuffles the given set of hints so that they're scattered -- hints starting with the same character + * will be spread evenly throughout the array. + */ + shuffleHints: function(hints, characterSetLength) { + var buckets = [], i = 0; + for (i = 0; i < characterSetLength; i++) + buckets[i] = [] + for (i = 0; i < hints.length; i++) + buckets[i % buckets.length].push(hints[i]); + var result = []; + for (i = 0; i < buckets.length; i++) + result = result.concat(buckets[i]); + return result; }, /* |
