Start working on getting index navigation from a thread working
This commit is contained in:
parent
9368cbb232
commit
41e3fa05ad
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.2.45 - 2014-01-07
|
* 4chan X - Version 1.2.45 - 2014-01-08
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.2.45 - 2014-01-07
|
* 4chan X - Version 1.2.45 - 2014-01-08
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
@ -2146,7 +2146,7 @@
|
|||||||
Index = {
|
Index = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var anchorEntry, input, label, modeEntry, name, refNavEntry, repliesEntry, sortEntry, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
var anchorEntry, input, label, modeEntry, name, refNavEntry, repliesEntry, sortEntry, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||||
if (g.VIEW !== 'index' || g.BOARD.ID === 'f') {
|
if (g.BOARD.ID === 'f') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.button = $.el('a', {
|
this.button = $.el('a', {
|
||||||
@ -2257,6 +2257,12 @@
|
|||||||
order: 90,
|
order: 90,
|
||||||
subEntries: [repliesEntry, anchorEntry, refNavEntry, modeEntry, sortEntry]
|
subEntries: [repliesEntry, anchorEntry, refNavEntry, modeEntry, sortEntry]
|
||||||
});
|
});
|
||||||
|
if (g.VIEW !== 'index') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.connect.call(this);
|
||||||
|
},
|
||||||
|
connect: function() {
|
||||||
$.addClass(doc, 'index-loading');
|
$.addClass(doc, 'index-loading');
|
||||||
this.update();
|
this.update();
|
||||||
this.root = $.el('div', {
|
this.root = $.el('div', {
|
||||||
@ -2280,13 +2286,13 @@
|
|||||||
return $.asap((function() {
|
return $.asap((function() {
|
||||||
return $('.board', doc) || d.readyState !== 'loading';
|
return $('.board', doc) || d.readyState !== 'loading';
|
||||||
}), function() {
|
}), function() {
|
||||||
var board, navLink, _l, _len3, _ref3;
|
var board, navLink, _i, _len, _ref;
|
||||||
board = $('.board');
|
board = $('.board');
|
||||||
$.replace(board, Index.root);
|
$.replace(board, Index.root);
|
||||||
d.implementation.createDocument(null, null, null).appendChild(board);
|
d.implementation.createDocument(null, null, null).appendChild(board);
|
||||||
_ref3 = $$('.navLinks');
|
_ref = $$('.navLinks');
|
||||||
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
navLink = _ref3[_l];
|
navLink = _ref[_i];
|
||||||
$.rm(navLink);
|
$.rm(navLink);
|
||||||
}
|
}
|
||||||
$.after($.x('child::form/preceding-sibling::hr[1]'), Index.navLinks);
|
$.after($.x('child::form/preceding-sibling::hr[1]'), Index.navLinks);
|
||||||
@ -2294,7 +2300,12 @@
|
|||||||
return $.asap((function() {
|
return $.asap((function() {
|
||||||
return $('.pagelist') || d.readyState !== 'loading';
|
return $('.pagelist') || d.readyState !== 'loading';
|
||||||
}), function() {
|
}), function() {
|
||||||
return $.replace($('.pagelist'), Index.pagelist);
|
var pagelist;
|
||||||
|
if (pagelist = $('.pagelist')) {
|
||||||
|
return $.replace(pagelist, Index.pagelist);
|
||||||
|
} else {
|
||||||
|
return $.after($.id('delform'), Index.pagelist);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -2444,19 +2455,14 @@
|
|||||||
if ((_ref1 = Index.notice) != null) {
|
if ((_ref1 = Index.notice) != null) {
|
||||||
_ref1.close();
|
_ref1.close();
|
||||||
}
|
}
|
||||||
if (d.readyState !== 'loading') {
|
now = Date.now();
|
||||||
Index.notice = new Notice('info', 'Refreshing index...');
|
$.ready(function() {
|
||||||
} else {
|
return setTimeout((function() {
|
||||||
now = Date.now();
|
if (Index.req && !Index.notice) {
|
||||||
$.ready(function() {
|
|
||||||
return setTimeout((function() {
|
|
||||||
if (!(Index.req && !Index.notice)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return Index.notice = new Notice('info', 'Refreshing index...');
|
return Index.notice = new Notice('info', 'Refreshing index...');
|
||||||
}), 5 * $.SECOND - (Date.now() - now));
|
}
|
||||||
});
|
}), 5 * $.SECOND - (Date.now() - now));
|
||||||
}
|
});
|
||||||
if (typeof pageNum !== 'number') {
|
if (typeof pageNum !== 'number') {
|
||||||
pageNum = null;
|
pageNum = null;
|
||||||
}
|
}
|
||||||
@ -5023,7 +5029,7 @@
|
|||||||
});
|
});
|
||||||
input = $('input', this.controls);
|
input = $('input', this.controls);
|
||||||
$.on(input, 'change', this.toggle);
|
$.on(input, 'change', this.toggle);
|
||||||
$.event('AddMenuEntry', {
|
$.event('AddMenuEntry', this.entry = {
|
||||||
type: 'header',
|
type: 'header',
|
||||||
el: this.controls,
|
el: this.controls,
|
||||||
order: 98
|
order: 98
|
||||||
@ -5036,6 +5042,16 @@
|
|||||||
cb: this.node
|
cb: this.node
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
disconnect: function() {
|
||||||
|
var input;
|
||||||
|
input = $('input', this.controls);
|
||||||
|
$.off(input, 'change', this.toggle);
|
||||||
|
$.event('rmMenuEntry', this.entry);
|
||||||
|
delete this.enabled;
|
||||||
|
delete this.controls;
|
||||||
|
delete this.entry;
|
||||||
|
return Post.callbacks.rm('Quote Threading');
|
||||||
|
},
|
||||||
setup: function() {
|
setup: function() {
|
||||||
$.off(d, '4chanXInitFinished', QuoteThreading.setup);
|
$.off(d, '4chanXInitFinished', QuoteThreading.setup);
|
||||||
return QuoteThreading.force();
|
return QuoteThreading.force();
|
||||||
@ -12777,16 +12793,32 @@
|
|||||||
return _results;
|
return _results;
|
||||||
},
|
},
|
||||||
disconnect: function() {
|
disconnect: function() {
|
||||||
var feature, name, _ref;
|
var err, errors, feature, features, name;
|
||||||
_ref = Main.features;
|
if (g.VIEW === 'thread') {
|
||||||
for (name in _ref) {
|
features = {
|
||||||
feature = _ref[name];
|
'Thread Updater': ThreadUpdater,
|
||||||
if (feature.disconnect) {
|
'Unread Count': Unread,
|
||||||
feature.disconnect();
|
'Quote Threading': QuoteThreading
|
||||||
|
};
|
||||||
|
}
|
||||||
|
for (name in features) {
|
||||||
|
feature = features[name];
|
||||||
|
try {
|
||||||
|
feature.disconnect.call(feature);
|
||||||
|
} catch (_error) {
|
||||||
|
err = _error;
|
||||||
|
if (!errors) {
|
||||||
|
errors = [];
|
||||||
|
}
|
||||||
|
errors.push({
|
||||||
|
message: "Failed to disconnect feature " + name + ".",
|
||||||
|
error: err
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (errors) {
|
||||||
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Post.callbacks.clear();
|
|
||||||
Thread.callbacks.clear();
|
|
||||||
return $.rmAll($('.board'));
|
return $.rmAll($('.board'));
|
||||||
},
|
},
|
||||||
navigate: function(e) {
|
navigate: function(e) {
|
||||||
@ -12806,11 +12838,10 @@
|
|||||||
}
|
}
|
||||||
if (view === g.VIEW) {
|
if (view === g.VIEW) {
|
||||||
if (view === 'index') {
|
if (view === 'index') {
|
||||||
if (boardID === g.BOARD.ID) {
|
if (boardID !== g.BOARD.ID) {
|
||||||
return Index.update();
|
Main.clean();
|
||||||
|
Main.updateBoard(boardID);
|
||||||
}
|
}
|
||||||
Main.clean();
|
|
||||||
Main.updateBoard(boardID);
|
|
||||||
return Index.update();
|
return Index.update();
|
||||||
} else {
|
} else {
|
||||||
return Main.refresh({
|
return Main.refresh({
|
||||||
@ -12820,7 +12851,21 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Main.disconnect();
|
g.VIEW = view;
|
||||||
|
if (view === 'index') {
|
||||||
|
Main.disconnect();
|
||||||
|
Main.clean();
|
||||||
|
if (boardID !== g.BOARD.ID) {
|
||||||
|
Main.updateBoard();
|
||||||
|
}
|
||||||
|
return Index.connect.call(Index);
|
||||||
|
} else {
|
||||||
|
return Main.refresh({
|
||||||
|
boardID: boardID,
|
||||||
|
view: view,
|
||||||
|
threadID: threadID
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateBoard: function(boardID) {
|
updateBoard: function(boardID) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript
|
// Generated by CoffeeScript
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.2.45 - 2014-01-07
|
* 4chan X - Version 1.2.45 - 2014-01-08
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
@ -2156,7 +2156,7 @@
|
|||||||
Index = {
|
Index = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var anchorEntry, input, label, modeEntry, name, refNavEntry, repliesEntry, sortEntry, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
var anchorEntry, input, label, modeEntry, name, refNavEntry, repliesEntry, sortEntry, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||||
if (g.VIEW !== 'index' || g.BOARD.ID === 'f') {
|
if (g.BOARD.ID === 'f') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.button = $.el('a', {
|
this.button = $.el('a', {
|
||||||
@ -2267,6 +2267,12 @@
|
|||||||
order: 90,
|
order: 90,
|
||||||
subEntries: [repliesEntry, anchorEntry, refNavEntry, modeEntry, sortEntry]
|
subEntries: [repliesEntry, anchorEntry, refNavEntry, modeEntry, sortEntry]
|
||||||
});
|
});
|
||||||
|
if (g.VIEW !== 'index') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.connect.call(this);
|
||||||
|
},
|
||||||
|
connect: function() {
|
||||||
$.addClass(doc, 'index-loading');
|
$.addClass(doc, 'index-loading');
|
||||||
this.update();
|
this.update();
|
||||||
this.root = $.el('div', {
|
this.root = $.el('div', {
|
||||||
@ -2290,13 +2296,13 @@
|
|||||||
return $.asap((function() {
|
return $.asap((function() {
|
||||||
return $('.board', doc) || d.readyState !== 'loading';
|
return $('.board', doc) || d.readyState !== 'loading';
|
||||||
}), function() {
|
}), function() {
|
||||||
var board, navLink, _l, _len3, _ref3;
|
var board, navLink, _i, _len, _ref;
|
||||||
board = $('.board');
|
board = $('.board');
|
||||||
$.replace(board, Index.root);
|
$.replace(board, Index.root);
|
||||||
d.implementation.createDocument(null, null, null).appendChild(board);
|
d.implementation.createDocument(null, null, null).appendChild(board);
|
||||||
_ref3 = $$('.navLinks');
|
_ref = $$('.navLinks');
|
||||||
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
navLink = _ref3[_l];
|
navLink = _ref[_i];
|
||||||
$.rm(navLink);
|
$.rm(navLink);
|
||||||
}
|
}
|
||||||
$.after($.x('child::form/preceding-sibling::hr[1]'), Index.navLinks);
|
$.after($.x('child::form/preceding-sibling::hr[1]'), Index.navLinks);
|
||||||
@ -2304,7 +2310,12 @@
|
|||||||
return $.asap((function() {
|
return $.asap((function() {
|
||||||
return $('.pagelist') || d.readyState !== 'loading';
|
return $('.pagelist') || d.readyState !== 'loading';
|
||||||
}), function() {
|
}), function() {
|
||||||
return $.replace($('.pagelist'), Index.pagelist);
|
var pagelist;
|
||||||
|
if (pagelist = $('.pagelist')) {
|
||||||
|
return $.replace(pagelist, Index.pagelist);
|
||||||
|
} else {
|
||||||
|
return $.after($.id('delform'), Index.pagelist);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -2454,19 +2465,14 @@
|
|||||||
if ((_ref1 = Index.notice) != null) {
|
if ((_ref1 = Index.notice) != null) {
|
||||||
_ref1.close();
|
_ref1.close();
|
||||||
}
|
}
|
||||||
if (d.readyState !== 'loading') {
|
now = Date.now();
|
||||||
Index.notice = new Notice('info', 'Refreshing index...');
|
$.ready(function() {
|
||||||
} else {
|
return setTimeout((function() {
|
||||||
now = Date.now();
|
if (Index.req && !Index.notice) {
|
||||||
$.ready(function() {
|
|
||||||
return setTimeout((function() {
|
|
||||||
if (!(Index.req && !Index.notice)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return Index.notice = new Notice('info', 'Refreshing index...');
|
return Index.notice = new Notice('info', 'Refreshing index...');
|
||||||
}), 5 * $.SECOND - (Date.now() - now));
|
}
|
||||||
});
|
}), 5 * $.SECOND - (Date.now() - now));
|
||||||
}
|
});
|
||||||
if (typeof pageNum !== 'number') {
|
if (typeof pageNum !== 'number') {
|
||||||
pageNum = null;
|
pageNum = null;
|
||||||
}
|
}
|
||||||
@ -5026,7 +5032,7 @@
|
|||||||
});
|
});
|
||||||
input = $('input', this.controls);
|
input = $('input', this.controls);
|
||||||
$.on(input, 'change', this.toggle);
|
$.on(input, 'change', this.toggle);
|
||||||
$.event('AddMenuEntry', {
|
$.event('AddMenuEntry', this.entry = {
|
||||||
type: 'header',
|
type: 'header',
|
||||||
el: this.controls,
|
el: this.controls,
|
||||||
order: 98
|
order: 98
|
||||||
@ -5039,6 +5045,16 @@
|
|||||||
cb: this.node
|
cb: this.node
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
disconnect: function() {
|
||||||
|
var input;
|
||||||
|
input = $('input', this.controls);
|
||||||
|
$.off(input, 'change', this.toggle);
|
||||||
|
$.event('rmMenuEntry', this.entry);
|
||||||
|
delete this.enabled;
|
||||||
|
delete this.controls;
|
||||||
|
delete this.entry;
|
||||||
|
return Post.callbacks.rm('Quote Threading');
|
||||||
|
},
|
||||||
setup: function() {
|
setup: function() {
|
||||||
$.off(d, '4chanXInitFinished', QuoteThreading.setup);
|
$.off(d, '4chanXInitFinished', QuoteThreading.setup);
|
||||||
return QuoteThreading.force();
|
return QuoteThreading.force();
|
||||||
@ -12751,16 +12767,32 @@
|
|||||||
return _results;
|
return _results;
|
||||||
},
|
},
|
||||||
disconnect: function() {
|
disconnect: function() {
|
||||||
var feature, name, _ref;
|
var err, errors, feature, features, name;
|
||||||
_ref = Main.features;
|
if (g.VIEW === 'thread') {
|
||||||
for (name in _ref) {
|
features = {
|
||||||
feature = _ref[name];
|
'Thread Updater': ThreadUpdater,
|
||||||
if (feature.disconnect) {
|
'Unread Count': Unread,
|
||||||
feature.disconnect();
|
'Quote Threading': QuoteThreading
|
||||||
|
};
|
||||||
|
}
|
||||||
|
for (name in features) {
|
||||||
|
feature = features[name];
|
||||||
|
try {
|
||||||
|
feature.disconnect.call(feature);
|
||||||
|
} catch (_error) {
|
||||||
|
err = _error;
|
||||||
|
if (!errors) {
|
||||||
|
errors = [];
|
||||||
|
}
|
||||||
|
errors.push({
|
||||||
|
message: "Failed to disconnect feature " + name + ".",
|
||||||
|
error: err
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (errors) {
|
||||||
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Post.callbacks.clear();
|
|
||||||
Thread.callbacks.clear();
|
|
||||||
return $.rmAll($('.board'));
|
return $.rmAll($('.board'));
|
||||||
},
|
},
|
||||||
navigate: function(e) {
|
navigate: function(e) {
|
||||||
@ -12780,11 +12812,10 @@
|
|||||||
}
|
}
|
||||||
if (view === g.VIEW) {
|
if (view === g.VIEW) {
|
||||||
if (view === 'index') {
|
if (view === 'index') {
|
||||||
if (boardID === g.BOARD.ID) {
|
if (boardID !== g.BOARD.ID) {
|
||||||
return Index.update();
|
Main.clean();
|
||||||
|
Main.updateBoard(boardID);
|
||||||
}
|
}
|
||||||
Main.clean();
|
|
||||||
Main.updateBoard(boardID);
|
|
||||||
return Index.update();
|
return Index.update();
|
||||||
} else {
|
} else {
|
||||||
return Main.refresh({
|
return Main.refresh({
|
||||||
@ -12794,7 +12825,21 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Main.disconnect();
|
g.VIEW = view;
|
||||||
|
if (view === 'index') {
|
||||||
|
Main.disconnect();
|
||||||
|
Main.clean();
|
||||||
|
if (boardID !== g.BOARD.ID) {
|
||||||
|
Main.updateBoard();
|
||||||
|
}
|
||||||
|
return Index.connect.call(Index);
|
||||||
|
} else {
|
||||||
|
return Main.refresh({
|
||||||
|
boardID: boardID,
|
||||||
|
view: view,
|
||||||
|
threadID: threadID
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateBoard: function(boardID) {
|
updateBoard: function(boardID) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
Index =
|
Index =
|
||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW isnt 'index' or g.BOARD.ID is 'f'
|
return if g.BOARD.ID is 'f'
|
||||||
|
|
||||||
@button = $.el 'a',
|
@button = $.el 'a',
|
||||||
className: 'index-refresh-shortcut fa fa-refresh'
|
className: 'index-refresh-shortcut fa fa-refresh'
|
||||||
@ -66,6 +66,11 @@ Index =
|
|||||||
order: 90
|
order: 90
|
||||||
subEntries: [repliesEntry, anchorEntry, refNavEntry, modeEntry, sortEntry]
|
subEntries: [repliesEntry, anchorEntry, refNavEntry, modeEntry, sortEntry]
|
||||||
|
|
||||||
|
return if g.VIEW isnt 'index'
|
||||||
|
|
||||||
|
@connect.call @
|
||||||
|
|
||||||
|
connect: ->
|
||||||
$.addClass doc, 'index-loading'
|
$.addClass doc, 'index-loading'
|
||||||
@update()
|
@update()
|
||||||
@root = $.el 'div', className: 'board'
|
@root = $.el 'div', className: 'board'
|
||||||
@ -99,7 +104,10 @@ Index =
|
|||||||
$.after $.x('child::form/preceding-sibling::hr[1]'), Index.navLinks
|
$.after $.x('child::form/preceding-sibling::hr[1]'), Index.navLinks
|
||||||
$.rmClass doc, 'index-loading'
|
$.rmClass doc, 'index-loading'
|
||||||
$.asap (-> $('.pagelist') or d.readyState isnt 'loading'), ->
|
$.asap (-> $('.pagelist') or d.readyState isnt 'loading'), ->
|
||||||
$.replace $('.pagelist'), Index.pagelist
|
if pagelist = $('.pagelist')
|
||||||
|
$.replace pagelist, Index.pagelist
|
||||||
|
else
|
||||||
|
$.after $.id('delform'), Index.pagelist
|
||||||
|
|
||||||
cb:
|
cb:
|
||||||
mode: ->
|
mode: ->
|
||||||
@ -202,17 +210,16 @@ Index =
|
|||||||
return unless navigator.onLine
|
return unless navigator.onLine
|
||||||
Index.req?.abort()
|
Index.req?.abort()
|
||||||
Index.notice?.close()
|
Index.notice?.close()
|
||||||
if d.readyState isnt 'loading'
|
|
||||||
Index.notice = new Notice 'info', 'Refreshing index...'
|
# Delay the notice on initial page load
|
||||||
else
|
# and only display it for slow connections.
|
||||||
# Delay the notice on initial page load
|
now = Date.now()
|
||||||
# and only display it for slow connections.
|
$.ready ->
|
||||||
now = Date.now()
|
setTimeout (->
|
||||||
$.ready ->
|
if Index.req and !Index.notice
|
||||||
setTimeout (->
|
|
||||||
return unless Index.req and !Index.notice
|
|
||||||
Index.notice = new Notice 'info', 'Refreshing index...'
|
Index.notice = new Notice 'info', 'Refreshing index...'
|
||||||
), 5 * $.SECOND - (Date.now() - now)
|
), 5 * $.SECOND - (Date.now() - now)
|
||||||
|
|
||||||
pageNum = null if typeof pageNum isnt 'number' # event
|
pageNum = null if typeof pageNum isnt 'number' # event
|
||||||
onload = (e) -> Index.load e, pageNum
|
onload = (e) -> Index.load e, pageNum
|
||||||
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD}/catalog.json",
|
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD}/catalog.json",
|
||||||
|
|||||||
@ -322,12 +322,26 @@ Main =
|
|||||||
delete threads[id] for id of threads when threads.hasOwnProperty id
|
delete threads[id] for id of threads when threads.hasOwnProperty id
|
||||||
|
|
||||||
disconnect: ->
|
disconnect: ->
|
||||||
# Disconnect active features that _can_ be disconnected
|
if g.VIEW is 'thread'
|
||||||
feature.disconnect() for name, feature of Main.features when feature.disconnect
|
features =
|
||||||
|
'Thread Updater': ThreadUpdater
|
||||||
|
'Unread Count': Unread
|
||||||
|
'Quote Threading': QuoteThreading
|
||||||
|
|
||||||
|
for name, feature of features
|
||||||
|
try
|
||||||
|
feature.disconnect.call feature
|
||||||
|
catch err
|
||||||
|
errors = [] unless errors
|
||||||
|
errors.push
|
||||||
|
message: "Failed to disconnect feature #{name}."
|
||||||
|
error: err
|
||||||
|
|
||||||
|
Main.handleErrors errors if errors
|
||||||
|
|
||||||
# Clean Post and Thread callbacks
|
# Clean Post and Thread callbacks
|
||||||
Post.callbacks.clear()
|
# Post.callbacks.clear()
|
||||||
Thread.callbacks.clear()
|
# Thread.callbacks.clear()
|
||||||
|
|
||||||
# Clean the board, as we'll be dumping shit here
|
# Clean the board, as we'll be dumping shit here
|
||||||
$.rmAll $ '.board'
|
$.rmAll $ '.board'
|
||||||
@ -348,17 +362,25 @@ Main =
|
|||||||
# Moving from thread to thread or index to index.
|
# Moving from thread to thread or index to index.
|
||||||
if view is g.VIEW
|
if view is g.VIEW
|
||||||
if view is 'index'
|
if view is 'index'
|
||||||
if boardID is g.BOARD.ID
|
unless boardID is g.BOARD.ID
|
||||||
return Index.update()
|
Main.clean()
|
||||||
Main.clean()
|
Main.updateBoard boardID
|
||||||
Main.updateBoard boardID
|
|
||||||
Index.update()
|
Index.update()
|
||||||
|
|
||||||
else
|
else
|
||||||
Main.refresh {boardID, view, threadID}
|
Main.refresh {boardID, view, threadID}
|
||||||
|
|
||||||
else
|
else
|
||||||
Main.disconnect()
|
g.VIEW = view
|
||||||
|
if view is 'index'
|
||||||
|
Main.disconnect()
|
||||||
|
Main.clean()
|
||||||
|
Main.updateBoard() unless boardID is g.BOARD.ID
|
||||||
|
Index.connect.call Index
|
||||||
|
|
||||||
|
else
|
||||||
|
Main.refresh {boardID, view, threadID}
|
||||||
|
|
||||||
updateBoard: (boardID) ->
|
updateBoard: (boardID) ->
|
||||||
g.BOARD = new Board boardID
|
g.BOARD = new Board boardID
|
||||||
|
|||||||
@ -13,7 +13,7 @@ QuoteThreading =
|
|||||||
input = $ 'input', @controls
|
input = $ 'input', @controls
|
||||||
$.on input, 'change', @toggle
|
$.on input, 'change', @toggle
|
||||||
|
|
||||||
$.event 'AddMenuEntry',
|
$.event 'AddMenuEntry', @entry =
|
||||||
type: 'header'
|
type: 'header'
|
||||||
el: @controls
|
el: @controls
|
||||||
order: 98
|
order: 98
|
||||||
@ -24,6 +24,18 @@ QuoteThreading =
|
|||||||
name: 'Quote Threading'
|
name: 'Quote Threading'
|
||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
|
disconnect: ->
|
||||||
|
input = $ 'input', @controls
|
||||||
|
$.off input, 'change', @toggle
|
||||||
|
|
||||||
|
$.event 'rmMenuEntry', @entry
|
||||||
|
|
||||||
|
delete @enabled
|
||||||
|
delete @controls
|
||||||
|
delete @entry
|
||||||
|
|
||||||
|
Post.callbacks.rm 'Quote Threading'
|
||||||
|
|
||||||
setup: ->
|
setup: ->
|
||||||
$.off d, '4chanXInitFinished', QuoteThreading.setup
|
$.off d, '4chanXInitFinished', QuoteThreading.setup
|
||||||
QuoteThreading.force()
|
QuoteThreading.force()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user