From bdf979d0f939d80ef0542e60f0f70c5fd81244cd Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 22 Mar 2012 12:40:24 -0700 Subject: [PATCH] mv flatten into Main --- 4chan_x.user.js | 30 +++++++++++++++--------------- script.coffee | 24 ++++++++++++------------ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3e896c43f..dc50b1fb6 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -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) { diff --git a/script.coffee b/script.coffee index cc01acf1a..82b0341fd 100644 --- a/script.coffee +++ b/script.coffee @@ -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