diff --git a/4chan_x.coffee b/4chan_x.coffee index e3ce45696..1ba734a86 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -376,9 +376,10 @@ keyAct = (e) -> char = String.fromCharCode kc hash = location.hash if not hash or hash == '#navtop' - position = 0 + position = -1 else - position = Number(hash.substring 2) or 0 + temp = Number(hash.substring 2) + position = if temp is NaN then -1 else temp count = g.count if char in '1234567890' temp = Number char @@ -409,7 +410,7 @@ keyAct = (e) -> location.hash = 'p' + temp when "K" temp = position - count - if temp <= 0 then temp = 'navtop' else temp = 'p' + temp + if temp < 0 then temp = 'navtop' else temp = 'p' + temp location.hash = temp when "L" temp = g.PAGENUM + count diff --git a/4chan_x.js b/4chan_x.js index 276d51327..f76f5b108 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -464,9 +464,10 @@ char = String.fromCharCode(kc); hash = location.hash; if (!hash || hash === '#navtop') { - position = 0; + position = -1; } else { - position = Number(hash.substring(2)) || 0; + temp = Number(hash.substring(2)); + position = temp === NaN ? -1 : temp; } count = g.count; if ((function(){ for (var _i=0, _len='1234567890'.length; _i<_len; _i++) { if ('1234567890'[_i] === char) return true; } return false; }).call(this)) { @@ -509,7 +510,7 @@ break; case "K": temp = position - count; - if (temp <= 0) { + if (temp < 0) { temp = 'navtop'; } else { temp = 'p' + temp;