mv flatten into Main
This commit is contained in:
parent
0cce896b1a
commit
bdf979d0f9
@ -73,7 +73,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(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 = {
|
Config = {
|
||||||
main: {
|
main: {
|
||||||
@ -194,20 +194,6 @@
|
|||||||
|
|
||||||
Conf = {};
|
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;
|
d = document;
|
||||||
|
|
||||||
g = {};
|
g = {};
|
||||||
@ -3794,6 +3780,7 @@
|
|||||||
Main = {
|
Main = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var cutoff, hiddenThreads, id, key, now, path, pathname, temp, timestamp, val, _ref;
|
var cutoff, hiddenThreads, id, key, now, path, pathname, temp, timestamp, val, _ref;
|
||||||
|
Main.flatten(null, Config);
|
||||||
path = location.pathname;
|
path = location.pathname;
|
||||||
pathname = path.slice(1).split('/');
|
pathname = path.slice(1).split('/');
|
||||||
g.BOARD = pathname[0], temp = pathname[1];
|
g.BOARD = pathname[0], temp = pathname[1];
|
||||||
@ -3970,6 +3957,19 @@
|
|||||||
return $.on(form, 'DOMNodeInserted', Main.listener);
|
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() {
|
addStyle: function() {
|
||||||
$.off(d, 'DOMNodeInserted', Main.addStyle);
|
$.off(d, 'DOMNodeInserted', Main.addStyle);
|
||||||
if (d.head) {
|
if (d.head) {
|
||||||
|
|||||||
@ -154,19 +154,7 @@ Config =
|
|||||||
'Auto Update': [true, 'Automatically fetch new posts']
|
'Auto Update': [true, 'Automatically fetch new posts']
|
||||||
'Interval': 30
|
'Interval': 30
|
||||||
|
|
||||||
# flatten the config
|
|
||||||
Conf = {}
|
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
|
d = document
|
||||||
g = {}
|
g = {}
|
||||||
|
|
||||||
@ -3152,6 +3140,8 @@ ImageExpand =
|
|||||||
|
|
||||||
Main =
|
Main =
|
||||||
init: ->
|
init: ->
|
||||||
|
Main.flatten null, Config
|
||||||
|
|
||||||
path = location.pathname
|
path = location.pathname
|
||||||
pathname = path[1..].split '/'
|
pathname = path[1..].split '/'
|
||||||
[g.BOARD, temp] = pathname
|
[g.BOARD, temp] = pathname
|
||||||
@ -3336,6 +3326,16 @@ Main =
|
|||||||
else
|
else
|
||||||
$.on form, 'DOMNodeInserted', Main.listener
|
$.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: ->
|
addStyle: ->
|
||||||
$.off d, 'DOMNodeInserted', Main.addStyle
|
$.off d, 'DOMNodeInserted', Main.addStyle
|
||||||
if d.head
|
if d.head
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user