This commit is contained in:
Zixaphir 2014-01-08 15:40:57 -07:00
parent 1c504e0676
commit 1e7fc8ea65
5 changed files with 81 additions and 114 deletions

View File

@ -2017,7 +2017,7 @@
$.addClass(doc, args[0]); $.addClass(doc, args[0]);
$.rmClass(doc, args[1]); $.rmClass(doc, args[1]);
Header.bar.parentNode.className = args[2]; Header.bar.parentNode.className = args[2];
return $[args[3]](Header.bar, Header.notify); return $[args[3]](Header.bar, Header.noticesRoot);
}, },
toggleBarPosition: function() { toggleBarPosition: function() {
$.cb.checked.call(this); $.cb.checked.call(this);
@ -2377,7 +2377,7 @@
return Header.scrollToIfNeeded(Index.root); return Header.scrollToIfNeeded(Index.root);
}, },
getCurrentPage: function() { getCurrentPage: function() {
return +window.location.pathname.split('/')[2] || 0; return +window.location.pathname.split('/')[2];
}, },
userPageNav: function(pageNum) { userPageNav: function(pageNum) {
if (Conf['Refreshed Navigation'] && Conf['Index Mode'] === 'paged') { if (Conf['Refreshed Navigation'] && Conf['Index Mode'] === 'paged') {
@ -2510,7 +2510,7 @@
} }
} catch (_error) { } catch (_error) {
err = _error; err = _error;
c.error('Index failure:', err.stack); c.error('Index failure:', err);
if (notice) { if (notice) {
notice.setType('error'); notice.setType('error');
notice.el.lastElementChild.textContent = 'Index refresh failed.'; notice.el.lastElementChild.textContent = 'Index refresh failed.';
@ -12791,35 +12791,26 @@
history.pushState(null, '', this.pathname); history.pushState(null, '', this.pathname);
} }
view = threadID ? 'thread' : view || 'index'; view = threadID ? 'thread' : view || 'index';
if (view === g.VIEW) { if (view !== g.VIEW) {
if (view === 'index') { Main.clean();
if (boardID !== g.BOARD.ID) { Main.disconnect(view);
Main.clean(); }
Main.updateBoard(boardID); if (view === 'index') {
} if (boardID !== g.BOARD.ID) {
Index.update(); Main.updateBoard(boardID);
} else {
Main.refresh({
boardID: boardID,
view: view,
threadID: threadID
});
} }
} else { if (Index.root) {
if (view === 'index') {
Main.disconnect(view);
Main.clean();
if (boardID !== g.BOARD.ID) {
Main.updateBoard(boardID);
}
Index.connect.call(Index); Index.connect.call(Index);
} else { } else {
Main.refresh({ Index.update();
boardID: boardID,
view: view,
threadID: threadID
});
} }
} else {
c.error('How?');
Main.refresh({
boardID: boardID,
view: view,
threadID: threadID
});
} }
return Header.setBoardList(); return Header.setBoardList();
}, },
@ -12875,20 +12866,15 @@
return $('.boardTitle').innerHTML = d.title = "/" + board.board + "/ - " + board.title; return $('.boardTitle').innerHTML = d.title = "/" + board.board + "/ - " + board.title;
}, },
refresh: function(context) { refresh: function(context) {
var boardID, name, threadID, view, _results, _results1; var boardID, feature, name, threadID, view, _i, _len, _ref, _ref1;
return;
boardID = context.boardID, view = context.view, threadID = context.threadID; boardID = context.boardID, view = context.view, threadID = context.threadID;
if (view === 'thread') { _ref = Main.features;
_results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) {
for (name in Main.features) { _ref1 = _ref[_i], name = _ref1[0], feature = _ref1[1];
_results.push(Main.features[name].thread()); if (feature.refresh) {
feature.refresh();
} }
return _results;
} else {
_results1 = [];
for (name in Main.features) {
_results1.push(Main.features[name].index());
}
return _results1;
} }
} }
}; };

