Fix Index building.

This commit is contained in:
Zixaphir 2015-01-11 00:53:41 -07:00
parent 76b60e4d4d
commit c147589bde
5 changed files with 34 additions and 51 deletions

View File

@ -1,5 +1,5 @@
/*
* appchan x - Version 2.9.43 - 2015-01-10
* appchan x - Version 2.9.43 - 2015-01-11
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE

View File

@ -27,7 +27,7 @@
// ==/UserScript==
/*
* appchan x - Version 2.9.43 - 2015-01-10
* appchan x - Version 2.9.43 - 2015-01-11
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -5465,11 +5465,11 @@
Index.currentPage = pageNum;
maxPageNum = Index.getMaxPageNum();
pagesRoot = $('.pages', Index.pagelist);
prev = pagesRoot.previousSibling.firstChild;
next = pagesRoot.nextSibling.firstChild;
prev = pagesRoot.previousElementSibling.firstElementChild;
href = Math.max(pageNum - 1, 1);
prev.href = href === 1 ? './' : href;
prev.firstChild.disabled = href === pageNum;
next = pagesRoot.nextElementSibling.firstElementChild;
href = Math.min(pageNum + 1, maxPageNum);
next.href = href === 1 ? './' : href;
next.firstChild.disabled = href === pageNum;
@ -5553,14 +5553,7 @@
pageNum = null;
}
onload = function(e) {
var err;
try {
return Index.load(e, pageNum);
} catch (_error) {
err = _error;
console.error(err.message);
return console.error(err.stack);
}
return Index.load(e, pageNum);
};
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD.ID + "/catalog.json", {
onabort: onload,
@ -5858,11 +5851,9 @@
_ref = Index.sortedThreads;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
thread = _ref[i];
if (match(thread)) {
(match(thread) ? topThreads : bottomThreads).push(thread);
}
(match(thread) ? topThreads : bottomThreads).push(thread);
}
return Index.sortedThreads = topThreads.push.apply(topThreads, bottomThreads);
return Index.sortedThreads = topThreads.concat(bottomThreads);
},
buildIndex: function(infinite) {
var i, max, nodes, pageNum, sortedThreads, thread, threads, threadsPerPage;
@ -6101,7 +6092,7 @@
innerHTML: " <strong class=\"capcode hand id_admin\" title=\"Highlight posts by the Administrator\">## Admin</strong>"
};
capcodeIcon = {
innerHTML: " <img src=\"//s.4cdn.org/image/adminicon" + E(retina) + ".gif\" alt=\"Admin Icon\" title=\"This user is the 4chan Administrator.\" class=\"identityIcon retina\">"
innerHTML: " <img src=\"" + E(staticPath) + "adminicon" + E(gifIcon) + "\" alt=\"Admin Icon\" title=\"This user is the 4chan Administrator.\" class=\"identityIcon retina\">"
};
break;
case 'mod':
@ -6110,7 +6101,7 @@
innerHTML: " <strong class=\"capcode hand id_mod\" title=\"Highlight posts by Moderators\">## Mod</strong>"
};
capcodeIcon = {
innerHTML: " <img src=\"//s.4cdn.org/image/modicon" + E(retina) + ".gif\" alt=\"Mod Icon\" title=\"This user is a 4chan Moderator.\" class=\"identityIcon retina\">"
innerHTML: " <img src=\"" + E(staticPath) + "modicon" + E(gifIcon) + "\" alt=\"Mod Icon\" title=\"This user is a 4chan Moderator.\" class=\"identityIcon retina\">"
};
break;
case 'developer':
@ -6119,7 +6110,7 @@
innerHTML: " <strong class=\"capcode hand id_developer\" title=\"Highlight posts by Developers\">## Developer</strong>"
};
capcodeIcon = {
innerHTML: " <img src=\"//s.4cdn.org/image/developericon" + E(retina) + ".gif\" alt=\"Developer Icon\" title=\"This user is a 4chan Developer.\" class=\"identityIcon retina\">"
innerHTML: " <img src=\"" + E(staticPath) + "developericon" + E(gifIcon) + "\" alt=\"Developer Icon\" title=\"This user is a 4chan Developer.\" class=\"identityIcon retina\">"
};
break;
default:

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript
/*
* appchan x - Version 2.9.43 - 2015-01-10
* appchan x - Version 2.9.43 - 2015-01-11
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -5494,11 +5494,11 @@
Index.currentPage = pageNum;
maxPageNum = Index.getMaxPageNum();
pagesRoot = $('.pages', Index.pagelist);
prev = pagesRoot.previousSibling.firstChild;
next = pagesRoot.nextSibling.firstChild;
prev = pagesRoot.previousElementSibling.firstElementChild;
href = Math.max(pageNum - 1, 1);
prev.href = href === 1 ? './' : href;
prev.firstChild.disabled = href === pageNum;
next = pagesRoot.nextElementSibling.firstElementChild;
href = Math.min(pageNum + 1, maxPageNum);
next.href = href === 1 ? './' : href;
next.firstChild.disabled = href === pageNum;
@ -5582,14 +5582,7 @@
pageNum = null;
}
onload = function(e) {
var err;
try {
return Index.load(e, pageNum);
} catch (_error) {
err = _error;
console.error(err.message);
return console.error(err.stack);
}
return Index.load(e, pageNum);
};
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD.ID + "/catalog.json", {
onabort: onload,
@ -5887,11 +5880,9 @@
_ref = Index.sortedThreads;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
thread = _ref[i];
if (match(thread)) {
(match(thread) ? topThreads : bottomThreads).push(thread);
}
(match(thread) ? topThreads : bottomThreads).push(thread);
}
return Index.sortedThreads = topThreads.push.apply(topThreads, bottomThreads);
return Index.sortedThreads = topThreads.concat(bottomThreads);
},
buildIndex: function(infinite) {
var i, max, nodes, pageNum, sortedThreads, thread, threads, threadsPerPage;
@ -6130,7 +6121,7 @@
innerHTML: " <strong class=\"capcode hand id_admin\" title=\"Highlight posts by the Administrator\">## Admin</strong>"
};
capcodeIcon = {
innerHTML: " <img src=\"//s.4cdn.org/image/adminicon" + E(retina) + ".gif\" alt=\"Admin Icon\" title=\"This user is the 4chan Administrator.\" class=\"identityIcon retina\">"
innerHTML: " <img src=\"" + E(staticPath) + "adminicon" + E(gifIcon) + "\" alt=\"Admin Icon\" title=\"This user is the 4chan Administrator.\" class=\"identityIcon retina\">"
};
break;
case 'mod':
@ -6139,7 +6130,7 @@
innerHTML: " <strong class=\"capcode hand id_mod\" title=\"Highlight posts by Moderators\">## Mod</strong>"
};
capcodeIcon = {
innerHTML: " <img src=\"//s.4cdn.org/image/modicon" + E(retina) + ".gif\" alt=\"Mod Icon\" title=\"This user is a 4chan Moderator.\" class=\"identityIcon retina\">"
innerHTML: " <img src=\"" + E(staticPath) + "modicon" + E(gifIcon) + "\" alt=\"Mod Icon\" title=\"This user is a 4chan Moderator.\" class=\"identityIcon retina\">"
};
break;
case 'developer':
@ -6148,7 +6139,7 @@
innerHTML: " <strong class=\"capcode hand id_developer\" title=\"Highlight posts by Developers\">## Developer</strong>"
};
capcodeIcon = {
innerHTML: " <img src=\"//s.4cdn.org/image/developericon" + E(retina) + ".gif\" alt=\"Developer Icon\" title=\"This user is a 4chan Developer.\" class=\"identityIcon retina\">"
innerHTML: " <img src=\"" + E(staticPath) + "developericon" + E(gifIcon) + "\" alt=\"Developer Icon\" title=\"This user is a 4chan Developer.\" class=\"identityIcon retina\">"
};
break;
default:

View File

@ -97,15 +97,15 @@ Build =
when 'admin', 'admin_highlight'
capcodeClass = ' capcodeAdmin'
capcodeStart = <%= html(' <strong class="capcode hand id_admin" title="Highlight posts by the Administrator">## Admin</strong>') %>
capcodeIcon = <%= html(' <img src="//s.4cdn.org/image/adminicon${retina}.gif" alt="Admin Icon" title="This user is the 4chan Administrator." class="identityIcon retina">') %>
capcodeIcon = <%= html(' <img src="${staticPath}adminicon${gifIcon}" alt="Admin Icon" title="This user is the 4chan Administrator." class="identityIcon retina">') %>
when 'mod'
capcodeClass = ' capcodeMod'
capcodeStart = <%= html(' <strong class="capcode hand id_mod" title="Highlight posts by Moderators">## Mod</strong>') %>
capcodeIcon = <%= html(' <img src="//s.4cdn.org/image/modicon${retina}.gif" alt="Mod Icon" title="This user is a 4chan Moderator." class="identityIcon retina">') %>
capcodeIcon = <%= html(' <img src="${staticPath}modicon${gifIcon}" alt="Mod Icon" title="This user is a 4chan Moderator." class="identityIcon retina">') %>
when 'developer'
capcodeClass = ' capcodeDeveloper'
capcodeStart = <%= html(' <strong class="capcode hand id_developer" title="Highlight posts by Developers">## Developer</strong>') %>
capcodeIcon = <%= html(' <img src="//s.4cdn.org/image/developericon${retina}.gif" alt="Developer Icon" title="This user is a 4chan Developer." class="identityIcon retina">') %>
capcodeIcon = <%= html(' <img src="${staticPath}developericon${gifIcon}" alt="Developer Icon" title="This user is a 4chan Developer." class="identityIcon retina">') %>
else
capcodeClass = ''
capcodeStart = <%= html('') %>

View File

@ -476,22 +476,28 @@ Index =
Index.currentPage = pageNum
maxPageNum = Index.getMaxPageNum()
pagesRoot = $ '.pages', Index.pagelist
# Previous/Next buttons
prev = pagesRoot.previousSibling.firstChild
next = pagesRoot.nextSibling.firstChild
prev = pagesRoot.previousElementSibling.firstElementChild
href = Math.max pageNum - 1, 1
prev.href = if href is 1 then './' else href
prev.firstChild.disabled = href is pageNum
next = pagesRoot.nextElementSibling.firstElementChild
href = Math.min pageNum + 1, maxPageNum
next.href = if href is 1 then './' else href
next.firstChild.disabled = href is pageNum
# <strong> current page
if strong = $ 'strong', pagesRoot
return if +strong.textContent is pageNum
$.replace strong, strong.firstChild
else
strong = $.el 'strong'
return unless a = pagesRoot.children[pageNum - 1] # If coming in from a Navigate.navigate, this could break.
# If coming in from a Navigate.navigate, this could break.
return unless a = pagesRoot.children[pageNum - 1]
$.before a, strong
$.add strong, a
@ -546,12 +552,7 @@ Index =
), 3 * $.SECOND - (Date.now() - now)
pageNum = null if typeof pageNum isnt 'number' # event
onload = (e) ->
try
Index.load e, pageNum
catch err
console.error err.message
console.error err.stack
onload = (e) -> Index.load e, pageNum
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD.ID}/catalog.json",
onabort: onload
onloadend: onload
@ -776,9 +777,9 @@ Index =
offset = 0
topThreads = []
bottomThreads = []
for thread, i in Index.sortedThreads when match thread
for thread, i in Index.sortedThreads
(if match thread then topThreads else bottomThreads).push thread
Index.sortedThreads = topThreads.push bottomThreads...
Index.sortedThreads = topThreads.concat bottomThreads
buildIndex: (infinite) ->
{sortedThreads} = Index