From 06194bf43e699c81edd34278d68b157c89200a5b Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 24 Apr 2011 23:54:49 -0700 Subject: [PATCH] fix flavors --- 4chan_x.js | 16 +++++++++++----- script.coffee | 24 +++++++++++++----------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index abc21496f..5d349ee7e 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -92,6 +92,9 @@ 'Thread Updater': [true, 'Update threads'], 'Thread Watcher': [true, 'Bookmark threads'], 'Unread Count': [true, 'Show unread post count in tab title'] + }, + textarea: { + flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://tineye.com/search?url='] } }, updater: { @@ -106,7 +109,11 @@ (function(parent, obj) { var key, val, _results; if (obj.length) { - return _config[parent] = obj[0]; + if (typeof obj[0] === 'boolean') { + return _config[parent] = obj[0]; + } else { + return _config[parent] = obj; + } } else if (typeof obj === 'object') { _results = []; for (key in obj) { @@ -862,7 +869,7 @@ html += "
"; } html += "
Flavors
"; - html += "
"; + html += "
"; hiddenThread = $.getValue("hiddenThread/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReply).length + Object.keys(hiddenThread).length; html += "
"; @@ -1506,7 +1513,7 @@ cb: { node: function(root) { var i, link, names, prefix, prefixes, span, suffix, _i, _len, _ref, _results; - prefixes = $.getValue('flavors', g.flavors).split('\n'); + prefixes = $.config('flavors'); names = (function() { var _i, _len, _results; _results = []; @@ -1977,8 +1984,7 @@ g = { cache: {}, requests: {}, - callbacks: [], - flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://tineye.com/search?url='].join('\n') + callbacks: [] }; main = { init: function() { diff --git a/script.coffee b/script.coffee index a8583b799..1ee1c363d 100644 --- a/script.coffee +++ b/script.coffee @@ -4,9 +4,6 @@ # (floating) qr no-quote button? # updater cache hacks -# XXX -# flavors saving is broken - # XXX chrome can't into `{log} = console` if console? log = (arg) -> @@ -38,17 +35,27 @@ config = 'Thread Updater': [true, 'Update threads'] 'Thread Watcher': [true, 'Bookmark threads'] 'Unread Count': [true, 'Show unread post count in tab title'] + textarea: + flavors: [ + 'http://regex.info/exif.cgi?url=' + 'http://iqdb.org/?url=' + 'http://tineye.com/search?url=' + ] updater: checkbox: 'Verbose': [true, 'Show countdown timer, new post count'] 'Auto Update': [false, 'Automatically fetch new posts'] 'Interval': 30 +# FIXME this is fucking horrible # create 'global' options, no namespacing _config = {} ((parent, obj) -> if obj.length #array - _config[parent] = obj[0] + if typeof obj[0] is 'boolean' + _config[parent] = obj[0] + else + _config[parent] = obj else if typeof obj is 'object' for key, val of obj arguments.callee key, val @@ -642,7 +649,7 @@ options = checked = if $.config name then "checked" else "" html += "
" html += "
Flavors
" - html += "
" + html += "
" hiddenThread = $.getValue "hiddenThread/#{g.BOARD}/", {} hiddenNum = Object.keys(g.hiddenReply).length + Object.keys(hiddenThread).length @@ -1185,7 +1192,7 @@ sauce = g.callbacks.push sauce.cb.node cb: node: (root) -> - prefixes = $.getValue('flavors', g.flavors).split '\n' + prefixes = $.config 'flavors' names = (prefix.match(/(\w+)\./)[1] for prefix in prefixes) for span in $$ 'span.filesize', root suffix = $('a', span).href @@ -1505,11 +1512,6 @@ g = cache: {} requests: {} callbacks: [] - flavors: [ - 'http://regex.info/exif.cgi?url=' - 'http://iqdb.org/?url=' - 'http://tineye.com/search?url=' - ].join '\n' main = init: ->