Fix Index building.
This commit is contained in:
parent
76b60e4d4d
commit
c147589bde
2
LICENSE
2
LICENSE
@ -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.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* appchan x - Version 2.9.43 - 2015-01-10
|
* appchan x - Version 2.9.43 - 2015-01-11
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||||
@ -5465,11 +5465,11 @@
|
|||||||
Index.currentPage = pageNum;
|
Index.currentPage = pageNum;
|
||||||
maxPageNum = Index.getMaxPageNum();
|
maxPageNum = Index.getMaxPageNum();
|
||||||
pagesRoot = $('.pages', Index.pagelist);
|
pagesRoot = $('.pages', Index.pagelist);
|
||||||
prev = pagesRoot.previousSibling.firstChild;
|
prev = pagesRoot.previousElementSibling.firstElementChild;
|
||||||
next = pagesRoot.nextSibling.firstChild;
|
|
||||||
href = Math.max(pageNum - 1, 1);
|
href = Math.max(pageNum - 1, 1);
|
||||||
prev.href = href === 1 ? './' : href;
|
prev.href = href === 1 ? './' : href;
|
||||||
prev.firstChild.disabled = href === pageNum;
|
prev.firstChild.disabled = href === pageNum;
|
||||||
|
next = pagesRoot.nextElementSibling.firstElementChild;
|
||||||
href = Math.min(pageNum + 1, maxPageNum);
|
href = Math.min(pageNum + 1, maxPageNum);
|
||||||
next.href = href === 1 ? './' : href;
|
next.href = href === 1 ? './' : href;
|
||||||
next.firstChild.disabled = href === pageNum;
|
next.firstChild.disabled = href === pageNum;
|
||||||
@ -5553,14 +5553,7 @@
|
|||||||
pageNum = null;
|
pageNum = null;
|
||||||
}
|
}
|
||||||
onload = function(e) {
|
onload = function(e) {
|
||||||
var err;
|
return Index.load(e, pageNum);
|
||||||
try {
|
|
||||||
return Index.load(e, pageNum);
|
|
||||||
} catch (_error) {
|
|
||||||
err = _error;
|
|
||||||
console.error(err.message);
|
|
||||||
return console.error(err.stack);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD.ID + "/catalog.json", {
|
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD.ID + "/catalog.json", {
|
||||||
onabort: onload,
|
onabort: onload,
|
||||||
@ -5858,11 +5851,9 @@
|
|||||||
_ref = Index.sortedThreads;
|
_ref = Index.sortedThreads;
|
||||||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
||||||
thread = _ref[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) {
|
buildIndex: function(infinite) {
|
||||||
var i, max, nodes, pageNum, sortedThreads, thread, threads, threadsPerPage;
|
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>"
|
innerHTML: " <strong class=\"capcode hand id_admin\" title=\"Highlight posts by the Administrator\">## Admin</strong>"
|
||||||
};
|
};
|
||||||
capcodeIcon = {
|
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;
|
break;
|
||||||
case 'mod':
|
case 'mod':
|
||||||
@ -6110,7 +6101,7 @@
|
|||||||
innerHTML: " <strong class=\"capcode hand id_mod\" title=\"Highlight posts by Moderators\">## Mod</strong>"
|
innerHTML: " <strong class=\"capcode hand id_mod\" title=\"Highlight posts by Moderators\">## Mod</strong>"
|
||||||
};
|
};
|
||||||
capcodeIcon = {
|
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;
|
break;
|
||||||
case 'developer':
|
case 'developer':
|
||||||
@ -6119,7 +6110,7 @@
|
|||||||
innerHTML: " <strong class=\"capcode hand id_developer\" title=\"Highlight posts by Developers\">## Developer</strong>"
|
innerHTML: " <strong class=\"capcode hand id_developer\" title=\"Highlight posts by Developers\">## Developer</strong>"
|
||||||
};
|
};
|
||||||
capcodeIcon = {
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript
|
// 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.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||||
@ -5494,11 +5494,11 @@
|
|||||||
Index.currentPage = pageNum;
|
Index.currentPage = pageNum;
|
||||||
maxPageNum = Index.getMaxPageNum();
|
maxPageNum = Index.getMaxPageNum();
|
||||||
pagesRoot = $('.pages', Index.pagelist);
|
pagesRoot = $('.pages', Index.pagelist);
|
||||||
prev = pagesRoot.previousSibling.firstChild;
|
prev = pagesRoot.previousElementSibling.firstElementChild;
|
||||||
next = pagesRoot.nextSibling.firstChild;
|
|
||||||
href = Math.max(pageNum - 1, 1);
|
href = Math.max(pageNum - 1, 1);
|
||||||
prev.href = href === 1 ? './' : href;
|
prev.href = href === 1 ? './' : href;
|
||||||
prev.firstChild.disabled = href === pageNum;
|
prev.firstChild.disabled = href === pageNum;
|
||||||
|
next = pagesRoot.nextElementSibling.firstElementChild;
|
||||||
href = Math.min(pageNum + 1, maxPageNum);
|
href = Math.min(pageNum + 1, maxPageNum);
|
||||||
next.href = href === 1 ? './' : href;
|
next.href = href === 1 ? './' : href;
|
||||||
next.firstChild.disabled = href === pageNum;
|
next.firstChild.disabled = href === pageNum;
|
||||||
@ -5582,14 +5582,7 @@
|
|||||||
pageNum = null;
|
pageNum = null;
|
||||||
}
|
}
|
||||||
onload = function(e) {
|
onload = function(e) {
|
||||||
var err;
|
return Index.load(e, pageNum);
|
||||||
try {
|
|
||||||
return Index.load(e, pageNum);
|
|
||||||
} catch (_error) {
|
|
||||||
err = _error;
|
|
||||||
console.error(err.message);
|
|
||||||
return console.error(err.stack);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD.ID + "/catalog.json", {
|
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD.ID + "/catalog.json", {
|
||||||
onabort: onload,
|
onabort: onload,
|
||||||
@ -5887,11 +5880,9 @@
|
|||||||
_ref = Index.sortedThreads;
|
_ref = Index.sortedThreads;
|
||||||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
||||||
thread = _ref[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) {
|
buildIndex: function(infinite) {
|
||||||
var i, max, nodes, pageNum, sortedThreads, thread, threads, threadsPerPage;
|
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>"
|
innerHTML: " <strong class=\"capcode hand id_admin\" title=\"Highlight posts by the Administrator\">## Admin</strong>"
|
||||||
};
|
};
|
||||||
capcodeIcon = {
|
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;
|
break;
|
||||||
case 'mod':
|
case 'mod':
|
||||||
@ -6139,7 +6130,7 @@
|
|||||||
innerHTML: " <strong class=\"capcode hand id_mod\" title=\"Highlight posts by Moderators\">## Mod</strong>"
|
innerHTML: " <strong class=\"capcode hand id_mod\" title=\"Highlight posts by Moderators\">## Mod</strong>"
|
||||||
};
|
};
|
||||||
capcodeIcon = {
|
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;
|
break;
|
||||||
case 'developer':
|
case 'developer':
|
||||||
@ -6148,7 +6139,7 @@
|
|||||||
innerHTML: " <strong class=\"capcode hand id_developer\" title=\"Highlight posts by Developers\">## Developer</strong>"
|
innerHTML: " <strong class=\"capcode hand id_developer\" title=\"Highlight posts by Developers\">## Developer</strong>"
|
||||||
};
|
};
|
||||||
capcodeIcon = {
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -97,15 +97,15 @@ Build =
|
|||||||
when 'admin', 'admin_highlight'
|
when 'admin', 'admin_highlight'
|
||||||
capcodeClass = ' capcodeAdmin'
|
capcodeClass = ' capcodeAdmin'
|
||||||
capcodeStart = <%= html(' <strong class="capcode hand id_admin" title="Highlight posts by the Administrator">## Admin</strong>') %>
|
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'
|
when 'mod'
|
||||||
capcodeClass = ' capcodeMod'
|
capcodeClass = ' capcodeMod'
|
||||||
capcodeStart = <%= html(' <strong class="capcode hand id_mod" title="Highlight posts by Moderators">## Mod</strong>') %>
|
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'
|
when 'developer'
|
||||||
capcodeClass = ' capcodeDeveloper'
|
capcodeClass = ' capcodeDeveloper'
|
||||||
capcodeStart = <%= html(' <strong class="capcode hand id_developer" title="Highlight posts by Developers">## Developer</strong>') %>
|
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
|
else
|
||||||
capcodeClass = ''
|
capcodeClass = ''
|
||||||
capcodeStart = <%= html('') %>
|
capcodeStart = <%= html('') %>
|
||||||
|
|||||||
@ -476,22 +476,28 @@ Index =
|
|||||||
Index.currentPage = pageNum
|
Index.currentPage = pageNum
|
||||||
maxPageNum = Index.getMaxPageNum()
|
maxPageNum = Index.getMaxPageNum()
|
||||||
pagesRoot = $ '.pages', Index.pagelist
|
pagesRoot = $ '.pages', Index.pagelist
|
||||||
|
|
||||||
# Previous/Next buttons
|
# Previous/Next buttons
|
||||||
prev = pagesRoot.previousSibling.firstChild
|
prev = pagesRoot.previousElementSibling.firstElementChild
|
||||||
next = pagesRoot.nextSibling.firstChild
|
|
||||||
href = Math.max pageNum - 1, 1
|
href = Math.max pageNum - 1, 1
|
||||||
prev.href = if href is 1 then './' else href
|
prev.href = if href is 1 then './' else href
|
||||||
prev.firstChild.disabled = href is pageNum
|
prev.firstChild.disabled = href is pageNum
|
||||||
|
|
||||||
|
next = pagesRoot.nextElementSibling.firstElementChild
|
||||||
href = Math.min pageNum + 1, maxPageNum
|
href = Math.min pageNum + 1, maxPageNum
|
||||||
next.href = if href is 1 then './' else href
|
next.href = if href is 1 then './' else href
|
||||||
next.firstChild.disabled = href is pageNum
|
next.firstChild.disabled = href is pageNum
|
||||||
|
|
||||||
# <strong> current page
|
# <strong> current page
|
||||||
if strong = $ 'strong', pagesRoot
|
if strong = $ 'strong', pagesRoot
|
||||||
return if +strong.textContent is pageNum
|
return if +strong.textContent is pageNum
|
||||||
$.replace strong, strong.firstChild
|
$.replace strong, strong.firstChild
|
||||||
else
|
else
|
||||||
strong = $.el 'strong'
|
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
|
$.before a, strong
|
||||||
$.add strong, a
|
$.add strong, a
|
||||||
|
|
||||||
@ -546,12 +552,7 @@ Index =
|
|||||||
), 3 * $.SECOND - (Date.now() - now)
|
), 3 * $.SECOND - (Date.now() - now)
|
||||||
|
|
||||||
pageNum = null if typeof pageNum isnt 'number' # event
|
pageNum = null if typeof pageNum isnt 'number' # event
|
||||||
onload = (e) ->
|
onload = (e) -> Index.load e, pageNum
|
||||||
try
|
|
||||||
Index.load e, pageNum
|
|
||||||
catch err
|
|
||||||
console.error err.message
|
|
||||||
console.error err.stack
|
|
||||||
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD.ID}/catalog.json",
|
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD.ID}/catalog.json",
|
||||||
onabort: onload
|
onabort: onload
|
||||||
onloadend: onload
|
onloadend: onload
|
||||||
@ -776,9 +777,9 @@ Index =
|
|||||||
offset = 0
|
offset = 0
|
||||||
topThreads = []
|
topThreads = []
|
||||||
bottomThreads = []
|
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
|
(if match thread then topThreads else bottomThreads).push thread
|
||||||
Index.sortedThreads = topThreads.push bottomThreads...
|
Index.sortedThreads = topThreads.concat bottomThreads
|
||||||
|
|
||||||
buildIndex: (infinite) ->
|
buildIndex: (infinite) ->
|
||||||
{sortedThreads} = Index
|
{sortedThreads} = Index
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user