mv flatten into Main
This commit is contained in:
parent
0cce896b1a
commit
bdf979d0f9
@ -73,7 +73,7 @@
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var $, $$, Anonymize, AutoGif, Conf, Config, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, GetTitle, ImageExpand, ImageHover, Keybinds, Main, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportButton, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Threading, Time, TitlePost, UI, Unread, Updater, Watcher, d, flatten, g, _base;
|
||||
var $, $$, Anonymize, AutoGif, Conf, Config, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, GetTitle, ImageExpand, ImageHover, Keybinds, Main, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportButton, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Threading, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base;
|
||||
|
||||
Config = {
|
||||
main: {
|
||||
@ -194,20 +194,6 @@
|
||||
|
||||
Conf = {};
|
||||
|
||||
(flatten = function(parent, obj) {
|
||||
var key, val;
|
||||
if (obj instanceof Array) {
|
||||
Conf[parent] = obj[0];
|
||||
} else if (typeof obj === 'object') {
|
||||
for (key in obj) {
|
||||
val = obj[key];
|
||||
flatten(key, val);
|
||||
}
|
||||
} else {
|
||||
Conf[parent] = obj;
|
||||
}
|
||||
})(null, Config);
|
||||
|
||||
d = document;
|
||||
|
||||
g = {};
|
||||
@ -3794,6 +3780,7 @@
|
||||
Main = {
|
||||
init: function() {
|
||||
var cutoff, hiddenThreads, id, key, now, path, pathname, temp, timestamp, val, _ref;
|
||||
Main.flatten(null, Config);
|
||||
path = location.pathname;
|
||||
pathname = path.slice(1).split('/');
|
||||
g.BOARD = pathname[0], temp = pathname[1];
|
||||
@ -3970,6 +3957,19 @@
|
||||
return $.on(form, 'DOMNodeInserted', Main.listener);
|
||||
}
|
||||
},
|
||||
flatten: function(parent, obj) {
|
||||
var key, val;
|
||||
if (obj instanceof Array) {
|
||||
Conf[parent] = obj[0];
|
||||
} else if (typeof obj === 'object') {
|
||||
for (key in obj) {
|
||||
val = obj[key];
|
||||
Main.flatten(key, val);
|
||||
}
|
||||
} else {
|
||||
Conf[parent] = obj;
|
||||
}
|
||||
},
|
||||
addStyle: function() {
|
||||
$.off(d, 'DOMNodeInserted', Main.addStyle);
|
||||
if (d.head) {
|
||||
|
||||
@ -154,19 +154,7 @@ Config =
|
||||
'Auto Update': [true, 'Automatically fetch new posts']
|
||||
'Interval': 30
|
||||
|
||||
# flatten the config
|
||||
Conf = {}
|
||||
(flatten = (parent, obj) ->
|
||||
if obj instanceof Array
|
||||
Conf[parent] = obj[0]
|
||||
else if typeof obj is 'object'
|
||||
for key, val of obj
|
||||
flatten key, val
|
||||
else # string or number
|
||||
Conf[parent] = obj
|
||||
return
|
||||
) null, Config
|
||||
|
||||
d = document
|
||||
g = {}
|
||||
|
||||
@ -3152,6 +3140,8 @@ ImageExpand =
|
||||
|
||||
Main =
|
||||
init: ->
|
||||
Main.flatten null, Config
|
||||
|
||||
path = location.pathname
|
||||
pathname = path[1..].split '/'
|
||||
[g.BOARD, temp] = pathname
|
||||
@ -3336,6 +3326,16 @@ Main =
|
||||
else
|
||||
$.on form, 'DOMNodeInserted', Main.listener
|
||||
|
||||
flatten: (parent, obj) ->
|
||||
if obj instanceof Array
|
||||
Conf[parent] = obj[0]
|
||||
else if typeof obj is 'object'
|
||||
for key, val of obj
|
||||
Main.flatten key, val
|
||||
else # string or number
|
||||
Conf[parent] = obj
|
||||
return
|
||||
|
||||
addStyle: ->
|
||||
$.off d, 'DOMNodeInserted', Main.addStyle
|
||||
if d.head
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user