diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js
index c131daff7..7fb27ef4c 100644
--- a/builds/appchan-x.user.js
+++ b/builds/appchan-x.user.js
@@ -116,7 +116,7 @@
'use strict';
(function() {
- var $, $$, Anonymize, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, Emoji, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageExpand, ImageHover, ImageLoader, Index, InfiniScroll, JSColor, Keybinds, Labels, Linkify, Main, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, TrashQueue, UI, Unread, Video, c, d, doc, editMascot, editTheme, g, userNavigation,
+ var $, $$, Anonymize, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, Emoji, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Labels, Linkify, Main, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, TrashQueue, UI, Unread, Video, c, d, doc, editMascot, editTheme, g, userNavigation,
__slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = {}.hasOwnProperty,
@@ -5363,7 +5363,8 @@
};
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD.ID + "/catalog.json", {
onabort: onload,
- onloadend: onload
+ onloadend: onload,
+ onerror: onload
}, {
whenModified: board === g.BOARD.ID
});
@@ -15590,179 +15591,6 @@
}
};
- InfiniScroll = {
- init: function() {
- if (!(Conf['Infinite Scrolling'] && g.VIEW === 'index' && g.BOARD !== 'f')) {
- return;
- }
- this.threads = g.threads;
- return $.on(d, '4chanXInitFinished', this.ready);
- },
- ready: function() {
- $.off(d, '4chanXInitFinished', InfiniScroll.ready);
- $.on(d, 'scroll', InfiniScroll.scroll);
- return InfiniScroll.scroll();
- },
- scroll: $.debounce(100, function() {
- var url;
- if (InfiniScroll.isFetching || ((d.body.scrollTop || doc.scrollTop) <= doc.scrollHeight - (300 + window.innerHeight))) {
- return;
- }
- if (InfiniScroll.isDead) {
- return InfiniScroll.notice();
- }
- if (InfiniScroll.cache && InfiniScroll.cache.time > Date.now() - $.MINUTE) {
- return InfiniScroll.parse(InfiniScroll.cache);
- }
- new Notice('info', "Fetching next page.", 2);
- InfiniScroll.isFetching = true;
- url = "//api.4chan.org/" + g.BOARD + "/catalog.json";
- return $.ajax(url, {
- onloadend: InfiniScroll.cb.load
- }, {
- whenModified: true
- });
- }),
- parse: function(response) {
- var botPostForm, el, nodes, omitted_images, omitted_posts, op, post, postlink, posts, replylink, thread, threadID, threadNodes, threads, _i, _j, _len, _len1, _ref;
- threads = InfiniScroll.parsePages(response);
- threadNodes = [];
- nodes = [];
- if (!threads.length) {
- InfiniScroll.notice();
- return InfiniScroll.isDead = true;
- }
- for (_i = 0, _len = threads.length; _i < _len; _i++) {
- thread = threads[_i];
- posts = [];
- omitted_posts = thread.omitted_posts, omitted_images = thread.omitted_images;
- threadID = thread.no;
- el = $.el('div', {
- className: 'thread',
- id: "t" + threadID
- });
- op = Build.postFromObject(thread, g.BOARD);
- posts.push(op);
- replylink = $.el('a', {
- href: "res/" + threadID,
- className: 'replylink',
- textContent: 'Reply'
- });
- postlink = $.el('div', {
- className: "postLink mobile",
- innerHTML: "View Thread"
- });
- if (omitted_posts) {
- posts.push($.el('span', {
- className: 'summary desktop',
- innerHTML: "" + omitted_posts + " posts " + (omitted_images ? "and " + omitted_images + " image replies" : void 0) + " omitted. Click here to view."
- }));
- $.prepend(postlink, $.el('span', {
- className: 'info',
- innerHTML: "" + omitted_posts + " posts omitted" + (omitted_images ? "
(" + omitted_images + " have images)" : "")
- }));
- }
- $.add($('.postInfo', op), [$.tn('\u00A0\u00A0\u00A0['), replylink, $.tn(']\u00A0')]);
- $.add(op, postlink);
- if (thread.last_replies) {
- _ref = thread.last_replies;
- for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
- post = _ref[_j];
- posts.push(Build.postFromObject(post, g.BOARD));
- }
- }
- $.add(el, posts);
- threadNodes.push(el);
- nodes.push(el);
- nodes.push($.el('hr'));
- }
- InfiniScroll.features(threadNodes);
- if (botPostForm = $('.board > .mobile.center')) {
- return $.before(botPostForm, nodes);
- }
- },
- parsePages: function(response) {
- var newThreads, number, page, pages, thread, threads, _i, _len;
- pages = JSON.parse(response);
- newThreads = [];
- for (number in pages) {
- page = pages[number];
- if (!(pages.hasOwnProperty(number))) {
- continue;
- }
- threads = page.threads;
- for (_i = 0, _len = threads.length; _i < _len; _i++) {
- thread = threads[_i];
- if (g.threads["" + g.BOARD + "." + thread.no]) {
- continue;
- }
- newThreads.push(thread);
- if (newThreads.length === 15) {
- return newThreads;
- }
- }
- }
- return newThreads;
- },
- features: function(threadNodes) {
- var err, errors, post, posts, thread, threadRoot, threads, _i, _j, _len, _len1, _ref;
- posts = [];
- threads = [];
- for (_i = 0, _len = threadNodes.length; _i < _len; _i++) {
- threadRoot = threadNodes[_i];
- thread = new Thread(+threadRoot.id.slice(1), g.BOARD);
- threads.push(thread);
- _ref = $$('.thread > .postContainer', threadRoot);
- for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
- post = _ref[_j];
- try {
- posts.push(new Post(post, thread, g.BOARD));
- } catch (_error) {
- err = _error;
- if (!errors) {
- errors = [];
- }
- errors.push({
- message: "Parsing of Post No." + (postRoot.id.match(/\d+/)) + " failed. Post will be skipped.",
- error: err
- });
- }
- }
- }
- if (errors) {
- Main.handleErrors(errors);
- }
- Main.callbackNodes(Thread, threads);
- return Main.callbackNodes(Post, posts);
- },
- notice: (function() {
- var notify, reset;
- notify = false;
- reset = function() {
- return notify = false;
- };
- return function() {
- if (notify) {
- return;
- }
- notify = true;
- new Notice('info', "Last page reached.", 2);
- return setTimeout(reset, 3 * $.SECOND);
- };
- })(),
- cb: {
- load: function() {
- InfiniScroll.isFetching = false;
- if (this.status !== 200) {
- return;
- }
- InfiniScroll.cache = new String(this.response);
- InfiniScroll.cache.time = Date.now();
- return InfiniScroll.parse(this.response);
- }
- }
- };
-
Keybinds = {
init: function() {
var hotkey, init;
diff --git a/builds/crx/script.js b/builds/crx/script.js
index f08898e6c..3880e68cc 100644
--- a/builds/crx/script.js
+++ b/builds/crx/script.js
@@ -88,7 +88,7 @@
'use strict';
(function() {
- var $, $$, Anonymize, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, Emoji, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageExpand, ImageHover, ImageLoader, Index, InfiniScroll, JSColor, Keybinds, Labels, Linkify, Main, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, TrashQueue, UI, Unread, Video, c, d, doc, editMascot, editTheme, g, userNavigation,
+ var $, $$, Anonymize, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, Emoji, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Labels, Linkify, Main, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, TrashQueue, UI, Unread, Video, c, d, doc, editMascot, editTheme, g, userNavigation,
__slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = {}.hasOwnProperty,
@@ -5414,7 +5414,8 @@
};
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD.ID + "/catalog.json", {
onabort: onload,
- onloadend: onload
+ onloadend: onload,
+ onerror: onload
}, {
whenModified: board === g.BOARD.ID
});
@@ -15601,179 +15602,6 @@
}
};
- InfiniScroll = {
- init: function() {
- if (!(Conf['Infinite Scrolling'] && g.VIEW === 'index' && g.BOARD !== 'f')) {
- return;
- }
- this.threads = g.threads;
- return $.on(d, '4chanXInitFinished', this.ready);
- },
- ready: function() {
- $.off(d, '4chanXInitFinished', InfiniScroll.ready);
- $.on(d, 'scroll', InfiniScroll.scroll);
- return InfiniScroll.scroll();
- },
- scroll: $.debounce(100, function() {
- var url;
- if (InfiniScroll.isFetching || ((d.body.scrollTop || doc.scrollTop) <= doc.scrollHeight - (300 + window.innerHeight))) {
- return;
- }
- if (InfiniScroll.isDead) {
- return InfiniScroll.notice();
- }
- if (InfiniScroll.cache && InfiniScroll.cache.time > Date.now() - $.MINUTE) {
- return InfiniScroll.parse(InfiniScroll.cache);
- }
- new Notice('info', "Fetching next page.", 2);
- InfiniScroll.isFetching = true;
- url = "//api.4chan.org/" + g.BOARD + "/catalog.json";
- return $.ajax(url, {
- onloadend: InfiniScroll.cb.load
- }, {
- whenModified: true
- });
- }),
- parse: function(response) {
- var botPostForm, el, nodes, omitted_images, omitted_posts, op, post, postlink, posts, replylink, thread, threadID, threadNodes, threads, _i, _j, _len, _len1, _ref;
- threads = InfiniScroll.parsePages(response);
- threadNodes = [];
- nodes = [];
- if (!threads.length) {
- InfiniScroll.notice();
- return InfiniScroll.isDead = true;
- }
- for (_i = 0, _len = threads.length; _i < _len; _i++) {
- thread = threads[_i];
- posts = [];
- omitted_posts = thread.omitted_posts, omitted_images = thread.omitted_images;
- threadID = thread.no;
- el = $.el('div', {
- className: 'thread',
- id: "t" + threadID
- });
- op = Build.postFromObject(thread, g.BOARD);
- posts.push(op);
- replylink = $.el('a', {
- href: "res/" + threadID,
- className: 'replylink',
- textContent: 'Reply'
- });
- postlink = $.el('div', {
- className: "postLink mobile",
- innerHTML: "View Thread"
- });
- if (omitted_posts) {
- posts.push($.el('span', {
- className: 'summary desktop',
- innerHTML: "" + omitted_posts + " posts " + (omitted_images ? "and " + omitted_images + " image replies" : void 0) + " omitted. Click here to view."
- }));
- $.prepend(postlink, $.el('span', {
- className: 'info',
- innerHTML: "" + omitted_posts + " posts omitted" + (omitted_images ? "
(" + omitted_images + " have images)" : "")
- }));
- }
- $.add($('.postInfo', op), [$.tn('\u00A0\u00A0\u00A0['), replylink, $.tn(']\u00A0')]);
- $.add(op, postlink);
- if (thread.last_replies) {
- _ref = thread.last_replies;
- for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
- post = _ref[_j];
- posts.push(Build.postFromObject(post, g.BOARD));
- }
- }
- $.add(el, posts);
- threadNodes.push(el);
- nodes.push(el);
- nodes.push($.el('hr'));
- }
- InfiniScroll.features(threadNodes);
- if (botPostForm = $('.board > .mobile.center')) {
- return $.before(botPostForm, nodes);
- }
- },
- parsePages: function(response) {
- var newThreads, number, page, pages, thread, threads, _i, _len;
- pages = JSON.parse(response);
- newThreads = [];
- for (number in pages) {
- page = pages[number];
- if (!(pages.hasOwnProperty(number))) {
- continue;
- }
- threads = page.threads;
- for (_i = 0, _len = threads.length; _i < _len; _i++) {
- thread = threads[_i];
- if (g.threads["" + g.BOARD + "." + thread.no]) {
- continue;
- }
- newThreads.push(thread);
- if (newThreads.length === 15) {
- return newThreads;
- }
- }
- }
- return newThreads;
- },
- features: function(threadNodes) {
- var err, errors, post, posts, thread, threadRoot, threads, _i, _j, _len, _len1, _ref;
- posts = [];
- threads = [];
- for (_i = 0, _len = threadNodes.length; _i < _len; _i++) {
- threadRoot = threadNodes[_i];
- thread = new Thread(+threadRoot.id.slice(1), g.BOARD);
- threads.push(thread);
- _ref = $$('.thread > .postContainer', threadRoot);
- for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
- post = _ref[_j];
- try {
- posts.push(new Post(post, thread, g.BOARD));
- } catch (_error) {
- err = _error;
- if (!errors) {
- errors = [];
- }
- errors.push({
- message: "Parsing of Post No." + (postRoot.id.match(/\d+/)) + " failed. Post will be skipped.",
- error: err
- });
- }
- }
- }
- if (errors) {
- Main.handleErrors(errors);
- }
- Main.callbackNodes(Thread, threads);
- return Main.callbackNodes(Post, posts);
- },
- notice: (function() {
- var notify, reset;
- notify = false;
- reset = function() {
- return notify = false;
- };
- return function() {
- if (notify) {
- return;
- }
- notify = true;
- new Notice('info', "Last page reached.", 2);
- return setTimeout(reset, 3 * $.SECOND);
- };
- })(),
- cb: {
- load: function() {
- InfiniScroll.isFetching = false;
- if (this.status !== 200) {
- return;
- }
- InfiniScroll.cache = new String(this.response);
- InfiniScroll.cache.time = Date.now();
- return InfiniScroll.parse(this.response);
- }
- }
- };
-
Keybinds = {
init: function() {
var hotkey, init;
diff --git a/src/General/Index.coffee b/src/General/Index.coffee
index f324730ab..44e94c592 100644
--- a/src/General/Index.coffee
+++ b/src/General/Index.coffee
@@ -550,6 +550,7 @@ Index =
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD.ID}/catalog.json",
onabort: onload
onloadend: onload
+ onerror: onload
,
whenModified: board is g.BOARD.ID
$.addClass Index.button, 'fa-spin'
@@ -562,7 +563,7 @@ Index =
delete Index.req
delete Index.notice
- if e.type is 'abort'
+ if e.type in 'abort'
req.onloadend = null
notice.close()
return
diff --git a/src/Miscellaneous/InfiniScroll.coffee b/src/Miscellaneous/InfiniScroll.coffee
deleted file mode 100644
index 4579aff46..000000000
--- a/src/Miscellaneous/InfiniScroll.coffee
+++ /dev/null
@@ -1,139 +0,0 @@
-InfiniScroll =
- init: ->
- return unless Conf['Infinite Scrolling'] and g.VIEW is 'index' and g.BOARD isnt 'f'
-
- @threads = g.threads
-
- $.on d, '4chanXInitFinished', @ready
-
- ready: ->
- $.off d, '4chanXInitFinished', InfiniScroll.ready
- $.on d, 'scroll', InfiniScroll.scroll
- InfiniScroll.scroll()
-
- scroll: $.debounce 100, ->
- return if InfiniScroll.isFetching or ((d.body.scrollTop or doc.scrollTop) <= doc.scrollHeight - (300 + window.innerHeight))
- return InfiniScroll.notice() if InfiniScroll.isDead
-
- # For once, lets respect 4chan's API rules.
- if InfiniScroll.cache and InfiniScroll.cache.time > Date.now() - $.MINUTE
- return InfiniScroll.parse InfiniScroll.cache
-
- new Notice 'info', "Fetching next page.", 2
-
- InfiniScroll.isFetching = true
- url = "//api.4chan.org/#{g.BOARD}/catalog.json"
- $.ajax url, onloadend: InfiniScroll.cb.load,
- whenModified: true
-
- parse: (response) ->
- threads = InfiniScroll.parsePages response
- threadNodes = []
- nodes = []
-
- return unless threads.length
- InfiniScroll.notice()
- InfiniScroll.isDead = true
-
- for thread in threads
- posts = []
- {omitted_posts, omitted_images} = thread
- threadID = thread.no
-
- el = $.el 'div',
- className: 'thread'
- id: "t#{threadID}"
-
- op = Build.postFromObject thread, g.BOARD
- posts.push op
-
- replylink = $.el 'a',
- href: "res/#{threadID}"
- className: 'replylink'
- textContent: 'Reply'
-
- postlink = $.el 'div',
- className: "postLink mobile"
- innerHTML: """View Thread"""
-
- if omitted_posts
- posts.push $.el 'span',
- className: 'summary desktop'
- innerHTML: """
- #{omitted_posts} posts #{if omitted_images then "and " + omitted_images + " image replies"} omitted. Click here to view.
- """
-
- $.prepend postlink, $.el 'span',
- className: 'info'
- innerHTML: """
- #{omitted_posts} posts omitted#{if omitted_images then "
(#{omitted_images} have images)" else ""}
- """
-
- $.add $('.postInfo', op), [$.tn('\u00A0\u00A0\u00A0['), replylink, $.tn(']\u00A0')]
- $.add op, postlink
-
- if thread.last_replies then posts.push Build.postFromObject post, g.BOARD for post in thread.last_replies
-
- $.add el, posts
-
- threadNodes.push el
- nodes.push el
- nodes.push $.el 'hr'
-
- InfiniScroll.features threadNodes
-
- $.before botPostForm, nodes if botPostForm = $ '.board > .mobile.center'
-
- parsePages: (response) ->
- pages = JSON.parse response
- newThreads = []
-
- for number, page of pages when pages.hasOwnProperty number
- {threads} = page
- for thread in threads
- continue if g.threads["#{g.BOARD}.#{thread.no}"]
-
- newThreads.push thread
-
- return newThreads if newThreads.length is 15
-
- return newThreads
-
- features: (threadNodes) ->
- posts = []
- threads = []
- for threadRoot in threadNodes
- thread = new Thread +threadRoot.id[1..], g.BOARD
- threads.push thread
- for post in $$ '.thread > .postContainer', threadRoot
- try
- posts.push new Post post, thread, g.BOARD
- catch err
- # Skip posts that we failed to parse.
- unless errors
- errors = []
- errors.push
- message: "Parsing of Post No.#{postRoot.id.match(/\d+/)} failed. Post will be skipped."
- error: err
- Main.handleErrors errors if errors
-
- Main.callbackNodes Thread, threads
- Main.callbackNodes Post, posts
-
- notice: do ->
- notify = false
- reset = -> notify = false
- return ->
- return if notify
- notify = true
- new Notice 'info', "Last page reached.", 2
- setTimeout reset, 3 * $.SECOND
-
- cb:
- load: ->
- InfiniScroll.isFetching = false
- return unless @status is 200
-
- InfiniScroll.cache = new String @response
- InfiniScroll.cache.time = Date.now()
- InfiniScroll.parse @response
\ No newline at end of file