diff options
author | hogelog | 2009-01-27 14:59:22 +0000 |
---|---|---|
committer | hogelog | 2009-01-27 14:59:22 +0000 |
commit | 8e8dd9687a9fef239ccb6fcb0572c13dd4c534d5 (patch) | |
tree | 8a1a708ef22534328f0a705d8aab813acbb66473 /char-hints-mod2.js | |
parent | a68fc7ad20e847e926e0184aecf63c881fee5269 (diff) | |
download | vimperator-plugins-8e8dd9687a9fef239ccb6fcb0572c13dd4c534d5.tar.bz2 |
* fix labeling algorithm
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@29138 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'char-hints-mod2.js')
-rw-r--r-- | char-hints-mod2.js | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/char-hints-mod2.js b/char-hints-mod2.js index 139f87a..6645503 100644 --- a/char-hints-mod2.js +++ b/char-hints-mod2.js @@ -4,10 +4,10 @@ var PLUGIN_INFO = <name>{NAME}</name>
<description>character hint mode.</description>
<author mail="konbu.komuro@gmail.com" homepage="http://d.hatena.ne.jp/hogelog/">hogelog</author>
- <version>0.2.0</version>
+ <version>0.2.1</version>
<minVersion>2.0pre 2008/12/12</minVersion>
<maxVersion>2.0a1</maxVersion>
- <date>2009/1/27 18:56</date>
+ <date>2009/1/27 23:52</date>
<updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/char-hints-mod2.js</updateURL>
<detail><![CDATA[
== Usage ==
@@ -89,19 +89,20 @@ let g:hintsio: return chars;
} //}}}
- function getStartNum(base, count) //{{{
+ // get Most Significant Digit
+ function getMSD(base, count) //{{{
{
- let figure = 1;
- while((count/=base) >= 1.0) {
- ++figure;
+ let next;
+ while((next = Math.floor(count/base)) > 0) {
+ count = next;
}
- return Math.pow(base, figure-1) - 1;
+ return count;
} //}}}
function getCharHints(win) //{{{
{
let hints = [];
(function (win) {
- let elems = [elem for(elem in buffer.evaluateXPath("//*[@liberator:highlight and @number]", win.document))];
+ let elems = [elem for(elem in buffer.evaluateXPath('//*[@liberator:highlight="Hint" and @number]', win.document))];
hints = hints.concat(elems);
Array.forEach(win.frames, arguments.callee);
})(win);
@@ -109,11 +110,11 @@ let g:hintsio: } //}}}
function showCharHints(hints) //{{{
{
- let start = getStartNum(hintchars.length, hints.length);
+ let msd = getMSD(hintchars.length, hints.length);
for(let i=0,len=hints.length;i<len;++i) {
let hint = hints[i];
let num = hint.getAttribute("number");
- let hintchar = num2chars(parseInt(num, 10)+start);
+ let hintchar = num2chars(parseInt(num, 10)+msd);
hint.setAttribute("hintchar", showCase(hintchar));
}
} //}}}
@@ -145,8 +146,8 @@ let g:hintsio: } //}}}
function processHintInput(hintInput, hints) //{{{
{
- let start = getStartNum(hintchars.length, hints.length);
- let num = chars2num(hintInput)-start;
+ let msd = getMSD(hintchars.length, hints.length);
+ let num = chars2num(hintInput)-msd;
if(num < 0) return;
let numstr = String(num);
// no setTimeout, don't run nice ?
|