Remove Main.callbacknodes
This commit is contained in:
parent
5581b53414
commit
ca9abdc4e7
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.4.1 - 2014-03-13
|
* 4chan X - Version 1.4.1 - 2014-03-14
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.4.1 - 2014-03-13
|
* 4chan X - Version 1.4.1 - 2014-03-14
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||||
@ -849,24 +849,27 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Callbacks.prototype.execute = function(node) {
|
Callbacks.prototype.execute = function(nodes) {
|
||||||
var err, errors, name, _i, _len, _ref;
|
var cb, err, errors, i, j, name, node;
|
||||||
_ref = this.keys;
|
i = 0;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
while (name = this.keys[i++]) {
|
||||||
name = _ref[_i];
|
j = 0;
|
||||||
try {
|
cb = this[name];
|
||||||
if (!this[name].disconnected) {
|
while (node = nodes[j++]) {
|
||||||
this[name].call(node);
|
try {
|
||||||
|
if (!cb.disconnected) {
|
||||||
|
cb.call(node);
|
||||||
|
}
|
||||||
|
} catch (_error) {
|
||||||
|
err = _error;
|
||||||
|
if (!errors) {
|
||||||
|
errors = [];
|
||||||
|
}
|
||||||
|
errors.push({
|
||||||
|
message: ['"', name, '" crashed on node ', this.type, ' No.', node.ID, ' (', node.board, ').'].join(''),
|
||||||
|
error: err
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
|
||||||
err = _error;
|
|
||||||
if (!errors) {
|
|
||||||
errors = [];
|
|
||||||
}
|
|
||||||
errors.push({
|
|
||||||
message: ['"', name, '" crashed on node ', this.type, ' No.', node.ID, ' (', node.board, ').'].join(''),
|
|
||||||
error: err
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (errors) {
|
if (errors) {
|
||||||
@ -3319,8 +3322,8 @@
|
|||||||
if (errors) {
|
if (errors) {
|
||||||
Main.handleErrors(errors);
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
Main.callbackNodes(Thread, threads);
|
Thread.callbacks.execute(threads);
|
||||||
Main.callbackNodes(Post, posts);
|
Post.callbacks.execute(posts);
|
||||||
Index.updateHideLabel();
|
Index.updateHideLabel();
|
||||||
return $.event('IndexRefresh');
|
return $.event('IndexRefresh');
|
||||||
},
|
},
|
||||||
@ -3358,7 +3361,7 @@
|
|||||||
if (errors) {
|
if (errors) {
|
||||||
Main.handleErrors(errors);
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
return Main.callbackNodes(Post, posts);
|
return Post.callbacks.execute(posts);
|
||||||
},
|
},
|
||||||
buildCatalogViews: function() {
|
buildCatalogViews: function() {
|
||||||
var catalogThreads, i, nodes, thread, _i, _len, _ref;
|
var catalogThreads, i, nodes, thread, _i, _len, _ref;
|
||||||
@ -3370,7 +3373,7 @@
|
|||||||
catalogThreads.push(new CatalogThread(Build.catalogThread(thread), thread));
|
catalogThreads.push(new CatalogThread(Build.catalogThread(thread), thread));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Main.callbackNodes(CatalogThread, catalogThreads);
|
CatalogThread.callbacks.execute(catalogThreads);
|
||||||
nodes = [];
|
nodes = [];
|
||||||
i = 0;
|
i = 0;
|
||||||
while (thread = Index.sortedThreads[i++]) {
|
while (thread = Index.sortedThreads[i++]) {
|
||||||
@ -3989,7 +3992,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clone = post.addClone(context);
|
clone = post.addClone(context);
|
||||||
Main.callbackNodes(Clone, [clone]);
|
Clone.callbacks.execute([clone]);
|
||||||
nodes = clone.nodes;
|
nodes = clone.nodes;
|
||||||
$.rmAll(nodes.root);
|
$.rmAll(nodes.root);
|
||||||
$.add(nodes.root, nodes.post);
|
$.add(nodes.root, nodes.post);
|
||||||
@ -4046,7 +4049,7 @@
|
|||||||
board = g.boards[boardID] || new Board(boardID);
|
board = g.boards[boardID] || new Board(boardID);
|
||||||
thread = g.threads["" + boardID + "." + threadID] || new Thread(threadID, board);
|
thread = g.threads["" + boardID + "." + threadID] || new Thread(threadID, board);
|
||||||
post = new Post(Build.postFromObject(post, boardID), thread, board);
|
post = new Post(Build.postFromObject(post, boardID), thread, board);
|
||||||
Main.callbackNodes(Post, [post]);
|
Post.callbacks.execute([post]);
|
||||||
return Get.insert(post, root, context);
|
return Get.insert(post, root, context);
|
||||||
},
|
},
|
||||||
archivedPost: function(req, boardID, postID, root, context) {
|
archivedPost: function(req, boardID, postID, root, context) {
|
||||||
@ -4115,7 +4118,7 @@
|
|||||||
if ((_ref1 = $('.page-num', post.nodes.info)) != null) {
|
if ((_ref1 = $('.page-num', post.nodes.info)) != null) {
|
||||||
_ref1.hidden = true;
|
_ref1.hidden = true;
|
||||||
}
|
}
|
||||||
Main.callbackNodes(Post, [post]);
|
Post.callbacks.execute([post]);
|
||||||
return Get.insert(post, root, context);
|
return Get.insert(post, root, context);
|
||||||
},
|
},
|
||||||
parseMarkup: function(text) {
|
parseMarkup: function(text) {
|
||||||
@ -9878,7 +9881,7 @@
|
|||||||
ThreadUpdater.audio.play();
|
ThreadUpdater.audio.play();
|
||||||
}
|
}
|
||||||
ThreadUpdater.lastPost = posts[count - 1].ID;
|
ThreadUpdater.lastPost = posts[count - 1].ID;
|
||||||
Main.callbackNodes(Post, posts);
|
Post.callbacks.execute(posts);
|
||||||
scroll = Conf['Auto Scroll'] && ThreadUpdater.scrollBG() && Header.getBottomOf(ThreadUpdater.root) > -75;
|
scroll = Conf['Auto Scroll'] && ThreadUpdater.scrollBG() && Header.getBottomOf(ThreadUpdater.root) > -75;
|
||||||
for (_j = 0, _len1 = posts.length; _j < _len1; _j++) {
|
for (_j = 0, _len1 = posts.length; _j < _len1; _j++) {
|
||||||
post = posts[_j];
|
post = posts[_j];
|
||||||
@ -11539,7 +11542,7 @@
|
|||||||
posts.push(post);
|
posts.push(post);
|
||||||
postsRoot.push(root);
|
postsRoot.push(root);
|
||||||
}
|
}
|
||||||
Main.callbackNodes(Post, posts);
|
Post.callbacks.execute(posts);
|
||||||
$.after(a, postsRoot);
|
$.after(a, postsRoot);
|
||||||
postsCount = postsRoot.length;
|
postsCount = postsRoot.length;
|
||||||
return a.textContent = ExpandThread.text('-', postsRoot.length, filesCount);
|
return a.textContent = ExpandThread.text('-', postsRoot.length, filesCount);
|
||||||
@ -12817,8 +12820,8 @@
|
|||||||
makePost(post);
|
makePost(post);
|
||||||
$.add(threadRoot, post);
|
$.add(threadRoot, post);
|
||||||
}
|
}
|
||||||
Main.callbackNodes(Thread, [thread]);
|
Thread.callbacks.execute([thread]);
|
||||||
Main.callbackNodes(Post, posts);
|
Post.callbacks.execute(posts);
|
||||||
if (Conf['Quote Threading'] && !Conf['Unread Count']) {
|
if (Conf['Quote Threading'] && !Conf['Unread Count']) {
|
||||||
QuoteThreading.force();
|
QuoteThreading.force();
|
||||||
}
|
}
|
||||||
@ -13699,10 +13702,9 @@
|
|||||||
if (errors) {
|
if (errors) {
|
||||||
Main.handleErrors(errors);
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
Main.callbackNodes(Thread, threads);
|
Thread.callbacks.execute(threads);
|
||||||
Main.callbackNodesDB(Post, posts, function() {
|
Post.callbacks.execute(posts);
|
||||||
return $.event('4chanXInitFinished');
|
$.event('4chanXInitFinished');
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return $.get('previousversion', null, function(_arg) {
|
return $.get('previousversion', null, function(_arg) {
|
||||||
var changelog, el, previousversion;
|
var changelog, el, previousversion;
|
||||||
@ -13722,40 +13724,6 @@
|
|||||||
return $.set('previousversion', g.VERSION);
|
return $.set('previousversion', g.VERSION);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
callbackNodes: function(klass, nodes) {
|
|
||||||
var cb, i, node;
|
|
||||||
i = 0;
|
|
||||||
cb = klass.callbacks;
|
|
||||||
while (node = nodes[i++]) {
|
|
||||||
cb.execute(node);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callbackNodesDB: function(klass, nodes, cb) {
|
|
||||||
var cbs, fn, i, softTask;
|
|
||||||
i = 0;
|
|
||||||
cbs = klass.callbacks;
|
|
||||||
fn = function() {
|
|
||||||
var node;
|
|
||||||
if (!(node = nodes[i])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
cbs.execute(node);
|
|
||||||
return ++i % 25;
|
|
||||||
};
|
|
||||||
softTask = function() {
|
|
||||||
while (fn()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!nodes[i]) {
|
|
||||||
if (cb) {
|
|
||||||
cb();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return setTimeout(softTask, 0);
|
|
||||||
};
|
|
||||||
return softTask();
|
|
||||||
},
|
|
||||||
addCallback: function(e) {
|
addCallback: function(e) {
|
||||||
var Klass, obj;
|
var Klass, obj;
|
||||||
obj = e.detail;
|
obj = e.detail;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript
|
// Generated by CoffeeScript
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.4.1 - 2014-03-13
|
* 4chan X - Version 1.4.1 - 2014-03-14
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||||
@ -903,24 +903,27 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Callbacks.prototype.execute = function(node) {
|
Callbacks.prototype.execute = function(nodes) {
|
||||||
var err, errors, name, _i, _len, _ref;
|
var cb, err, errors, i, j, name, node;
|
||||||
_ref = this.keys;
|
i = 0;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
while (name = this.keys[i++]) {
|
||||||
name = _ref[_i];
|
j = 0;
|
||||||
try {
|
cb = this[name];
|
||||||
if (!this[name].disconnected) {
|
while (node = nodes[j++]) {
|
||||||
this[name].call(node);
|
try {
|
||||||
|
if (!cb.disconnected) {
|
||||||
|
cb.call(node);
|
||||||
|
}
|
||||||
|
} catch (_error) {
|
||||||
|
err = _error;
|
||||||
|
if (!errors) {
|
||||||
|
errors = [];
|
||||||
|
}
|
||||||
|
errors.push({
|
||||||
|
message: ['"', name, '" crashed on node ', this.type, ' No.', node.ID, ' (', node.board, ').'].join(''),
|
||||||
|
error: err
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
|
||||||
err = _error;
|
|
||||||
if (!errors) {
|
|
||||||
errors = [];
|
|
||||||
}
|
|
||||||
errors.push({
|
|
||||||
message: ['"', name, '" crashed on node ', this.type, ' No.', node.ID, ' (', node.board, ').'].join(''),
|
|
||||||
error: err
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (errors) {
|
if (errors) {
|
||||||
@ -3378,8 +3381,8 @@
|
|||||||
if (errors) {
|
if (errors) {
|
||||||
Main.handleErrors(errors);
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
Main.callbackNodes(Thread, threads);
|
Thread.callbacks.execute(threads);
|
||||||
Main.callbackNodes(Post, posts);
|
Post.callbacks.execute(posts);
|
||||||
Index.updateHideLabel();
|
Index.updateHideLabel();
|
||||||
return $.event('IndexRefresh');
|
return $.event('IndexRefresh');
|
||||||
},
|
},
|
||||||
@ -3417,7 +3420,7 @@
|
|||||||
if (errors) {
|
if (errors) {
|
||||||
Main.handleErrors(errors);
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
return Main.callbackNodes(Post, posts);
|
return Post.callbacks.execute(posts);
|
||||||
},
|
},
|
||||||
buildCatalogViews: function() {
|
buildCatalogViews: function() {
|
||||||
var catalogThreads, i, nodes, thread, _i, _len, _ref;
|
var catalogThreads, i, nodes, thread, _i, _len, _ref;
|
||||||
@ -3429,7 +3432,7 @@
|
|||||||
catalogThreads.push(new CatalogThread(Build.catalogThread(thread), thread));
|
catalogThreads.push(new CatalogThread(Build.catalogThread(thread), thread));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Main.callbackNodes(CatalogThread, catalogThreads);
|
CatalogThread.callbacks.execute(catalogThreads);
|
||||||
nodes = [];
|
nodes = [];
|
||||||
i = 0;
|
i = 0;
|
||||||
while (thread = Index.sortedThreads[i++]) {
|
while (thread = Index.sortedThreads[i++]) {
|
||||||
@ -4048,7 +4051,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clone = post.addClone(context);
|
clone = post.addClone(context);
|
||||||
Main.callbackNodes(Clone, [clone]);
|
Clone.callbacks.execute([clone]);
|
||||||
nodes = clone.nodes;
|
nodes = clone.nodes;
|
||||||
$.rmAll(nodes.root);
|
$.rmAll(nodes.root);
|
||||||
$.add(nodes.root, nodes.post);
|
$.add(nodes.root, nodes.post);
|
||||||
@ -4105,7 +4108,7 @@
|
|||||||
board = g.boards[boardID] || new Board(boardID);
|
board = g.boards[boardID] || new Board(boardID);
|
||||||
thread = g.threads["" + boardID + "." + threadID] || new Thread(threadID, board);
|
thread = g.threads["" + boardID + "." + threadID] || new Thread(threadID, board);
|
||||||
post = new Post(Build.postFromObject(post, boardID), thread, board);
|
post = new Post(Build.postFromObject(post, boardID), thread, board);
|
||||||
Main.callbackNodes(Post, [post]);
|
Post.callbacks.execute([post]);
|
||||||
return Get.insert(post, root, context);
|
return Get.insert(post, root, context);
|
||||||
},
|
},
|
||||||
archivedPost: function(req, boardID, postID, root, context) {
|
archivedPost: function(req, boardID, postID, root, context) {
|
||||||
@ -4174,7 +4177,7 @@
|
|||||||
if ((_ref1 = $('.page-num', post.nodes.info)) != null) {
|
if ((_ref1 = $('.page-num', post.nodes.info)) != null) {
|
||||||
_ref1.hidden = true;
|
_ref1.hidden = true;
|
||||||
}
|
}
|
||||||
Main.callbackNodes(Post, [post]);
|
Post.callbacks.execute([post]);
|
||||||
return Get.insert(post, root, context);
|
return Get.insert(post, root, context);
|
||||||
},
|
},
|
||||||
parseMarkup: function(text) {
|
parseMarkup: function(text) {
|
||||||
@ -9893,7 +9896,7 @@
|
|||||||
ThreadUpdater.audio.play();
|
ThreadUpdater.audio.play();
|
||||||
}
|
}
|
||||||
ThreadUpdater.lastPost = posts[count - 1].ID;
|
ThreadUpdater.lastPost = posts[count - 1].ID;
|
||||||
Main.callbackNodes(Post, posts);
|
Post.callbacks.execute(posts);
|
||||||
scroll = Conf['Auto Scroll'] && ThreadUpdater.scrollBG() && Header.getBottomOf(ThreadUpdater.root) > -75;
|
scroll = Conf['Auto Scroll'] && ThreadUpdater.scrollBG() && Header.getBottomOf(ThreadUpdater.root) > -75;
|
||||||
for (_j = 0, _len1 = posts.length; _j < _len1; _j++) {
|
for (_j = 0, _len1 = posts.length; _j < _len1; _j++) {
|
||||||
post = posts[_j];
|
post = posts[_j];
|
||||||
@ -11553,7 +11556,7 @@
|
|||||||
posts.push(post);
|
posts.push(post);
|
||||||
postsRoot.push(root);
|
postsRoot.push(root);
|
||||||
}
|
}
|
||||||
Main.callbackNodes(Post, posts);
|
Post.callbacks.execute(posts);
|
||||||
$.after(a, postsRoot);
|
$.after(a, postsRoot);
|
||||||
postsCount = postsRoot.length;
|
postsCount = postsRoot.length;
|
||||||
return a.textContent = ExpandThread.text('-', postsRoot.length, filesCount);
|
return a.textContent = ExpandThread.text('-', postsRoot.length, filesCount);
|
||||||
@ -12831,8 +12834,8 @@
|
|||||||
makePost(post);
|
makePost(post);
|
||||||
$.add(threadRoot, post);
|
$.add(threadRoot, post);
|
||||||
}
|
}
|
||||||
Main.callbackNodes(Thread, [thread]);
|
Thread.callbacks.execute([thread]);
|
||||||
Main.callbackNodes(Post, posts);
|
Post.callbacks.execute(posts);
|
||||||
if (Conf['Quote Threading'] && !Conf['Unread Count']) {
|
if (Conf['Quote Threading'] && !Conf['Unread Count']) {
|
||||||
QuoteThreading.force();
|
QuoteThreading.force();
|
||||||
}
|
}
|
||||||
@ -13696,10 +13699,9 @@
|
|||||||
if (errors) {
|
if (errors) {
|
||||||
Main.handleErrors(errors);
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
Main.callbackNodes(Thread, threads);
|
Thread.callbacks.execute(threads);
|
||||||
Main.callbackNodesDB(Post, posts, function() {
|
Post.callbacks.execute(posts);
|
||||||
return $.event('4chanXInitFinished');
|
$.event('4chanXInitFinished');
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return $.get('previousversion', null, function(_arg) {
|
return $.get('previousversion', null, function(_arg) {
|
||||||
var changelog, el, previousversion;
|
var changelog, el, previousversion;
|
||||||
@ -13719,40 +13721,6 @@
|
|||||||
return $.set('previousversion', g.VERSION);
|
return $.set('previousversion', g.VERSION);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
callbackNodes: function(klass, nodes) {
|
|
||||||
var cb, i, node;
|
|
||||||
i = 0;
|
|
||||||
cb = klass.callbacks;
|
|
||||||
while (node = nodes[i++]) {
|
|
||||||
cb.execute(node);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callbackNodesDB: function(klass, nodes, cb) {
|
|
||||||
var cbs, fn, i, softTask;
|
|
||||||
i = 0;
|
|
||||||
cbs = klass.callbacks;
|
|
||||||
fn = function() {
|
|
||||||
var node;
|
|
||||||
if (!(node = nodes[i])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
cbs.execute(node);
|
|
||||||
return ++i % 25;
|
|
||||||
};
|
|
||||||
softTask = function() {
|
|
||||||
while (fn()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!nodes[i]) {
|
|
||||||
if (cb) {
|
|
||||||
cb();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return setTimeout(softTask, 0);
|
|
||||||
};
|
|
||||||
return softTask();
|
|
||||||
},
|
|
||||||
addCallback: function(e) {
|
addCallback: function(e) {
|
||||||
var Klass, obj;
|
var Klass, obj;
|
||||||
obj = e.detail;
|
obj = e.detail;
|
||||||
|
|||||||
@ -81,7 +81,7 @@ Get =
|
|||||||
# Stop here if the container has been removed while loading.
|
# Stop here if the container has been removed while loading.
|
||||||
return unless root.parentNode
|
return unless root.parentNode
|
||||||
clone = post.addClone context
|
clone = post.addClone context
|
||||||
Main.callbackNodes Clone, [clone]
|
Clone.callbacks.execute [clone]
|
||||||
|
|
||||||
# Get rid of the side arrows/stubs.
|
# Get rid of the side arrows/stubs.
|
||||||
{nodes} = clone
|
{nodes} = clone
|
||||||
@ -136,7 +136,7 @@ Get =
|
|||||||
thread = g.threads["#{boardID}.#{threadID}"] or
|
thread = g.threads["#{boardID}.#{threadID}"] or
|
||||||
new Thread threadID, board
|
new Thread threadID, board
|
||||||
post = new Post Build.postFromObject(post, boardID), thread, board
|
post = new Post Build.postFromObject(post, boardID), thread, board
|
||||||
Main.callbackNodes Post, [post]
|
Post.callbacks.execute [post]
|
||||||
Get.insert post, root, context
|
Get.insert post, root, context
|
||||||
archivedPost: (req, boardID, postID, root, context) ->
|
archivedPost: (req, boardID, postID, root, context) ->
|
||||||
# In case of multiple callbacks for the same request,
|
# In case of multiple callbacks for the same request,
|
||||||
@ -209,7 +209,7 @@ Get =
|
|||||||
new Thread threadID, board
|
new Thread threadID, board
|
||||||
post = new Post Build.post(o, true), thread, board, {isArchived: true}
|
post = new Post Build.post(o, true), thread, board, {isArchived: true}
|
||||||
$('.page-num', post.nodes.info)?.hidden = true
|
$('.page-num', post.nodes.info)?.hidden = true
|
||||||
Main.callbackNodes Post, [post]
|
Post.callbacks.execute [post]
|
||||||
Get.insert post, root, context
|
Get.insert post, root, context
|
||||||
parseMarkup: (text) ->
|
parseMarkup: (text) ->
|
||||||
{
|
{
|
||||||
|
|||||||
@ -622,8 +622,8 @@ Index =
|
|||||||
error: err
|
error: err
|
||||||
|
|
||||||
Main.handleErrors errors if errors
|
Main.handleErrors errors if errors
|
||||||
Main.callbackNodes Thread, threads
|
Thread.callbacks.execute threads
|
||||||
Main.callbackNodes Post, posts
|
Post.callbacks.execute posts
|
||||||
Index.updateHideLabel()
|
Index.updateHideLabel()
|
||||||
|
|
||||||
$.event 'IndexRefresh'
|
$.event 'IndexRefresh'
|
||||||
@ -649,13 +649,13 @@ Index =
|
|||||||
$.add thread.OP.nodes.root.parentNode, nodes
|
$.add thread.OP.nodes.root.parentNode, nodes
|
||||||
|
|
||||||
Main.handleErrors errors if errors
|
Main.handleErrors errors if errors
|
||||||
Main.callbackNodes Post, posts
|
Post.callbacks.execute posts
|
||||||
|
|
||||||
buildCatalogViews: ->
|
buildCatalogViews: ->
|
||||||
catalogThreads = []
|
catalogThreads = []
|
||||||
for thread in Index.sortedThreads when !thread.catalogView
|
for thread in Index.sortedThreads when !thread.catalogView
|
||||||
catalogThreads.push new CatalogThread Build.catalogThread(thread), thread
|
catalogThreads.push new CatalogThread Build.catalogThread(thread), thread
|
||||||
Main.callbackNodes CatalogThread, catalogThreads
|
CatalogThread.callbacks.execute catalogThreads
|
||||||
nodes = []
|
nodes = []
|
||||||
i = 0
|
i = 0
|
||||||
while thread = Index.sortedThreads[i++]
|
while thread = Index.sortedThreads[i++]
|
||||||
|
|||||||
@ -230,9 +230,10 @@ Main =
|
|||||||
error: err
|
error: err
|
||||||
Main.handleErrors errors if errors
|
Main.handleErrors errors if errors
|
||||||
|
|
||||||
Main.callbackNodes Thread, threads
|
Thread.callbacks.execute threads
|
||||||
Main.callbackNodesDB Post, posts, ->
|
Post.callbacks.execute posts
|
||||||
$.event '4chanXInitFinished'
|
|
||||||
|
$.event '4chanXInitFinished'
|
||||||
|
|
||||||
$.get 'previousversion', null, ({previousversion}) ->
|
$.get 'previousversion', null, ({previousversion}) ->
|
||||||
return if previousversion is g.VERSION
|
return if previousversion is g.VERSION
|
||||||
@ -245,31 +246,6 @@ Main =
|
|||||||
Settings.open()
|
Settings.open()
|
||||||
$.set 'previousversion', g.VERSION
|
$.set 'previousversion', g.VERSION
|
||||||
|
|
||||||
callbackNodes: (klass, nodes) ->
|
|
||||||
i = 0
|
|
||||||
cb = klass.callbacks
|
|
||||||
while node = nodes[i++]
|
|
||||||
cb.execute node
|
|
||||||
return
|
|
||||||
|
|
||||||
callbackNodesDB: (klass, nodes, cb) ->
|
|
||||||
i = 0
|
|
||||||
cbs = klass.callbacks
|
|
||||||
fn = ->
|
|
||||||
return false unless node = nodes[i]
|
|
||||||
cbs.execute node
|
|
||||||
++i % 25
|
|
||||||
|
|
||||||
softTask = ->
|
|
||||||
while fn()
|
|
||||||
continue
|
|
||||||
unless nodes[i]
|
|
||||||
cb() if cb
|
|
||||||
return
|
|
||||||
setTimeout softTask, 0
|
|
||||||
|
|
||||||
softTask()
|
|
||||||
|
|
||||||
addCallback: (e) ->
|
addCallback: (e) ->
|
||||||
obj = e.detail
|
obj = e.detail
|
||||||
unless typeof obj.callback.name is 'string'
|
unless typeof obj.callback.name is 'string'
|
||||||
|
|||||||
@ -312,8 +312,8 @@ Navigate =
|
|||||||
makePost post
|
makePost post
|
||||||
$.add threadRoot, post
|
$.add threadRoot, post
|
||||||
|
|
||||||
Main.callbackNodes Thread, [thread]
|
Thread.callbacks.execute [thread]
|
||||||
Main.callbackNodes Post, posts
|
Post.callbacks.execute posts
|
||||||
|
|
||||||
QuoteThreading.force() if Conf['Quote Threading'] and not Conf['Unread Count']
|
QuoteThreading.force() if Conf['Quote Threading'] and not Conf['Unread Count']
|
||||||
|
|
||||||
|
|||||||
@ -10,14 +10,22 @@ class Callbacks
|
|||||||
connect: (name) -> delete @[name].disconnected if @[name].disconnected
|
connect: (name) -> delete @[name].disconnected if @[name].disconnected
|
||||||
disconnect: (name) -> @[name].disconnected = true if @[name]
|
disconnect: (name) -> @[name].disconnected = true if @[name]
|
||||||
|
|
||||||
execute: (node) ->
|
execute: (nodes) ->
|
||||||
for name in @keys
|
i = 0
|
||||||
try
|
# c.time 'Features'
|
||||||
@[name].call node unless @[name].disconnected
|
while name = @keys[i++]
|
||||||
catch err
|
j = 0
|
||||||
errors = [] unless errors
|
cb = @[name]
|
||||||
errors.push
|
# c.time name
|
||||||
message: ['"', name, '" crashed on node ', @type, ' No.', node.ID, ' (', node.board, ').'].join('')
|
while node = nodes[j++]
|
||||||
error: err
|
try
|
||||||
|
cb.call node unless cb.disconnected
|
||||||
|
catch err
|
||||||
|
errors = [] unless errors
|
||||||
|
errors.push
|
||||||
|
message: ['"', name, '" crashed on node ', @type, ' No.', node.ID, ' (', node.board, ').'].join('')
|
||||||
|
error: err
|
||||||
|
# c.timeEnd name
|
||||||
|
# c.timeEnd 'Features'
|
||||||
|
|
||||||
Main.handleErrors errors if errors
|
Main.handleErrors errors if errors
|
||||||
|
|||||||
@ -100,7 +100,7 @@ ExpandThread =
|
|||||||
filesCount++ if 'file' of post
|
filesCount++ if 'file' of post
|
||||||
posts.push post
|
posts.push post
|
||||||
postsRoot.push root
|
postsRoot.push root
|
||||||
Main.callbackNodes Post, posts
|
Post.callbacks.execute posts
|
||||||
$.after a, postsRoot
|
$.after a, postsRoot
|
||||||
|
|
||||||
postsCount = postsRoot.length
|
postsCount = postsRoot.length
|
||||||
|
|||||||
@ -332,7 +332,7 @@ ThreadUpdater =
|
|||||||
ThreadUpdater.audio.play()
|
ThreadUpdater.audio.play()
|
||||||
|
|
||||||
ThreadUpdater.lastPost = posts[count - 1].ID
|
ThreadUpdater.lastPost = posts[count - 1].ID
|
||||||
Main.callbackNodes Post, posts
|
Post.callbacks.execute posts
|
||||||
|
|
||||||
scroll = Conf['Auto Scroll'] and ThreadUpdater.scrollBG() and Header.getBottomOf(ThreadUpdater.root) > -75
|
scroll = Conf['Auto Scroll'] and ThreadUpdater.scrollBG() and Header.getBottomOf(ThreadUpdater.root) > -75
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user