use _i, _len in thread nav loop

This commit is contained in:
James Campos 2010-11-13 23:19:53 -08:00
parent 984503c714
commit 8e5c1e292f
2 changed files with 39 additions and 45 deletions

View File

@ -936,43 +936,38 @@ else #not reply
$('form[name="post"]').addEventListener('submit', autoWatch, true) $('form[name="post"]').addEventListener('submit', autoWatch, true)
if getConfig 'Thread Navigation' if getConfig 'Thread Navigation'
arr = $$('div > span.filesize, form > span.filesize') arr = $$ 'div > span.filesize, form > span.filesize'
i = 0 l1 = arr.length - 1
l = arr.length
l1 = l + 1
#should this be a while loop?
for el in arr for el in arr
if i isnt 0 span = n 'span',
className: 'navlinks'
id: _i
if _i
textContent = '' textContent = ''
href = "##{i}" href = "##{_i - 1}"
else if g.PAGENUM isnt 0 else if g.PAGENUM
textContent = '' textContent = ''
href = "#{g.PAGENUM - 1}" href = g.PAGENUM - 1
else else
textContent = '' textContent = ''
href = "#navtop" href = "#navtop"
up = n 'a', up = n 'a',
className: 'pointer' className: 'pointer'
textContent: textContent textContent: textContent
href: href href: href
if _i < l1
span = n 'span', textContent = ''
className: 'navlinks' href = "##{_i + 1}"
id: ++i else
i1 = i + 1 textContent = ''
href = "#{g.PAGENUM + 1}#0"
down = n 'a', down = n 'a',
className: 'pointer' className: 'pointer'
if i1 == l1 textContent: textContent
down.textContent = '' href: href
down.href = "#{g.PAGENUM + 1}#1"
else
down.textContent = ''
down.href = "##{i1}"
addTo span, up, tn(' '), down addTo span, up, tn(' '), down
inBefore el, span inBefore el, span
if location.hash is '#1' if location.hash is '#0'
window.location = window.location window.location = window.location
if getConfig 'Thread Expansion' if getConfig 'Thread Expansion'

View File

@ -1,5 +1,5 @@
(function() { (function() {
var $, $$, AEOS, DAY, _, _i, _len, _ref, _ref2, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expandComment, expandThread, formSubmit, g, getConfig, getTime, hide, hideReply, hideThread, href, html, i, i1, id, iframe, iframeLoad, inAfter, inBefore, inputs, keyboardNav, l, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, show, showReply, showThread, slice, span, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, up, watch, watchX, watcher, watcherUpdate, x; var $, $$, AEOS, DAY, _, _i, _len, _ref, _ref2, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expandComment, expandThread, formSubmit, g, getConfig, getTime, hide, hideReply, hideThread, href, html, id, iframe, iframeLoad, inAfter, inBefore, inputs, keyboardNav, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, show, showReply, showThread, slice, span, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, up, watch, watchX, watcher, watcherUpdate, x;
var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty; var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty;
config = { config = {
'Thread Hiding': [true, 'Hide entire threads'], 'Thread Hiding': [true, 'Hide entire threads'],
@ -1206,18 +1206,20 @@
} }
if (getConfig('Thread Navigation')) { if (getConfig('Thread Navigation')) {
arr = $$('div > span.filesize, form > span.filesize'); arr = $$('div > span.filesize, form > span.filesize');
i = 0; l1 = arr.length - 1;
l = arr.length;
l1 = l + 1;
_ref = arr; _ref = arr;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
el = _ref[_i]; el = _ref[_i];
if (i !== 0) { span = n('span', {
className: 'navlinks',
id: _i
});
if (_i) {
textContent = '▲'; textContent = '▲';
href = ("#" + (i)); href = ("#" + (_i - 1));
} else if (g.PAGENUM !== 0) { } else if (g.PAGENUM) {
textContent = '◀'; textContent = '◀';
href = ("" + (g.PAGENUM - 1)); href = g.PAGENUM - 1;
} else { } else {
textContent = '▲'; textContent = '▲';
href = "#navtop"; href = "#navtop";
@ -1227,25 +1229,22 @@
textContent: textContent, textContent: textContent,
href: href href: href
}); });
span = n('span', { if (_i < l1) {
className: 'navlinks', textContent = '▼';
id: ++i href = ("#" + (_i + 1));
});
i1 = i + 1;
down = n('a', {
className: 'pointer'
});
if (i1 === l1) {
down.textContent = '▶';
down.href = ("" + (g.PAGENUM + 1) + "#1");
} else { } else {
down.textContent = '▼'; textContent = '▶';
down.href = ("#" + (i1)); href = ("" + (g.PAGENUM + 1) + "#0");
} }
down = n('a', {
className: 'pointer',
textContent: textContent,
href: href
});
addTo(span, up, tn(' '), down); addTo(span, up, tn(' '), down);
inBefore(el, span); inBefore(el, span);
} }
if (location.hash === '#1') { if (location.hash === '#0') {
window.location = window.location; window.location = window.location;
} }
} }