'global' options
This commit is contained in:
parent
7facd42909
commit
2d8c1d16b0
31
4chan_x.js
31
4chan_x.js
@ -59,7 +59,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, NAMESPACE, a, as, autoWatch, callback, changeCheckbox, changeValue, config, d, delform, el, expand, expandComment, expandThread, g, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, keyModeNormal, keybinds, log, nav, navtopr, nodeInserted, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyHiding, replyNav, report, request, scroll, scrollThread, span, temp, text, threadHiding, tzOffset, ui, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updater, updaterMake, watcher, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _m, _ref, _ref2, _ref3, _ref4;
|
var $, $$, NAMESPACE, a, as, autoWatch, callback, changeCheckbox, changeValue, config, d, delform, el, expand, expandComment, expandThread, g, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, keyModeNormal, keybinds, log, nav, navtopr, nodeInserted, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyHiding, replyNav, report, request, scroll, scrollThread, span, temp, text, threadHiding, tzOffset, ui, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updater, updaterMake, watcher, _config, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _m, _ref, _ref2, _ref3, _ref4;
|
||||||
var __slice = Array.prototype.slice;
|
var __slice = Array.prototype.slice;
|
||||||
if (typeof console != "undefined" && console !== null) {
|
if (typeof console != "undefined" && console !== null) {
|
||||||
log = console.log;
|
log = console.log;
|
||||||
@ -100,6 +100,22 @@
|
|||||||
'Interval': 30
|
'Interval': 30
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
_config = {};
|
||||||
|
(function(parent, obj) {
|
||||||
|
var key, val, _results;
|
||||||
|
if (obj.length) {
|
||||||
|
return _config[parent] = obj[0];
|
||||||
|
} else if (typeof obj === 'object') {
|
||||||
|
_results = [];
|
||||||
|
for (key in obj) {
|
||||||
|
val = obj[key];
|
||||||
|
_results.push(arguments.callee(key, val));
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
} else {
|
||||||
|
return _config[parent] = obj;
|
||||||
|
}
|
||||||
|
})(null, config);
|
||||||
if (typeof GM_deleteValue === 'undefined') {
|
if (typeof GM_deleteValue === 'undefined') {
|
||||||
window.GM_setValue = function(name, value) {
|
window.GM_setValue = function(name, value) {
|
||||||
value = (typeof value)[0] + value;
|
value = (typeof value)[0] + value;
|
||||||
@ -269,11 +285,8 @@
|
|||||||
style.textContent = css;
|
style.textContent = css;
|
||||||
return $.append(d.head, style);
|
return $.append(d.head, style);
|
||||||
},
|
},
|
||||||
config: function(name, conf) {
|
config: function(name) {
|
||||||
if (conf == null) {
|
return $.getValue(name, _config[name]);
|
||||||
conf = config.main.checkbox;
|
|
||||||
}
|
|
||||||
return $.getValue(name, conf[name][0]);
|
|
||||||
},
|
},
|
||||||
zeroPad: function(n) {
|
zeroPad: function(n) {
|
||||||
if (n < 10) {
|
if (n < 10) {
|
||||||
@ -1674,12 +1687,12 @@
|
|||||||
conf = config.updater.checkbox;
|
conf = config.updater.checkbox;
|
||||||
for (name in conf) {
|
for (name in conf) {
|
||||||
title = conf[name][1];
|
title = conf[name][1];
|
||||||
checked = $.config(name, conf) ? "checked" : "";
|
checked = $.config(name) ? "checked" : "";
|
||||||
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>";
|
||||||
}
|
}
|
||||||
name = 'Auto Update This';
|
name = 'Auto Update This';
|
||||||
title = 'Controls whether *this* thread auotmatically updates or not';
|
title = 'Controls whether *this* thread auotmatically updates or not';
|
||||||
checked = $.config('Auto Update', conf) ? 'checked' : '';
|
checked = $.config('Auto Update') ? 'checked' : '';
|
||||||
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>";
|
||||||
dialog = ui.dialog('updater', {
|
dialog = ui.dialog('updater', {
|
||||||
bottom: '0px',
|
bottom: '0px',
|
||||||
@ -1710,7 +1723,7 @@
|
|||||||
},
|
},
|
||||||
autoUpdate: function(e) {
|
autoUpdate: function(e) {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
updater.timer = $.config('Interval', config.updater);
|
updater.timer = $.config('Interval');
|
||||||
return $('#timer').textContent = updater.timer;
|
return $('#timer').textContent = updater.timer;
|
||||||
} else {
|
} else {
|
||||||
return updater.timer = null;
|
return updater.timer = null;
|
||||||
|
|||||||
@ -39,6 +39,18 @@ config =
|
|||||||
'Auto Update': [false, 'Automatically fetch new posts']
|
'Auto Update': [false, 'Automatically fetch new posts']
|
||||||
'Interval': 30
|
'Interval': 30
|
||||||
|
|
||||||
|
# create 'global' options, no namespacing
|
||||||
|
_config = {}
|
||||||
|
((parent, obj) ->
|
||||||
|
if obj.length #array
|
||||||
|
_config[parent] = obj[0]
|
||||||
|
else if typeof obj is 'object'
|
||||||
|
for key, val of obj
|
||||||
|
arguments.callee key, val
|
||||||
|
else #constant
|
||||||
|
_config[parent] = obj
|
||||||
|
) null, config
|
||||||
|
|
||||||
#x-browser
|
#x-browser
|
||||||
if typeof GM_deleteValue is 'undefined'
|
if typeof GM_deleteValue is 'undefined'
|
||||||
window.GM_setValue = (name, value) ->
|
window.GM_setValue = (name, value) ->
|
||||||
@ -162,8 +174,8 @@ $.extend $,
|
|||||||
style.type = 'text/css'
|
style.type = 'text/css'
|
||||||
style.textContent = css
|
style.textContent = css
|
||||||
$.append d.head, style
|
$.append d.head, style
|
||||||
config: (name, conf=config.main.checkbox) ->
|
config: (name) ->
|
||||||
$.getValue name, conf[name][0]
|
$.getValue name, _config[name]
|
||||||
zeroPad: (n) ->
|
zeroPad: (n) ->
|
||||||
if n < 10 then '0' + n else n
|
if n < 10 then '0' + n else n
|
||||||
x: (path, root=d.body) ->
|
x: (path, root=d.body) ->
|
||||||
@ -1305,12 +1317,12 @@ updater =
|
|||||||
conf = config.updater.checkbox
|
conf = config.updater.checkbox
|
||||||
for name of conf
|
for name of conf
|
||||||
title = conf[name][1]
|
title = conf[name][1]
|
||||||
checked = if $.config name, conf 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>"
|
||||||
|
|
||||||
name = 'Auto Update This'
|
name = 'Auto Update This'
|
||||||
title = 'Controls whether *this* thread auotmatically updates or not'
|
title = 'Controls whether *this* thread auotmatically updates or not'
|
||||||
checked = if $.config 'Auto Update', conf then 'checked' else ''
|
checked = if $.config 'Auto Update' 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>"
|
||||||
|
|
||||||
dialog = ui.dialog 'updater', bottom: '0px', right: '0px', html
|
dialog = ui.dialog 'updater', bottom: '0px', right: '0px', html
|
||||||
@ -1338,7 +1350,7 @@ updater =
|
|||||||
$('#timer').textContent = 'Thread Updater'
|
$('#timer').textContent = 'Thread Updater'
|
||||||
autoUpdate: (e) ->
|
autoUpdate: (e) ->
|
||||||
if @checked
|
if @checked
|
||||||
updater.timer = $.config 'Interval', config.updater
|
updater.timer = $.config 'Interval'
|
||||||
$('#timer').textContent = updater.timer
|
$('#timer').textContent = updater.timer
|
||||||
else
|
else
|
||||||
updater.timer = null
|
updater.timer = null
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user