Well, fuck. Looks like we're generating board indexes now. :D
This commit is contained in:
parent
27f642c3b8
commit
21056d72f9
@ -1775,9 +1775,9 @@
|
|||||||
$.ready(function() {
|
$.ready(function() {
|
||||||
var a, cs, footer;
|
var a, cs, footer;
|
||||||
_this.footer = footer = $.id('boardNavDesktopFoot');
|
_this.footer = footer = $.id('boardNavDesktopFoot');
|
||||||
|
$.on(a, 'click', Main.navigate);
|
||||||
if (a = $("a[href*='/" + g.BOARD + "/']", footer)) {
|
if (a = $("a[href*='/" + g.BOARD + "/']", footer)) {
|
||||||
a.className = 'current';
|
a.className = 'current';
|
||||||
$.on(a, 'click', Index.cb.link);
|
|
||||||
}
|
}
|
||||||
cs = $.el('a', {
|
cs = $.el('a', {
|
||||||
id: 'settingsWindowLink',
|
id: 'settingsWindowLink',
|
||||||
@ -1808,15 +1808,19 @@
|
|||||||
id: 'scroll-marker'
|
id: 'scroll-marker'
|
||||||
}),
|
}),
|
||||||
setBoardList: function() {
|
setBoardList: function() {
|
||||||
var a, boardList, btn, fourchannav, fullBoardList;
|
var a, boardList, btn, fourchannav, fullBoardList, _i, _len, _ref;
|
||||||
fourchannav = $.id('boardNavDesktop');
|
fourchannav = $.id('boardNavDesktop');
|
||||||
boardList = $.el('span', {
|
boardList = $.el('span', {
|
||||||
id: 'board-list',
|
id: 'board-list',
|
||||||
innerHTML: "<span id=custom-board-list></span><span id=full-board-list hidden><span class='hide-board-list-container brackets-wrap'><a href=javascript:; class='hide-board-list-button'> - </a></span> " + fourchannav.innerHTML + "</span>"
|
innerHTML: "<span id=custom-board-list></span><span id=full-board-list hidden><span class='hide-board-list-container brackets-wrap'><a href=javascript:; class='hide-board-list-button'> - </a></span> " + fourchannav.innerHTML + "</span>"
|
||||||
});
|
});
|
||||||
if (a = $("a[href*='/" + g.BOARD + "/']", boardList)) {
|
_ref = $$('a', boardList);
|
||||||
a.className = 'current';
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
$.on(a, 'click', Index.cb.link);
|
a = _ref[_i];
|
||||||
|
$.on(a, 'click', Main.navigate);
|
||||||
|
if (a.pathname.split('/')[0] === g.BOARD.ID) {
|
||||||
|
a.className = 'current';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fullBoardList = $('#full-board-list', boardList);
|
fullBoardList = $('#full-board-list', boardList);
|
||||||
btn = $('.hide-board-list-button', fullBoardList);
|
btn = $('.hide-board-list-button', fullBoardList);
|
||||||
@ -1838,7 +1842,7 @@
|
|||||||
}
|
}
|
||||||
as = $$('#full-board-list a[title]', Header.bar);
|
as = $$('#full-board-list a[title]', Header.bar);
|
||||||
nodes = text.match(/[\w@]+((-(all|title|replace|full|index|catalog|url:"[^"]+[^"]"|text:"[^"]+")|\,"[^"]+[^"]"))*|[^\w@]+/g).map(function(t) {
|
nodes = text.match(/[\w@]+((-(all|title|replace|full|index|catalog|url:"[^"]+[^"]"|text:"[^"]+")|\,"[^"]+[^"]"))*|[^\w@]+/g).map(function(t) {
|
||||||
var a, board, current, m, _i, _len;
|
var a, board, m, _i, _len;
|
||||||
if (/^[^\w@]/.test(t)) {
|
if (/^[^\w@]/.test(t)) {
|
||||||
return $.tn(t);
|
return $.tn(t);
|
||||||
}
|
}
|
||||||
@ -1864,11 +1868,8 @@
|
|||||||
a = as[_i];
|
a = as[_i];
|
||||||
if (a.textContent === board) {
|
if (a.textContent === board) {
|
||||||
a = a.cloneNode(true);
|
a = a.cloneNode(true);
|
||||||
current = $.hasClass(a, 'current');
|
$.on(a, 'click', Main.navigate);
|
||||||
if (current) {
|
a.textContent = /-title/.test(t) || /-replace/.test(t) && $.hasClass(a, 'current') ? a.title : /-full/.test(t) ? "/" + board + "/ - " + a.title : (m = t.match(/-text:"(.+)"/)) ? m[1] : a.textContent;
|
||||||
$.on(a, 'click', Index.cb.link);
|
|
||||||
}
|
|
||||||
a.textContent = /-title/.test(t) || /-replace/.test(t) && current ? a.title : /-full/.test(t) ? "/" + board + "/ - " + a.title : (m = t.match(/-text:"(.+)"/)) ? m[1] : a.textContent;
|
|
||||||
if (m = t.match(/-(index|catalog)/)) {
|
if (m = t.match(/-(index|catalog)/)) {
|
||||||
a.dataset.only = m[1];
|
a.dataset.only = m[1];
|
||||||
a.href = "//boards.4chan.org/" + board + "/";
|
a.href = "//boards.4chan.org/" + board + "/";
|
||||||
@ -12752,13 +12753,18 @@
|
|||||||
'Banner': Banner
|
'Banner': Banner
|
||||||
},
|
},
|
||||||
clean: function() {
|
clean: function() {
|
||||||
var id, _results;
|
var id, posts, threads, _results;
|
||||||
for (id in g.posts) {
|
posts = g.posts, threads = g.threads;
|
||||||
delete g.posts[id];
|
for (id in posts) {
|
||||||
|
if (posts.hasOwnProperty(id)) {
|
||||||
|
delete posts[id];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_results = [];
|
_results = [];
|
||||||
for (id in g.threads) {
|
for (id in threads) {
|
||||||
_results.push(delete g.threads[id]);
|
if (threads.hasOwnProperty(id)) {
|
||||||
|
_results.push(delete threads[id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
},
|
},
|
||||||
@ -12775,15 +12781,82 @@
|
|||||||
Thread.callbacks.clear();
|
Thread.callbacks.clear();
|
||||||
return $.rmAll($('.board'));
|
return $.rmAll($('.board'));
|
||||||
},
|
},
|
||||||
navigate: function(context) {
|
navigate: function(e) {
|
||||||
var boardID, threadID, view;
|
var boardID, threadID, view, _, _ref;
|
||||||
boardID = context.boardID, view = context.view, threadID = context.threadID;
|
if (this.hostname !== 'boards.4chan.org') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_ref = this.pathname.split('/'), _ = _ref[0], boardID = _ref[1], view = _ref[2], threadID = _ref[3];
|
||||||
|
if (view === 'catalog') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
if (threadID) {
|
||||||
|
view = 'thread';
|
||||||
|
} else {
|
||||||
|
view = view || 'index';
|
||||||
|
}
|
||||||
|
Main.clean();
|
||||||
if (view === g.VIEW) {
|
if (view === g.VIEW) {
|
||||||
return Main.refresh(context);
|
if (view === 'index') {
|
||||||
|
if (boardID === g.BOARD.ID) {
|
||||||
|
return Index.update();
|
||||||
|
}
|
||||||
|
Main.clean();
|
||||||
|
Main.updateBoard(boardID);
|
||||||
|
return Index.update();
|
||||||
|
} else {
|
||||||
|
return Main.refresh(context);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return Main.disconnect();
|
return Main.disconnect();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
updateBoard: function(boardID) {
|
||||||
|
var onload, req;
|
||||||
|
g.BOARD = new Board(boardID);
|
||||||
|
req = null;
|
||||||
|
onload = function(e) {
|
||||||
|
var board, err, o, _i, _len, _ref;
|
||||||
|
if (e.type === 'abort') {
|
||||||
|
req.onloadend = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (req.status !== 200) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
o = JSON.parse(req.response);
|
||||||
|
_ref = o.boards;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
board = _ref[_i];
|
||||||
|
if (board.board === boardID) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Main.updateTitle(board);
|
||||||
|
} catch (_error) {
|
||||||
|
err = _error;
|
||||||
|
return Main.handleErrors([
|
||||||
|
{
|
||||||
|
message: "Index Failure.",
|
||||||
|
error: err
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return req = $.ajax('//a.4cdn.org/boards.json', {
|
||||||
|
onabort: onload,
|
||||||
|
onloadend: onload
|
||||||
|
});
|
||||||
|
},
|
||||||
|
updateTitle: function(board) {
|
||||||
|
var subtitle;
|
||||||
|
if (subtitle = $('.boardSubtitle')) {
|
||||||
|
$.rm(subtitle);
|
||||||
|
}
|
||||||
|
return $('.boardTitle').innerHTML = "/" + board.board + "/ - " + board.title;
|
||||||
|
},
|
||||||
refresh: function(context) {
|
refresh: function(context) {
|
||||||
var boardID, name, threadID, view, _results, _results1;
|
var boardID, name, threadID, view, _results, _results1;
|
||||||
boardID = context.boardID, view = context.view, threadID = context.threadID;
|
boardID = context.boardID, view = context.view, threadID = context.threadID;
|
||||||
|
|||||||
@ -1785,9 +1785,9 @@
|
|||||||
$.ready(function() {
|
$.ready(function() {
|
||||||
var a, cs, footer;
|
var a, cs, footer;
|
||||||
_this.footer = footer = $.id('boardNavDesktopFoot');
|
_this.footer = footer = $.id('boardNavDesktopFoot');
|
||||||
|
$.on(a, 'click', Main.navigate);
|
||||||
if (a = $("a[href*='/" + g.BOARD + "/']", footer)) {
|
if (a = $("a[href*='/" + g.BOARD + "/']", footer)) {
|
||||||
a.className = 'current';
|
a.className = 'current';
|
||||||
$.on(a, 'click', Index.cb.link);
|
|
||||||
}
|
}
|
||||||
cs = $.el('a', {
|
cs = $.el('a', {
|
||||||
id: 'settingsWindowLink',
|
id: 'settingsWindowLink',
|
||||||
@ -1818,15 +1818,19 @@
|
|||||||
id: 'scroll-marker'
|
id: 'scroll-marker'
|
||||||
}),
|
}),
|
||||||
setBoardList: function() {
|
setBoardList: function() {
|
||||||
var a, boardList, btn, fourchannav, fullBoardList;
|
var a, boardList, btn, fourchannav, fullBoardList, _i, _len, _ref;
|
||||||
fourchannav = $.id('boardNavDesktop');
|
fourchannav = $.id('boardNavDesktop');
|
||||||
boardList = $.el('span', {
|
boardList = $.el('span', {
|
||||||
id: 'board-list',
|
id: 'board-list',
|
||||||
innerHTML: "<span id=custom-board-list></span><span id=full-board-list hidden><span class='hide-board-list-container brackets-wrap'><a href=javascript:; class='hide-board-list-button'> - </a></span> " + fourchannav.innerHTML + "</span>"
|
innerHTML: "<span id=custom-board-list></span><span id=full-board-list hidden><span class='hide-board-list-container brackets-wrap'><a href=javascript:; class='hide-board-list-button'> - </a></span> " + fourchannav.innerHTML + "</span>"
|
||||||
});
|
});
|
||||||
if (a = $("a[href*='/" + g.BOARD + "/']", boardList)) {
|
_ref = $$('a', boardList);
|
||||||
a.className = 'current';
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
$.on(a, 'click', Index.cb.link);
|
a = _ref[_i];
|
||||||
|
$.on(a, 'click', Main.navigate);
|
||||||
|
if (a.pathname.split('/')[0] === g.BOARD.ID) {
|
||||||
|
a.className = 'current';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fullBoardList = $('#full-board-list', boardList);
|
fullBoardList = $('#full-board-list', boardList);
|
||||||
btn = $('.hide-board-list-button', fullBoardList);
|
btn = $('.hide-board-list-button', fullBoardList);
|
||||||
@ -1848,7 +1852,7 @@
|
|||||||
}
|
}
|
||||||
as = $$('#full-board-list a[title]', Header.bar);
|
as = $$('#full-board-list a[title]', Header.bar);
|
||||||
nodes = text.match(/[\w@]+((-(all|title|replace|full|index|catalog|url:"[^"]+[^"]"|text:"[^"]+")|\,"[^"]+[^"]"))*|[^\w@]+/g).map(function(t) {
|
nodes = text.match(/[\w@]+((-(all|title|replace|full|index|catalog|url:"[^"]+[^"]"|text:"[^"]+")|\,"[^"]+[^"]"))*|[^\w@]+/g).map(function(t) {
|
||||||
var a, board, current, m, _i, _len;
|
var a, board, m, _i, _len;
|
||||||
if (/^[^\w@]/.test(t)) {
|
if (/^[^\w@]/.test(t)) {
|
||||||
return $.tn(t);
|
return $.tn(t);
|
||||||
}
|
}
|
||||||
@ -1874,11 +1878,8 @@
|
|||||||
a = as[_i];
|
a = as[_i];
|
||||||
if (a.textContent === board) {
|
if (a.textContent === board) {
|
||||||
a = a.cloneNode(true);
|
a = a.cloneNode(true);
|
||||||
current = $.hasClass(a, 'current');
|
$.on(a, 'click', Main.navigate);
|
||||||
if (current) {
|
a.textContent = /-title/.test(t) || /-replace/.test(t) && $.hasClass(a, 'current') ? a.title : /-full/.test(t) ? "/" + board + "/ - " + a.title : (m = t.match(/-text:"(.+)"/)) ? m[1] : a.textContent;
|
||||||
$.on(a, 'click', Index.cb.link);
|
|
||||||
}
|
|
||||||
a.textContent = /-title/.test(t) || /-replace/.test(t) && current ? a.title : /-full/.test(t) ? "/" + board + "/ - " + a.title : (m = t.match(/-text:"(.+)"/)) ? m[1] : a.textContent;
|
|
||||||
if (m = t.match(/-(index|catalog)/)) {
|
if (m = t.match(/-(index|catalog)/)) {
|
||||||
a.dataset.only = m[1];
|
a.dataset.only = m[1];
|
||||||
a.href = "//boards.4chan.org/" + board + "/";
|
a.href = "//boards.4chan.org/" + board + "/";
|
||||||
@ -12726,13 +12727,18 @@
|
|||||||
'Banner': Banner
|
'Banner': Banner
|
||||||
},
|
},
|
||||||
clean: function() {
|
clean: function() {
|
||||||
var id, _results;
|
var id, posts, threads, _results;
|
||||||
for (id in g.posts) {
|
posts = g.posts, threads = g.threads;
|
||||||
delete g.posts[id];
|
for (id in posts) {
|
||||||
|
if (posts.hasOwnProperty(id)) {
|
||||||
|
delete posts[id];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_results = [];
|
_results = [];
|
||||||
for (id in g.threads) {
|
for (id in threads) {
|
||||||
_results.push(delete g.threads[id]);
|
if (threads.hasOwnProperty(id)) {
|
||||||
|
_results.push(delete threads[id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
},
|
},
|
||||||
@ -12749,15 +12755,82 @@
|
|||||||
Thread.callbacks.clear();
|
Thread.callbacks.clear();
|
||||||
return $.rmAll($('.board'));
|
return $.rmAll($('.board'));
|
||||||
},
|
},
|
||||||
navigate: function(context) {
|
navigate: function(e) {
|
||||||
var boardID, threadID, view;
|
var boardID, threadID, view, _, _ref;
|
||||||
boardID = context.boardID, view = context.view, threadID = context.threadID;
|
if (this.hostname !== 'boards.4chan.org') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_ref = this.pathname.split('/'), _ = _ref[0], boardID = _ref[1], view = _ref[2], threadID = _ref[3];
|
||||||
|
if (view === 'catalog') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
if (threadID) {
|
||||||
|
view = 'thread';
|
||||||
|
} else {
|
||||||
|
view = view || 'index';
|
||||||
|
}
|
||||||
|
Main.clean();
|
||||||
if (view === g.VIEW) {
|
if (view === g.VIEW) {
|
||||||
return Main.refresh(context);
|
if (view === 'index') {
|
||||||
|
if (boardID === g.BOARD.ID) {
|
||||||
|
return Index.update();
|
||||||
|
}
|
||||||
|
Main.clean();
|
||||||
|
Main.updateBoard(boardID);
|
||||||
|
return Index.update();
|
||||||
|
} else {
|
||||||
|
return Main.refresh(context);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return Main.disconnect();
|
return Main.disconnect();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
updateBoard: function(boardID) {
|
||||||
|
var onload, req;
|
||||||
|
g.BOARD = new Board(boardID);
|
||||||
|
req = null;
|
||||||
|
onload = function(e) {
|
||||||
|
var board, err, o, _i, _len, _ref;
|
||||||
|
if (e.type === 'abort') {
|
||||||
|
req.onloadend = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (req.status !== 200) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
o = JSON.parse(req.response);
|
||||||
|
_ref = o.boards;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
board = _ref[_i];
|
||||||
|
if (board.board === boardID) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Main.updateTitle(board);
|
||||||
|
} catch (_error) {
|
||||||
|
err = _error;
|
||||||
|
return Main.handleErrors([
|
||||||
|
{
|
||||||
|
message: "Index Failure.",
|
||||||
|
error: err
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return req = $.ajax('//a.4cdn.org/boards.json', {
|
||||||
|
onabort: onload,
|
||||||
|
onloadend: onload
|
||||||
|
});
|
||||||
|
},
|
||||||
|
updateTitle: function(board) {
|
||||||
|
var subtitle;
|
||||||
|
if (subtitle = $('.boardSubtitle')) {
|
||||||
|
$.rm(subtitle);
|
||||||
|
}
|
||||||
|
return $('.boardTitle').innerHTML = "/" + board.board + "/ - " + board.title;
|
||||||
|
},
|
||||||
refresh: function(context) {
|
refresh: function(context) {
|
||||||
var boardID, name, threadID, view, _results, _results1;
|
var boardID, name, threadID, view, _results, _results1;
|
||||||
boardID = context.boardID, view = context.view, threadID = context.threadID;
|
boardID = context.boardID, view = context.view, threadID = context.threadID;
|
||||||
|
|||||||
@ -102,9 +102,9 @@ Header =
|
|||||||
|
|
||||||
$.ready =>
|
$.ready =>
|
||||||
@footer = footer = $.id 'boardNavDesktopFoot'
|
@footer = footer = $.id 'boardNavDesktopFoot'
|
||||||
|
$.on a, 'click', Main.navigate
|
||||||
if a = $ "a[href*='/#{g.BOARD}/']", footer
|
if a = $ "a[href*='/#{g.BOARD}/']", footer
|
||||||
a.className = 'current'
|
a.className = 'current'
|
||||||
$.on a, 'click', Index.cb.link
|
|
||||||
|
|
||||||
cs = $.el 'a',
|
cs = $.el 'a',
|
||||||
id: 'settingsWindowLink'
|
id: 'settingsWindowLink'
|
||||||
@ -138,9 +138,10 @@ Header =
|
|||||||
boardList = $.el 'span',
|
boardList = $.el 'span',
|
||||||
id: 'board-list'
|
id: 'board-list'
|
||||||
innerHTML: "<span id=custom-board-list></span><span id=full-board-list hidden><span class='hide-board-list-container brackets-wrap'><a href=javascript:; class='hide-board-list-button'> - </a></span> #{fourchannav.innerHTML}</span>"
|
innerHTML: "<span id=custom-board-list></span><span id=full-board-list hidden><span class='hide-board-list-container brackets-wrap'><a href=javascript:; class='hide-board-list-button'> - </a></span> #{fourchannav.innerHTML}</span>"
|
||||||
if a = $ "a[href*='/#{g.BOARD}/']", boardList
|
for a in $$ 'a', boardList
|
||||||
a.className = 'current'
|
$.on a, 'click', Main.navigate
|
||||||
$.on a, 'click', Index.cb.link
|
if a.pathname.split('/')[0] is g.BOARD.ID
|
||||||
|
a.className = 'current'
|
||||||
fullBoardList = $ '#full-board-list', boardList
|
fullBoardList = $ '#full-board-list', boardList
|
||||||
btn = $ '.hide-board-list-button', fullBoardList
|
btn = $ '.hide-board-list-button', fullBoardList
|
||||||
$.on btn, 'click', Header.toggleBoardList
|
$.on btn, 'click', Header.toggleBoardList
|
||||||
@ -184,11 +185,9 @@ Header =
|
|||||||
if a.textContent is board
|
if a.textContent is board
|
||||||
a = a.cloneNode true
|
a = a.cloneNode true
|
||||||
|
|
||||||
current = $.hasClass a, 'current'
|
$.on a, 'click', Main.navigate
|
||||||
if current
|
|
||||||
$.on a, 'click', Index.cb.link
|
|
||||||
|
|
||||||
a.textContent = if /-title/.test(t) or /-replace/.test(t) and current
|
a.textContent = if /-title/.test(t) or /-replace/.test(t) and $.hasClass a, 'current'
|
||||||
a.title
|
a.title
|
||||||
else if /-full/.test t
|
else if /-full/.test t
|
||||||
"/#{board}/ - #{a.title}"
|
"/#{board}/ - #{a.title}"
|
||||||
@ -379,6 +378,7 @@ Header =
|
|||||||
return if (Get.postFromRoot post).isHidden
|
return if (Get.postFromRoot post).isHidden
|
||||||
|
|
||||||
Header.scrollTo post
|
Header.scrollTo post
|
||||||
|
|
||||||
scrollTo: (root, down, needed) ->
|
scrollTo: (root, down, needed) ->
|
||||||
if down
|
if down
|
||||||
x = Header.getBottomOf root
|
x = Header.getBottomOf root
|
||||||
@ -386,14 +386,17 @@ Header =
|
|||||||
else
|
else
|
||||||
x = Header.getTopOf root
|
x = Header.getTopOf root
|
||||||
window.scrollBy 0, x unless needed and x >= 0
|
window.scrollBy 0, x unless needed and x >= 0
|
||||||
|
|
||||||
scrollToIfNeeded: (root, down) ->
|
scrollToIfNeeded: (root, down) ->
|
||||||
Header.scrollTo root, down, true
|
Header.scrollTo root, down, true
|
||||||
|
|
||||||
getTopOf: (root) ->
|
getTopOf: (root) ->
|
||||||
{top} = root.getBoundingClientRect()
|
{top} = root.getBoundingClientRect()
|
||||||
if Conf['Fixed Header'] and not Conf['Bottom Header']
|
if Conf['Fixed Header'] and not Conf['Bottom Header']
|
||||||
headRect = Header.toggle.getBoundingClientRect()
|
headRect = Header.toggle.getBoundingClientRect()
|
||||||
top -= headRect.top + headRect.height
|
top -= headRect.top + headRect.height
|
||||||
top
|
top
|
||||||
|
|
||||||
getBottomOf: (root) ->
|
getBottomOf: (root) ->
|
||||||
{clientHeight} = doc
|
{clientHeight} = doc
|
||||||
bottom = clientHeight - root.getBoundingClientRect().bottom
|
bottom = clientHeight - root.getBoundingClientRect().bottom
|
||||||
|
|||||||
@ -320,8 +320,9 @@ Main =
|
|||||||
'Banner': Banner
|
'Banner': Banner
|
||||||
|
|
||||||
clean: ->
|
clean: ->
|
||||||
delete g.posts[id] for id of g.posts
|
{posts, threads} = g
|
||||||
delete g.threads[id] for id of g.threads
|
delete posts[id] for id of posts when posts.hasOwnProperty id
|
||||||
|
delete threads[id] for id of threads when threads.hasOwnProperty id
|
||||||
|
|
||||||
disconnect: ->
|
disconnect: ->
|
||||||
# Disconnect active features that _can_ be disconnected
|
# Disconnect active features that _can_ be disconnected
|
||||||
@ -334,17 +335,69 @@ Main =
|
|||||||
# Clean the board, as we'll be dumping shit here
|
# Clean the board, as we'll be dumping shit here
|
||||||
$.rmAll $ '.board'
|
$.rmAll $ '.board'
|
||||||
|
|
||||||
navigate: (context) ->
|
navigate: (e) ->
|
||||||
|
return unless @hostname is 'boards.4chan.org'
|
||||||
# Lets have a good idea of what we should we should be expecting for this kind of feature
|
# Lets have a good idea of what we should we should be expecting for this kind of feature
|
||||||
{boardID, view, threadID} = context
|
[_, boardID, view, threadID] = @pathname.split '/'
|
||||||
|
|
||||||
|
return if view is 'catalog'
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
if threadID
|
||||||
|
view = 'thread'
|
||||||
|
else
|
||||||
|
view = view or 'index'
|
||||||
|
Main.clean()
|
||||||
|
|
||||||
# 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
|
||||||
Main.refresh context
|
if view is 'index'
|
||||||
|
if boardID is g.BOARD.ID
|
||||||
|
return Index.update()
|
||||||
|
Main.clean()
|
||||||
|
Main.updateBoard boardID
|
||||||
|
Index.update()
|
||||||
|
|
||||||
|
else
|
||||||
|
Main.refresh context
|
||||||
|
|
||||||
else
|
else
|
||||||
Main.disconnect()
|
Main.disconnect()
|
||||||
|
|
||||||
|
updateBoard: (boardID) ->
|
||||||
|
g.BOARD = new Board boardID
|
||||||
|
|
||||||
|
req = null
|
||||||
|
|
||||||
|
onload = (e) ->
|
||||||
|
if e.type is 'abort'
|
||||||
|
req.onloadend = null
|
||||||
|
return
|
||||||
|
|
||||||
|
try
|
||||||
|
return unless req.status is 200
|
||||||
|
|
||||||
|
o = JSON.parse req.response
|
||||||
|
for board in o.boards
|
||||||
|
if board.board is boardID
|
||||||
|
break
|
||||||
|
|
||||||
|
Main.updateTitle board
|
||||||
|
|
||||||
|
catch err
|
||||||
|
Main.handleErrors [
|
||||||
|
message: "Index Failure."
|
||||||
|
error: err
|
||||||
|
]
|
||||||
|
|
||||||
|
req = $.ajax '//a.4cdn.org/boards.json',
|
||||||
|
onabort: onload
|
||||||
|
onloadend: onload
|
||||||
|
|
||||||
|
updateTitle: (board) ->
|
||||||
|
$.rm subtitle if subtitle = $ '.boardSubtitle'
|
||||||
|
$('.boardTitle').innerHTML = "/#{board.board}/ - #{board.title}"
|
||||||
|
|
||||||
refresh: (context) ->
|
refresh: (context) ->
|
||||||
{boardID, view, threadID} = context
|
{boardID, view, threadID} = context
|
||||||
|
|
||||||
@ -354,6 +407,5 @@ Main =
|
|||||||
else
|
else
|
||||||
# Refresh index features
|
# Refresh index features
|
||||||
Main.features[name].index() for name of Main.features
|
Main.features[name].index() for name of Main.features
|
||||||
|
|
||||||
|
|
||||||
Main.init()
|
Main.init()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user