$.onLoad
This commit is contained in:
parent
b80c700c4a
commit
726335775c
@ -307,6 +307,15 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.extend($, {
|
$.extend($, {
|
||||||
|
onLoad: function(fc) {
|
||||||
|
var cb;
|
||||||
|
if (/interactive|complete/.test(d.readyState)) return fc();
|
||||||
|
cb = function() {
|
||||||
|
$.off(d, 'DOMContentLoaded', cb);
|
||||||
|
return fc();
|
||||||
|
};
|
||||||
|
return $.on(d, 'DOMContentLoaded', cb);
|
||||||
|
},
|
||||||
id: function(id) {
|
id: function(id) {
|
||||||
return d.getElementById(id);
|
return d.getElementById(id);
|
||||||
},
|
},
|
||||||
@ -3074,7 +3083,7 @@
|
|||||||
|
|
||||||
Main = {
|
Main = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var cutoff, hiddenThreads, id, now, pathname, temp, timestamp, update, _ref;
|
var cutoff, hiddenThreads, id, now, pathname, temp, timestamp, _ref;
|
||||||
pathname = location.pathname.slice(1).split('/');
|
pathname = location.pathname.slice(1).split('/');
|
||||||
g.BOARD = pathname[0], temp = pathname[1];
|
g.BOARD = pathname[0], temp = pathname[1];
|
||||||
if (temp === 'res') {
|
if (temp === 'res') {
|
||||||
@ -3084,27 +3093,17 @@
|
|||||||
g.PAGENUM = parseInt(temp) || 0;
|
g.PAGENUM = parseInt(temp) || 0;
|
||||||
}
|
}
|
||||||
if (location.hostname === 'sys.4chan.org') {
|
if (location.hostname === 'sys.4chan.org') {
|
||||||
if (/interactive|complete/.test(d.readyState)) {
|
$.onLoad(qr.sys);
|
||||||
qr.sys();
|
|
||||||
} else {
|
|
||||||
$.on(d, 'DOMContentLoaded', qr.sys);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.on(window, 'message', Main.message);
|
$.on(window, 'message', Main.message);
|
||||||
now = Date.now();
|
now = Date.now();
|
||||||
if (conf['Check for Updates'] && $.get('lastUpdate', 0) < now - 6 * HOUR) {
|
if (conf['Check for Updates'] && $.get('lastUpdate', 0) < now - 6 * HOUR) {
|
||||||
update = function() {
|
$.onLoad(function() {
|
||||||
$.off(d, 'DOMContentLoaded', update);
|
|
||||||
return $.add(d.head, $.el('script', {
|
return $.add(d.head, $.el('script', {
|
||||||
src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js'
|
src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js'
|
||||||
}));
|
}));
|
||||||
};
|
});
|
||||||
if (/interactive|complete/.test(d.readyState)) {
|
|
||||||
update();
|
|
||||||
} else {
|
|
||||||
$.on(d, 'DOMContentLoaded', update);
|
|
||||||
}
|
|
||||||
$.set('lastUpdate', now);
|
$.set('lastUpdate', now);
|
||||||
}
|
}
|
||||||
g.hiddenReplies = $.get("hiddenReplies/" + g.BOARD + "/", {});
|
g.hiddenReplies = $.get("hiddenReplies/" + g.BOARD + "/", {});
|
||||||
@ -3138,15 +3137,10 @@
|
|||||||
if (conf['Quote Backlinks']) quoteBacklink.init();
|
if (conf['Quote Backlinks']) quoteBacklink.init();
|
||||||
if (conf['Indicate OP quote']) quoteOP.init();
|
if (conf['Indicate OP quote']) quoteOP.init();
|
||||||
if (conf['Indicate Cross-thread Quotes']) quoteDR.init();
|
if (conf['Indicate Cross-thread Quotes']) quoteDR.init();
|
||||||
if (/interactive|complete/.test(d.readyState)) {
|
return $.onLoad(Main.onLoad);
|
||||||
return Main.onLoad();
|
|
||||||
} else {
|
|
||||||
return $.on(d, 'DOMContentLoaded', Main.onLoad);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
var callback, canPost, form, node, nodes, _i, _j, _len, _len2, _ref;
|
var callback, canPost, form, node, nodes, _i, _j, _len, _len2, _ref;
|
||||||
$.off(d, 'DOMContentLoaded', Main.onLoad);
|
|
||||||
if (conf['404 Redirect'] && d.title === '4chan - 404') {
|
if (conf['404 Redirect'] && d.title === '4chan - 404') {
|
||||||
redirect.init();
|
redirect.init();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -221,6 +221,13 @@ $.extend = (object, properties) ->
|
|||||||
object
|
object
|
||||||
|
|
||||||
$.extend $,
|
$.extend $,
|
||||||
|
onLoad: (fc) ->
|
||||||
|
if /interactive|complete/.test d.readyState
|
||||||
|
return fc()
|
||||||
|
cb = ->
|
||||||
|
$.off d, 'DOMContentLoaded', cb
|
||||||
|
fc()
|
||||||
|
$.on d, 'DOMContentLoaded', cb
|
||||||
id: (id) ->
|
id: (id) ->
|
||||||
d.getElementById id
|
d.getElementById id
|
||||||
globalEval: (code) ->
|
globalEval: (code) ->
|
||||||
@ -2388,23 +2395,14 @@ Main =
|
|||||||
g.PAGENUM = parseInt(temp) or 0
|
g.PAGENUM = parseInt(temp) or 0
|
||||||
|
|
||||||
if location.hostname is 'sys.4chan.org'
|
if location.hostname is 'sys.4chan.org'
|
||||||
if /interactive|complete/.test d.readyState
|
$.onLoad qr.sys
|
||||||
qr.sys()
|
|
||||||
else
|
|
||||||
$.on d, 'DOMContentLoaded', qr.sys
|
|
||||||
return
|
return
|
||||||
|
|
||||||
$.on window, 'message', Main.message
|
$.on window, 'message', Main.message
|
||||||
|
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
if conf['Check for Updates'] and $.get('lastUpdate', 0) < now - 6*HOUR
|
if conf['Check for Updates'] and $.get('lastUpdate', 0) < now - 6*HOUR
|
||||||
update = ->
|
$.onLoad -> $.add d.head, $.el 'script', src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js'
|
||||||
$.off d, 'DOMContentLoaded', update
|
|
||||||
$.add d.head, $.el 'script', src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js'
|
|
||||||
if /interactive|complete/.test d.readyState
|
|
||||||
update()
|
|
||||||
else
|
|
||||||
$.on d, 'DOMContentLoaded', update
|
|
||||||
$.set 'lastUpdate', now
|
$.set 'lastUpdate', now
|
||||||
|
|
||||||
g.hiddenReplies = $.get "hiddenReplies/#{g.BOARD}/", {}
|
g.hiddenReplies = $.get "hiddenReplies/#{g.BOARD}/", {}
|
||||||
@ -2470,13 +2468,9 @@ Main =
|
|||||||
quoteDR.init()
|
quoteDR.init()
|
||||||
|
|
||||||
|
|
||||||
if /interactive|complete/.test d.readyState
|
$.onLoad Main.onLoad
|
||||||
Main.onLoad()
|
|
||||||
else
|
|
||||||
$.on d, 'DOMContentLoaded', Main.onLoad
|
|
||||||
|
|
||||||
onLoad: ->
|
onLoad: ->
|
||||||
$.off d, 'DOMContentLoaded', Main.onLoad
|
|
||||||
if conf['404 Redirect'] and d.title is '4chan - 404'
|
if conf['404 Redirect'] and d.title is '4chan - 404'
|
||||||
redirect.init()
|
redirect.init()
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user