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

View File

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

View File

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