make navlink ids friendlier to css selectors

css selectors don't want ids to start with numbers,
so change the ids from #n to #pn.
This commit is contained in:
James Campos 2010-11-14 00:02:39 -08:00
parent 8e5c1e292f
commit eea05abfa6
2 changed files with 33 additions and 22 deletions

View File

@ -364,7 +364,11 @@ keyboardNav = (e) ->
unless char in '1234567890GHJKL'
return
e.preventDefault()
hash = Number(location.hash?.substring(1)) or 0
hash = location.hash
if not hash or hash == '#navtop'
position = 0
else
position = Number(hash.substring 2) or 0
count = g.count
if char in '1234567890'
temp = Number char
@ -389,12 +393,12 @@ keyboardNav = (e) ->
if temp < 0 then temp = 0
location.pathname = "/#{g.BOARD}/#{temp}#1"
when "J"
temp = hash + count
temp = position + count
if temp > 10 then temp = 10
location.hash = temp
location.hash = 'p' + temp
when "K"
temp = hash - count
if temp <= 0 then temp = 'navtop'
temp = position - count
if temp <= 0 then temp = 'navtop' else temp = 'p' + temp
location.hash = temp
when "L"
temp = g.PAGENUM + count
@ -941,13 +945,13 @@ else #not reply
for el in arr
span = n 'span',
className: 'navlinks'
id: _i
id: 'p' + _i
if _i
textContent = ''
href = "##{_i - 1}"
href = "#p#{_i - 1}"
else if g.PAGENUM
textContent = ''
href = g.PAGENUM - 1
href = "#{g.PAGENUM - 1}#p0"
else
textContent = ''
href = "#navtop"
@ -957,17 +961,17 @@ else #not reply
href: href
if _i < l1
textContent = ''
href = "##{_i + 1}"
href = "#p#{_i + 1}"
else
textContent = ''
href = "#{g.PAGENUM + 1}#0"
href = "#{g.PAGENUM + 1}#p0"
down = n 'a',
className: 'pointer'
textContent: textContent
href: href
addTo span, up, tn(' '), down
inBefore el, span
if location.hash is '#0'
if location.hash is '#p0'
window.location = window.location
if getConfig 'Thread Expansion'

View File

@ -445,13 +445,18 @@
return recaptchaReload();
};
keyboardNav = function(e) {
var _i, _len, char, count, hash, temp;
var _i, _len, char, count, hash, position, temp;
char = String.fromCharCode(e.keyCode);
if (!((function(){ for (var _i=0, _len='1234567890GHJKL'.length; _i<_len; _i++) { if ('1234567890GHJKL'[_i] === char) return true; } return false; }).call(this))) {
return null;
}
e.preventDefault();
hash = Number(location.hash == null ? undefined : location.hash.substring(1)) || 0;
hash = location.hash;
if (!hash || hash === '#navtop') {
position = 0;
} else {
position = Number(hash.substring(2)) || 0;
}
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)) {
temp = Number(char);
@ -484,16 +489,18 @@
location.pathname = ("/" + (g.BOARD) + "/" + (temp) + "#1");
break;
case "J":
temp = hash + count;
temp = position + count;
if (temp > 10) {
temp = 10;
}
location.hash = temp;
location.hash = 'p' + temp;
break;
case "K":
temp = hash - count;
temp = position - count;
if (temp <= 0) {
temp = 'navtop';
} else {
temp = 'p' + temp;
}
location.hash = temp;
break;
@ -1212,14 +1219,14 @@
el = _ref[_i];
span = n('span', {
className: 'navlinks',
id: _i
id: 'p' + _i
});
if (_i) {
textContent = '▲';
href = ("#" + (_i - 1));
href = ("#p" + (_i - 1));
} else if (g.PAGENUM) {
textContent = '◀';
href = g.PAGENUM - 1;
href = ("" + (g.PAGENUM - 1) + "#p0");
} else {
textContent = '▲';
href = "#navtop";
@ -1231,10 +1238,10 @@
});
if (_i < l1) {
textContent = '▼';
href = ("#" + (_i + 1));
href = ("#p" + (_i + 1));
} else {
textContent = '▶';
href = ("" + (g.PAGENUM + 1) + "#0");
href = ("" + (g.PAGENUM + 1) + "#p0");
}
down = n('a', {
className: 'pointer',
@ -1244,7 +1251,7 @@
addTo(span, up, tn(' '), down);
inBefore(el, span);
}
if (location.hash === '#0') {
if (location.hash === '#p0') {
window.location = window.location;
}
}