View File

@ -2027,7 +2027,7 @@
$.addClass(doc, args[0]); $.addClass(doc, args[0]);
$.rmClass(doc, args[1]); $.rmClass(doc, args[1]);
Header.bar.parentNode.className = args[2]; Header.bar.parentNode.className = args[2];
return $[args[3]](Header.bar, Header.notify); return $[args[3]](Header.bar, Header.noticesRoot);
}, },
toggleBarPosition: function() { toggleBarPosition: function() {
$.cb.checked.call(this); $.cb.checked.call(this);
@ -2387,7 +2387,7 @@
return Header.scrollToIfNeeded(Index.root); return Header.scrollToIfNeeded(Index.root);
}, },
getCurrentPage: function() { getCurrentPage: function() {
return +window.location.pathname.split('/')[2] || 0; return +window.location.pathname.split('/')[2];
}, },
userPageNav: function(pageNum) { userPageNav: function(pageNum) {
if (Conf['Refreshed Navigation'] && Conf['Index Mode'] === 'paged') { if (Conf['Refreshed Navigation'] && Conf['Index Mode'] === 'paged') {
@ -2520,7 +2520,7 @@
} }
} catch (_error) { } catch (_error) {
err = _error; err = _error;
c.error('Index failure:', err.stack); c.error('Index failure:', err);
if (notice) { if (notice) {
notice.setType('error'); notice.setType('error');
notice.el.lastElementChild.textContent = 'Index refresh failed.'; notice.el.lastElementChild.textContent = 'Index refresh failed.';
@ -12765,45 +12765,38 @@
history.pushState(null, '', this.pathname); history.pushState(null, '', this.pathname);
} }
view = threadID ? 'thread' : view || 'index'; view = threadID ? 'thread' : view || 'index';
if (view === g.VIEW) { if (view !== g.VIEW) {
if (view === 'index') { Main.clean();
if (boardID !== g.BOARD.ID) { Main.disconnect(view);
Main.clean(); }
Main.updateBoard(boardID); if (view === 'index') {
} if (boardID !== g.BOARD.ID) {
Index.update(); Main.updateBoard(boardID);
} else {
Main.refresh({
boardID: boardID,
view: view,
threadID: threadID
});
} }
} else { if (Index.root) {
if (view === 'index') {
Main.disconnect(view);
Main.clean();
if (boardID !== g.BOARD.ID) {
Main.updateBoard(boardID);
}
Index.connect.call(Index); Index.connect.call(Index);
} else { } else {
Main.refresh({ Index.update();
boardID: boardID,
view: view,
threadID: threadID
});
} }
} else {
c.error('How?');
Main.refresh({
boardID: boardID,
view: view,
threadID: threadID
});
} }
return Header.setBoardList(); return Header.setBoardList();
}, },
popstate: function() { popstate: function() {
var a; return Main.popstate = function() {
a = $.el('a', { var a;
href: window.location, a = $.el('a', {
id: 'popState' href: window.location,
}); id: 'popState'
return Main.navigate.call(a); });
return Main.navigate.call(a);
};
}, },
updateBoard: function(boardID) { updateBoard: function(boardID) {
var onload, req; var onload, req;
@ -12849,20 +12842,15 @@
return $('.boardTitle').innerHTML = d.title = "/" + board.board + "/ - " + board.title; return $('.boardTitle').innerHTML = d.title = "/" + board.board + "/ - " + board.title;
}, },
refresh: function(context) { refresh: function(context) {
var boardID, name, threadID, view, _results, _results1; var boardID, feature, name, threadID, view, _i, _len, _ref, _ref1;
return;
boardID = context.boardID, view = context.view, threadID = context.threadID; boardID = context.boardID, view = context.view, threadID = context.threadID;
if (view === 'thread') { _ref = Main.features;
_results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) {
for (name in Main.features) { _ref1 = _ref[_i], name = _ref1[0], feature = _ref1[1];
_results.push(Main.features[name].thread()); if (feature.refresh) {
feature.refresh();
} }
return _results;
} else {
_results1 = [];
for (name in Main.features) {
_results1.push(Main.features[name].index());
}
return _results1;
} }
} }
}; };

