start $.config -> conf

This commit is contained in:
James Campos 2011-07-23 18:55:27 -07:00
parent bc9093584b
commit c15a55c2f0
2 changed files with 20 additions and 18 deletions

View File

@ -59,7 +59,7 @@
*/ */
(function() { (function() {
var $, $$, Favicon, NAMESPACE, Recaptcha, Time, anonymize, config, cooldown, d, expandComment, expandThread, firstRun, g, imgExpand, imgGif, imgHover, imgPreloading, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, watcher, _config, _ref; var $, $$, Favicon, NAMESPACE, Recaptcha, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, firstRun, g, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher, _ref;
var __slice = Array.prototype.slice; var __slice = Array.prototype.slice;
config = { config = {
main: { main: {
@ -144,14 +144,14 @@
'Interval': 30 'Interval': 30
} }
}; };
_config = {}; conf = {};
(function(parent, obj) { (function(parent, obj) {
var key, val, _results; var key, val, _results;
if (obj.length) { if (obj.length) {
if (typeof obj[0] === 'boolean') { if (typeof obj[0] === 'boolean') {
return _config[parent] = obj[0]; return conf[parent] = obj[0];
} else { } else {
return _config[parent] = obj; return conf[parent] = obj;
} }
} else if (typeof obj === 'object') { } else if (typeof obj === 'object') {
_results = []; _results = [];
@ -161,7 +161,7 @@
} }
return _results; return _results;
} else { } else {
return _config[parent] = obj; return conf[parent] = obj;
} }
})(null, config); })(null, config);
if (typeof console !== "undefined" && console !== null) { if (typeof console !== "undefined" && console !== null) {
@ -346,9 +346,6 @@
$.append(d.head, style); $.append(d.head, style);
return style; return style;
}, },
config: function(name) {
return $.getValue(name, _config[name]);
},
x: function(path, root) { x: function(path, root) {
if (root == null) { if (root == null) {
root = d.body; root = d.body;
@ -500,6 +497,10 @@
} }
}); });
} }
for (key in conf) {
val = conf[key];
conf[key] = $.getValue(key, conf[key]);
}
$$ = function(selector, root) { $$ = function(selector, root) {
if (root == null) { if (root == null) {
root = d.body; root = d.body;
@ -744,7 +745,7 @@
}, },
cb: { cb: {
keydown: function(e) { keydown: function(e) {
var key, o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; var o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3;
if (((_ref = e.target.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey && !(e.keyCode === 27)) { if (((_ref = e.target.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey && !(e.keyCode === 27)) {
return; return;
} }
@ -847,7 +848,7 @@
return e.preventDefault(); return e.preventDefault();
}, },
keyCode: function(e, options) { keyCode: function(e, options) {
var kc, key; var kc;
kc = e.keyCode; kc = e.keyCode;
if ((65 <= kc && kc <= 90)) { if ((65 <= kc && kc <= 90)) {
key = String.fromCharCode(kc); key = String.fromCharCode(kc);
@ -1135,7 +1136,6 @@
return g.hiddenReplies = {}; return g.hiddenReplies = {};
}, },
keybind: function(e) { keybind: function(e) {
var key;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
key = keybinds.cb.keyCode(e, true); key = keybinds.cb.keyCode(e, true);
@ -1561,7 +1561,7 @@
}; };
updater = { updater = {
init: function() { init: function() {
var autoUpT, checked, conf, dialog, html, input, interva, name, title, updNow, verbose, _i, _len, _ref; var autoUpT, checked, dialog, html, input, interva, name, title, updNow, verbose, _i, _len, _ref;
updater.interval = $.config('Interval'); updater.interval = $.config('Interval');
updater.ircUpd = $.config('IRC Updating'); updater.ircUpd = $.config('IRC Updating');
updater.verbose = $.config('Verbose'); updater.verbose = $.config('Verbose');

View File

@ -78,18 +78,18 @@ config =
'Interval': 30 'Interval': 30
# flatten the config # flatten the config
_config = {} conf = {}
((parent, obj) -> ((parent, obj) ->
if obj.length #array if obj.length #array
if typeof obj[0] is 'boolean' if typeof obj[0] is 'boolean'
_config[parent] = obj[0] conf[parent] = obj[0]
else else
_config[parent] = obj conf[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
else #constant else #constant
_config[parent] = obj conf[parent] = obj
) null, config ) null, config
# XXX chrome can't into `{log} = console` # XXX chrome can't into `{log} = console`
@ -229,8 +229,6 @@ $.extend $,
textContent: css textContent: css
$.append d.head, style $.append d.head, style
style style
config: (name) ->
$.getValue name, _config[name]
x: (path, root=d.body) -> x: (path, root=d.body) ->
d.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null). d.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).
singleNodeValue singleNodeValue
@ -352,6 +350,10 @@ else
name = NAMESPACE + name name = NAMESPACE + name
localStorage[name] = JSON.stringify value localStorage[name] = JSON.stringify value
#load values from localStorage
for key, val of conf
conf[key] = $.getValue key, conf[key]
$$ = (selector, root=d.body) -> $$ = (selector, root=d.body) ->
Array::slice.call root.querySelectorAll selector Array::slice.call root.querySelectorAll selector