fix flavors

This commit is contained in:
James Campos 2011-04-24 23:54:49 -07:00
parent b84234fdf5
commit 06194bf43e
2 changed files with 24 additions and 16 deletions

View File

@ -92,6 +92,9 @@
'Thread Updater': [true, 'Update threads'], 'Thread Updater': [true, 'Update threads'],
'Thread Watcher': [true, 'Bookmark threads'], 'Thread Watcher': [true, 'Bookmark threads'],
'Unread Count': [true, 'Show unread post count in tab title'] '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: { updater: {
@ -106,7 +109,11 @@
(function(parent, obj) { (function(parent, obj) {
var key, val, _results; var key, val, _results;
if (obj.length) { 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') { } else if (typeof obj === 'object') {
_results = []; _results = [];
for (key in obj) { for (key in obj) {
@ -862,7 +869,7 @@
html += "<div><label title=\"" + title + "\">" + name + "<input name=\"" + name + "\" " + checked + " type=checkbox></label></div>"; html += "<div><label title=\"" + title + "\">" + name + "<input name=\"" + name + "\" " + checked + " type=checkbox></label></div>";
} }
html += "<div><a name=flavors>Flavors</a></div>"; html += "<div><a name=flavors>Flavors</a></div>";
html += "<div><textarea style=\"display: none;\" name=flavors>" + ($.getValue('flavors', g.flavors)) + "</textarea></div>"; html += "<div><textarea style=\"display: none;\" name=flavors>" + ($.config('flavors').join('\n')) + "</textarea></div>";
hiddenThread = $.getValue("hiddenThread/" + g.BOARD + "/", {}); hiddenThread = $.getValue("hiddenThread/" + g.BOARD + "/", {});
hiddenNum = Object.keys(g.hiddenReply).length + Object.keys(hiddenThread).length; hiddenNum = Object.keys(g.hiddenReply).length + Object.keys(hiddenThread).length;
html += "<div><input type=\"button\" value=\"hidden: " + hiddenNum + "\"></div>"; html += "<div><input type=\"button\" value=\"hidden: " + hiddenNum + "\"></div>";
@ -1506,7 +1513,7 @@
cb: { cb: {
node: function(root) { node: function(root) {
var i, link, names, prefix, prefixes, span, suffix, _i, _len, _ref, _results; var i, link, names, prefix, prefixes, span, suffix, _i, _len, _ref, _results;
prefixes = $.getValue('flavors', g.flavors).split('\n'); prefixes = $.config('flavors');
names = (function() { names = (function() {
var _i, _len, _results; var _i, _len, _results;
_results = []; _results = [];
@ -1977,8 +1984,7 @@
g = { g = {
cache: {}, cache: {},
requests: {}, requests: {},
callbacks: [], callbacks: []
flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://tineye.com/search?url='].join('\n')
}; };
main = { main = {
init: function() { init: function() {

View File

@ -4,9 +4,6 @@
# (floating) qr no-quote button? # (floating) qr no-quote button?
# updater cache hacks # updater cache hacks
# XXX
# flavors saving is broken
# XXX chrome can't into `{log} = console` # XXX chrome can't into `{log} = console`
if console? if console?
log = (arg) -> log = (arg) ->
@ -38,17 +35,27 @@ config =
'Thread Updater': [true, 'Update threads'] 'Thread Updater': [true, 'Update threads']
'Thread Watcher': [true, 'Bookmark threads'] 'Thread Watcher': [true, 'Bookmark threads']
'Unread Count': [true, 'Show unread post count in tab title'] '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: updater:
checkbox: checkbox:
'Verbose': [true, 'Show countdown timer, new post count'] 'Verbose': [true, 'Show countdown timer, new post count']
'Auto Update': [false, 'Automatically fetch new posts'] 'Auto Update': [false, 'Automatically fetch new posts']
'Interval': 30 'Interval': 30
# FIXME this is fucking horrible
# create 'global' options, no namespacing # create 'global' options, no namespacing
_config = {} _config = {}
((parent, obj) -> ((parent, obj) ->
if obj.length #array 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' else if typeof obj is 'object'
for key, val of obj for key, val of obj
arguments.callee key, val arguments.callee key, val
@ -642,7 +649,7 @@ options =
checked = if $.config name then "checked" else "" checked = if $.config name then "checked" else ""
html += "<div><label title=\"#{title}\">#{name}<input name=\"#{name}\" #{checked} type=checkbox></label></div>" html += "<div><label title=\"#{title}\">#{name}<input name=\"#{name}\" #{checked} type=checkbox></label></div>"
html += "<div><a name=flavors>Flavors</a></div>" html += "<div><a name=flavors>Flavors</a></div>"
html += "<div><textarea style=\"display: none;\" name=flavors>#{$.getValue 'flavors', g.flavors}</textarea></div>" html += "<div><textarea style=\"display: none;\" name=flavors>#{$.config('flavors').join '\n'}</textarea></div>"
hiddenThread = $.getValue "hiddenThread/#{g.BOARD}/", {} hiddenThread = $.getValue "hiddenThread/#{g.BOARD}/", {}
hiddenNum = Object.keys(g.hiddenReply).length + Object.keys(hiddenThread).length hiddenNum = Object.keys(g.hiddenReply).length + Object.keys(hiddenThread).length
@ -1185,7 +1192,7 @@ sauce =
g.callbacks.push sauce.cb.node g.callbacks.push sauce.cb.node
cb: cb:
node: (root) -> node: (root) ->
prefixes = $.getValue('flavors', g.flavors).split '\n' prefixes = $.config 'flavors'
names = (prefix.match(/(\w+)\./)[1] for prefix in prefixes) names = (prefix.match(/(\w+)\./)[1] for prefix in prefixes)
for span in $$ 'span.filesize', root for span in $$ 'span.filesize', root
suffix = $('a', span).href suffix = $('a', span).href
@ -1505,11 +1512,6 @@ g =
cache: {} cache: {}
requests: {} requests: {}
callbacks: [] callbacks: []
flavors: [
'http://regex.info/exif.cgi?url='
'http://iqdb.org/?url='
'http://tineye.com/search?url='
].join '\n'
main = main =
init: -> init: ->