mv config flattening into Main.init

This commit is contained in:
James Campos 2012-03-16 00:34:57 -07:00
parent 6d7bd16653
commit 3fa7368b6b
2 changed files with 29 additions and 31 deletions

View File

@ -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, flatten, _base;
var $, $$, Anonymize, AutoGif, 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, _base;
Config = {
main: {
@ -192,22 +192,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);
UI = {
dialog: function(id, position, html) {
var el, saved;
@ -3790,7 +3774,21 @@
Main = {
init: function() {
var cutoff, hiddenThreads, id, key, now, path, pathname, temp, timestamp, val, _ref;
var Conf, cutoff, flatten, hiddenThreads, id, key, now, path, pathname, temp, timestamp, val, _ref;
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);
path = location.pathname;
pathname = path.slice(1).split('/');
Main.BOARD = pathname[0], temp = pathname[1];

View File

@ -154,19 +154,6 @@ 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
UI =
dialog: (id, position, html) ->
el = $.d.createElement 'div'
@ -3153,6 +3140,19 @@ ImageExpand =
Main =
init: ->
# 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
path = location.pathname
pathname = path[1..].split '/'
[Main.BOARD, temp] = pathname