Implement a cheap and easy style switcher on navigate
This commit is contained in:
parent
8ad7677eeb
commit
b9924973c5
@ -11950,7 +11950,7 @@
|
|||||||
g.BOARD = new Board(boardID);
|
g.BOARD = new Board(boardID);
|
||||||
req = null;
|
req = null;
|
||||||
onload = function(e) {
|
onload = function(e) {
|
||||||
var board, err, _i, _len, _ref;
|
var board, mainStyleSheet, newStyleSheet, style, type, _ref;
|
||||||
if (e.type === 'abort') {
|
if (e.type === 'abort') {
|
||||||
req.onloadend = null;
|
req.onloadend = null;
|
||||||
return;
|
return;
|
||||||
@ -11958,23 +11958,37 @@
|
|||||||
if (req.status !== 200) {
|
if (req.status !== 200) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
board = (function() {
|
||||||
_ref = JSON.parse(req.response).boards;
|
var err, _i, _len, _ref;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
try {
|
||||||
board = _ref[_i];
|
_ref = JSON.parse(req.response).boards;
|
||||||
if (board.board === boardID) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
return Navigate.updateTitle(board);
|
board = _ref[_i];
|
||||||
|
if (board.board === boardID) {
|
||||||
|
return board;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (_error) {
|
||||||
|
err = _error;
|
||||||
|
Main.handleErrors([
|
||||||
|
{
|
||||||
|
message: "Navigation failed to update board name.",
|
||||||
|
error: err
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
})();
|
||||||
err = _error;
|
if (!board) {
|
||||||
return Main.handleErrors([
|
return;
|
||||||
{
|
|
||||||
message: "Navigation failed to update board name.",
|
|
||||||
error: err
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
Navigate.updateTitle(board);
|
||||||
|
_ref = board.ws_board ? [(d.cookie.match(/ws\_style\=[^;]+/) || ['Yotsuba B New'])[0], 'ws_style'] : [(d.cookie.match(/nws\_style\=[^;]+/) || ['Yotsuba New'])[0], 'nws_style'], style = _ref[0], type = _ref[1];
|
||||||
|
$.globalEval("var style_group = '" + type + "'");
|
||||||
|
mainStyleSheet = $('link[title=switch]', d.head);
|
||||||
|
newStyleSheet = $("link[rel='alternate stylesheet'][title='" + style + "']", d.head);
|
||||||
|
mainStyleSheet.href = newStyleSheet.href;
|
||||||
|
return Main.initStyle();
|
||||||
};
|
};
|
||||||
fullBoardList = $('#full-board-list', Header.boardList);
|
fullBoardList = $('#full-board-list', Header.boardList);
|
||||||
$.rmClass($('.current', fullBoardList), 'current');
|
$.rmClass($('.current', fullBoardList), 'current');
|
||||||
|
|||||||
@ -11939,7 +11939,7 @@
|
|||||||
g.BOARD = new Board(boardID);
|
g.BOARD = new Board(boardID);
|
||||||
req = null;
|
req = null;
|
||||||
onload = function(e) {
|
onload = function(e) {
|
||||||
var board, err, _i, _len, _ref;
|
var board, mainStyleSheet, newStyleSheet, style, type, _ref;
|
||||||
if (e.type === 'abort') {
|
if (e.type === 'abort') {
|
||||||
req.onloadend = null;
|
req.onloadend = null;
|
||||||
return;
|
return;
|
||||||
@ -11947,23 +11947,37 @@
|
|||||||
if (req.status !== 200) {
|
if (req.status !== 200) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
board = (function() {
|
||||||
_ref = JSON.parse(req.response).boards;
|
var err, _i, _len, _ref;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
try {
|
||||||
board = _ref[_i];
|
_ref = JSON.parse(req.response).boards;
|
||||||
if (board.board === boardID) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
return Navigate.updateTitle(board);
|
board = _ref[_i];
|
||||||
|
if (board.board === boardID) {
|
||||||
|
return board;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (_error) {
|
||||||
|
err = _error;
|
||||||
|
Main.handleErrors([
|
||||||
|
{
|
||||||
|
message: "Navigation failed to update board name.",
|
||||||
|
error: err
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
})();
|
||||||
err = _error;
|
if (!board) {
|
||||||
return Main.handleErrors([
|
return;
|
||||||
{
|
|
||||||
message: "Navigation failed to update board name.",
|
|
||||||
error: err
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
Navigate.updateTitle(board);
|
||||||
|
_ref = board.ws_board ? [(d.cookie.match(/ws\_style\=[^;]+/) || ['Yotsuba B New'])[0], 'ws_style'] : [(d.cookie.match(/nws\_style\=[^;]+/) || ['Yotsuba New'])[0], 'nws_style'], style = _ref[0], type = _ref[1];
|
||||||
|
$.globalEval("var style_group = '" + type + "'");
|
||||||
|
mainStyleSheet = $('link[title=switch]', d.head);
|
||||||
|
newStyleSheet = $("link[rel='alternate stylesheet'][title='" + style + "']", d.head);
|
||||||
|
mainStyleSheet.href = newStyleSheet.href;
|
||||||
|
return Main.initStyle();
|
||||||
};
|
};
|
||||||
fullBoardList = $('#full-board-list', Header.boardList);
|
fullBoardList = $('#full-board-list', Header.boardList);
|
||||||
$.rmClass($('.current', fullBoardList), 'current');
|
$.rmClass($('.current', fullBoardList), 'current');
|
||||||
|
|||||||
@ -123,15 +123,35 @@ Navigate =
|
|||||||
|
|
||||||
return unless req.status is 200
|
return unless req.status is 200
|
||||||
|
|
||||||
try
|
board = do -> try
|
||||||
for board in JSON.parse(req.response).boards
|
for board in JSON.parse(req.response).boards
|
||||||
return Navigate.updateTitle board if board.board is boardID
|
return board if board.board is boardID
|
||||||
|
|
||||||
catch err
|
catch err
|
||||||
Main.handleErrors [
|
Main.handleErrors [
|
||||||
message: "Navigation failed to update board name."
|
message: "Navigation failed to update board name."
|
||||||
error: err
|
error: err
|
||||||
]
|
]
|
||||||
|
return false
|
||||||
|
|
||||||
|
return unless board
|
||||||
|
Navigate.updateTitle board
|
||||||
|
[style, type] = if board.ws_board then [
|
||||||
|
(d.cookie.match(/ws\_style\=[^;]+/) or ['Yotsuba B New'])[0]
|
||||||
|
'ws_style'
|
||||||
|
] else [
|
||||||
|
(d.cookie.match(/nws\_style\=[^;]+/) or ['Yotsuba New'])[0]
|
||||||
|
'nws_style'
|
||||||
|
]
|
||||||
|
|
||||||
|
$.globalEval "var style_group = '#{type}'"
|
||||||
|
|
||||||
|
mainStyleSheet = $ 'link[title=switch]', d.head
|
||||||
|
newStyleSheet = $ "link[rel='alternate stylesheet'][title='#{style}']", d.head
|
||||||
|
|
||||||
|
mainStyleSheet.href = newStyleSheet.href
|
||||||
|
|
||||||
|
Main.initStyle()
|
||||||
|
|
||||||
fullBoardList = $ '#full-board-list', Header.boardList
|
fullBoardList = $ '#full-board-list', Header.boardList
|
||||||
$.rmClass $('.current', fullBoardList), 'current'
|
$.rmClass $('.current', fullBoardList), 'current'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user