Add AddCallback API. #932 @milkytiptoe
This commit is contained in:
parent
5c171ac371
commit
4bceb059d9
@ -7291,6 +7291,7 @@
|
||||
initFeature('Index Navigation', Nav);
|
||||
initFeature('Keybinds', Keybinds);
|
||||
console.timeEnd('All initializations');
|
||||
$.on(d, 'AddCallback', Main.addCallback);
|
||||
$.on(d, '4chanMainInit', Main.initStyle);
|
||||
return $.ready(Main.initReady);
|
||||
},
|
||||
@ -7416,6 +7417,13 @@
|
||||
return Main.handleErrors(errors);
|
||||
}
|
||||
},
|
||||
addCallback: function(e) {
|
||||
var Klass, obj;
|
||||
obj = e.detail;
|
||||
Klass = obj.type === 'Post' ? Post : Thread;
|
||||
obj.callback.isAddon = true;
|
||||
return Klass.prototype.callbacks.push(obj.callback);
|
||||
},
|
||||
handleErrors: function(errors) {
|
||||
var div, error, logs, _i, _len;
|
||||
if (!('length' in errors)) {
|
||||
|
||||
@ -357,6 +357,7 @@ Main =
|
||||
initFeature 'Keybinds', Keybinds
|
||||
console.timeEnd 'All initializations'
|
||||
|
||||
$.on d, 'AddCallback', Main.addCallback
|
||||
$.on d, '4chanMainInit', Main.initStyle
|
||||
$.ready Main.initReady
|
||||
|
||||
@ -450,6 +451,15 @@ Main =
|
||||
# console.profileEnd callback.name
|
||||
Main.handleErrors errors if errors
|
||||
|
||||
addCallback: (e) ->
|
||||
obj = e.detail
|
||||
Klass = if obj.type is 'Post'
|
||||
Post
|
||||
else
|
||||
Thread
|
||||
obj.callback.isAddon = true
|
||||
Klass::callbacks.push obj.callback
|
||||
|
||||
handleErrors: (errors) ->
|
||||
unless 'length' of errors
|
||||
error = errors
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user