View File

@ -330,7 +330,7 @@ Header =
$.addClass doc, args[0] $.addClass doc, args[0]
$.rmClass doc, args[1] $.rmClass doc, args[1]
Header.bar.parentNode.className = args[2] Header.bar.parentNode.className = args[2]
$[args[3]] Header.bar, Header.notify $[args[3]] Header.bar, Header.noticesRoot
toggleBarPosition: -> toggleBarPosition: ->
$.cb.checked.call @ $.cb.checked.call @

View File

@ -144,7 +144,7 @@ Index =
Header.scrollToIfNeeded Index.root Header.scrollToIfNeeded Index.root
getCurrentPage: -> getCurrentPage: ->
+window.location.pathname.split('/')[2] or 0 +window.location.pathname.split('/')[2]
userPageNav: (pageNum) -> userPageNav: (pageNum) ->
if Conf['Refreshed Navigation'] and Conf['Index Mode'] is 'paged' if Conf['Refreshed Navigation'] and Conf['Index Mode'] is 'paged'
Index.update pageNum Index.update pageNum
@ -245,7 +245,7 @@ Index =
else if req.status is 304 and pageNum? else if req.status is 304 and pageNum?
Index.pageNav pageNum Index.pageNav pageNum
catch err catch err
c.error 'Index failure:', err.stack c.error 'Index failure:', err
# network error or non-JSON content for example. # network error or non-JSON content for example.
if notice if notice
notice.setType 'error' notice.setType 'error'

View File

@ -352,7 +352,7 @@ Main =
g.VIEW = view g.VIEW = view
navigate: (e) -> navigate: (e) ->
return unless @hostname is 'boards.4chan.org' return if @hostname isnt '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
path = @pathname.split '/' path = @pathname.split '/'
path.shift() if path[0] is '' path.shift() if path[0] is ''
@ -368,31 +368,26 @@ Main =
else else
view or 'index' # path is "/boardID/". See the problem? view or 'index' # path is "/boardID/". See the problem?
# Moving from thread to thread or index to index. if view isnt g.VIEW
if view is g.VIEW Main.clean()
if view is 'index' Main.disconnect view
unless boardID is g.BOARD.ID
Main.clean()
Main.updateBoard boardID
if view is 'index'
Main.updateBoard boardID unless boardID is g.BOARD.ID
if Index.root
Index.connect.call Index
else
Index.update() Index.update()
else # Moving from thread to thread or index to index.
Main.refresh {boardID, view, threadID}
else else
if view is 'index' c.error 'How?'
Main.disconnect view Main.refresh {boardID, view, threadID}
Main.clean()
Main.updateBoard boardID unless boardID is g.BOARD.ID
Index.connect.call Index
else
Main.refresh {boardID, view, threadID}
Header.setBoardList() Header.setBoardList()
popstate: -> popstate: -> <% if (type === 'crx') { %> Main.popstate = -> <% } %> # blink/webkit throw a popstate on page load. Not what we want.
a = $.el 'a', a = $.el 'a',
href: window.location href: window.location
id: 'popState' id: 'popState'
@ -430,13 +425,11 @@ Main =
$('.boardTitle').innerHTML = d.title = "/#{board.board}/ - #{board.title}" $('.boardTitle').innerHTML = d.title = "/#{board.board}/ - #{board.title}"
refresh: (context) -> refresh: (context) ->
return
{boardID, view, threadID} = context {boardID, view, threadID} = context
if view is 'thread' # Refresh features
# Refresh thread features feature.refresh() for [name, feature] in Main.features when feature.refresh
Main.features[name].thread() for name of Main.features return
else
# Refresh index features
Main.features[name].index() for name of Main.features
Main.init() Main.init()