Merge Mayhem X

This commit is contained in:
seaweedchan 2013-08-13 00:39:05 -07:00
commit b8062b0323
4 changed files with 96 additions and 25 deletions

View File

@ -10338,8 +10338,26 @@
}; };
Main = { Main = {
init: function(items) { init: function() {
var db, flatten, _i, _len; var db, flatten, pathname, _i, _len, _ref;
pathname = location.pathname.split('/');
g.BOARD = new Board(pathname[1]);
if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') {
return;
}
g.VIEW = (function() {
switch (pathname[2]) {
case 'res':
return 'thread';
case 'catalog':
return 'catalog';
default:
return 'index';
}
})();
if (g.VIEW === 'thread') {
g.THREADID = +pathname[3];
}
flatten = function(parent, obj) { flatten = function(parent, obj) {
var key, val; var key, val;
if (obj instanceof Array) { if (obj instanceof Array) {
@ -10362,15 +10380,18 @@
} }
Conf['selectedArchives'] = {}; Conf['selectedArchives'] = {};
Conf['CachedTitles'] = []; Conf['CachedTitles'] = [];
$.get(Conf, Main.initFeatures); Conf['archives'] = Redirect.archives;
$.get(Conf, function(items) {
$.extend(Conf, items);
return Main.initFeatures();
});
$.on(d, '4chanMainInit', Main.initStyle); $.on(d, '4chanMainInit', Main.initStyle);
return $.asap((function() { return $.asap((function() {
return d.head && $('link[rel="shortcut icon"]', d.head) || d.readyState !== 'loading'; return d.head && $('link[rel="shortcut icon"]', d.head) || d.readyState !== 'loading';
}), Main.initStyle); }), Main.initStyle);
}, },
initFeatures: function(items) { initFeatures: function() {
var init, pathname, _ref; var init, pathname, _ref;
Conf = items;
pathname = location.pathname.split('/'); pathname = location.pathname.split('/');
g.BOARD = new Board(pathname[1]); g.BOARD = new Board(pathname[1]);
if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') { if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') {
@ -10543,9 +10564,7 @@
} }
return; return;
} }
if (!$.hasClass(doc, 'fourchan-x')) { Main.initStyle();
Main.initStyle();
}
if (board = $('.board')) { if (board = $('.board')) {
threads = []; threads = [];
posts = []; posts = [];

View File

@ -10323,8 +10323,26 @@
}; };
Main = { Main = {
init: function(items) { init: function() {
var db, flatten, _i, _len; var db, flatten, pathname, _i, _len, _ref;
pathname = location.pathname.split('/');
g.BOARD = new Board(pathname[1]);
if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') {
return;
}
g.VIEW = (function() {
switch (pathname[2]) {
case 'res':
return 'thread';
case 'catalog':
return 'catalog';
default:
return 'index';
}
})();
if (g.VIEW === 'thread') {
g.THREADID = +pathname[3];
}
flatten = function(parent, obj) { flatten = function(parent, obj) {
var key, val; var key, val;
if (obj instanceof Array) { if (obj instanceof Array) {
@ -10347,15 +10365,27 @@
} }
Conf['selectedArchives'] = {}; Conf['selectedArchives'] = {};
Conf['CachedTitles'] = []; Conf['CachedTitles'] = [];
$.get(Conf, Main.initFeatures); Conf['archives'] = Redirect.archives;
$.get(Conf, function(items) {
$.extend(Conf, items);
if (!items) {
new Notification('error', $.el('span', {
innerHTML: "It seems like your 4chan X settings became corrupted due to a <a href=\"https://code.google.com/p/chromium/issues/detail?id=261623\" target=_blank>Chrome bug</a>.<br>\nUnfortunately, you'll have to <a href=\"https://github.com/MayhemYDG/4chan-x/wiki/FAQ#known-problems\" target=_blank>fix it yourself</a>."
}));
Main.logError({
message: 'Chrome Storage API bug',
error: new Error(chrome.runtime.lastError.message || 'no lastError.message')
});
}
return Main.initFeatures();
});
$.on(d, '4chanMainInit', Main.initStyle); $.on(d, '4chanMainInit', Main.initStyle);
return $.asap((function() { return $.asap((function() {
return d.head && $('link[rel="shortcut icon"]', d.head) || d.readyState !== 'loading'; return d.head && $('link[rel="shortcut icon"]', d.head) || d.readyState !== 'loading';
}), Main.initStyle); }), Main.initStyle);
}, },
initFeatures: function(items) { initFeatures: function() {
var init, pathname, _ref; var init, pathname, _ref;
Conf = items;
pathname = location.pathname.split('/'); pathname = location.pathname.split('/');
g.BOARD = new Board(pathname[1]); g.BOARD = new Board(pathname[1]);
if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') { if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') {
@ -10528,9 +10558,7 @@
} }
return; return;
} }
if (!$.hasClass(doc, 'fourchan-x')) { Main.initStyle();
Main.initStyle();
}
if (board = $('.board')) { if (board = $('.board')) {
threads = []; threads = [];
posts = []; posts = [];

View File

@ -1,5 +1,18 @@
Main = Main =
init: (items) -> init: ->
pathname = location.pathname.split '/'
g.BOARD = new Board pathname[1]
return if g.BOARD.ID in ['z', 'fk']
g.VIEW =
switch pathname[2]
when 'res'
'thread'
when 'catalog'
'catalog'
else
'index'
if g.VIEW is 'thread'
g.THREADID = +pathname[3]
# flatten Config into Conf # flatten Config into Conf
# and get saved or default values # and get saved or default values
flatten = (parent, obj) -> flatten = (parent, obj) ->
@ -16,15 +29,28 @@ Main =
Conf[db] = boards: {} Conf[db] = boards: {}
Conf['selectedArchives'] = {} Conf['selectedArchives'] = {}
Conf['CachedTitles'] = [] Conf['CachedTitles'] = []
Conf['archives'] = Redirect.archives
$.get Conf, Main.initFeatures $.get Conf, (items) ->
$.extend Conf, items
<% if (type === 'crx') { %>
unless items
new Notification 'error', $.el 'span',
innerHTML: """
It seems like your <%= meta.name %> settings became corrupted due to a <a href="https://code.google.com/p/chromium/issues/detail?id=261623" target=_blank>Chrome bug</a>.<br>
Unfortunately, you'll have to <a href="https://github.com/MayhemYDG/4chan-x/wiki/FAQ#known-problems" target=_blank>fix it yourself</a>.
"""
# Track resolution of this bug.
Main.logError
message: 'Chrome Storage API bug'
error: new Error chrome.runtime.lastError.message or 'no lastError.message'
<% } %>
Main.initFeatures()
$.on d, '4chanMainInit', Main.initStyle $.on d, '4chanMainInit', Main.initStyle
$.asap (-> d.head and $('link[rel="shortcut icon"]', d.head) or d.readyState isnt 'loading'), $.asap (-> d.head and $('link[rel="shortcut icon"]', d.head) or d.readyState isnt 'loading'),
Main.initStyle Main.initStyle
initFeatures: (items) -> initFeatures: ->
Conf = items
pathname = location.pathname.split '/' pathname = location.pathname.split '/'
g.BOARD = new Board pathname[1] g.BOARD = new Board pathname[1]
@ -39,7 +65,6 @@ Main =
'index' 'index'
if g.VIEW is 'thread' if g.VIEW is 'thread'
g.THREADID = +pathname[3] g.THREADID = +pathname[3]
switch location.hostname switch location.hostname
when 'api.4chan.org' when 'api.4chan.org'
return return
@ -180,9 +205,8 @@ Main =
location.replace href or "/#{g.BOARD}/" location.replace href or "/#{g.BOARD}/"
return return
unless $.hasClass doc, 'fourchan-x' # Something might have gone wrong!
# Something might have gone wrong! Main.initStyle()
Main.initStyle()
if board = $ '.board' if board = $ '.board'
threads = [] threads = []

0
src/General/html/Monitoring/ThreadWatcher.html Normal file → Executable file
View File