From 1c69ae5c9392c9c42737767f0213977dea9450d5 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 24 Jul 2011 07:15:55 +0200 Subject: [PATCH] Dynamic updater's settings --- 4chan_x.user.js | 43 ++++++++++++++++++++++++------------------- changelog | 4 ++++ script.coffee | 33 ++++++++++++++++----------------- 3 files changed, 44 insertions(+), 36 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 90d56930a..4567fc288 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1561,7 +1561,7 @@ }; updater = { init: function() { - var autoUpT, checkbox, checked, dialog, html, input, interva, name, title, updNow, verbose, _i, _len, _ref; + var checkbox, checked, dialog, html, input, name, title, _i, _len, _ref; html = "
-" + conf['Interval'] + "
"; checkbox = config.updater.checkbox; for (name in checkbox) { @@ -1575,29 +1575,34 @@ bottom: '0', right: '0' }, html); - _ref = $$('input[type=checkbox]', dialog); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - input = _ref[_i]; - $.bind(input, 'click', $.cb.checked); - } - verbose = $('input[name=Verbose]', dialog); - autoUpT = $('input[name$=This]', dialog); - interva = $('input[name=Interval]', dialog); - updNow = $('input[type=button]', dialog); - $.bind(verbose, 'click', updater.cb.verbose); - $.bind(autoUpT, 'click', updater.cb.autoUpdate); - $.bind(interva, 'change', updater.cb.interval); - $.bind(interva, 'change', $.cb.value); - $.bind(updNow, 'click', updater.updateNow); updater.count = $('#count', dialog); updater.timer = $('#timer', dialog); - $.append(d.body, dialog); - updater.cb.verbose.call(verbose); - return updater.cb.autoUpdate.call(autoUpT); + _ref = $$('input', dialog); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + input = _ref[_i]; + if (input.type === 'checkbox') { + $.bind(input, 'click', $.cb.checked); + $.bind(input, 'click', function() { + return conf[this.name] = this.checked; + }); + if (input.name === 'Verbose') { + $.bind(input, 'click', updater.cb.verbose); + updater.cb.verbose.call(input); + } else if (input.name === 'Auto Update This') { + $.bind(input, 'click', updater.cb.autoUpdate); + updater.cb.autoUpdate.call(input); + } + } else if (input.name === 'Interval') { + $.bind(input, 'change', updater.cb.interval); + } else if (input.type === 'button') { + $.bind(input, 'click', updater.updateNow); + } + } + return $.append(d.body, dialog); }, cb: { verbose: function() { - if (conf['Verbose'] = this.checked) { + if (conf['Verbose']) { updater.count.textContent = '+0'; return $.show(updater.timer); } else { diff --git a/changelog b/changelog index bb4fce7a7..2fa1a4866 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,8 @@ github +- mayhem: + - Make updater's settings dynamic + +2.16.1 - mayhem: - fix updater's custom settings diff --git a/script.coffee b/script.coffee index b6731d403..5b67b814f 100644 --- a/script.coffee +++ b/script.coffee @@ -1283,30 +1283,29 @@ updater = dialog = ui.dialog 'updater', bottom: '0', right: '0', html - for input in $$ 'input[type=checkbox]', dialog - $.bind input, 'click', $.cb.checked - - verbose = $ 'input[name=Verbose]', dialog - autoUpT = $ 'input[name$=This]', dialog - interva = $ 'input[name=Interval]', dialog - updNow = $ 'input[type=button]', dialog - $.bind verbose, 'click', updater.cb.verbose - $.bind autoUpT, 'click', updater.cb.autoUpdate - $.bind interva, 'change', updater.cb.interval - $.bind interva, 'change', $.cb.value - $.bind updNow, 'click', updater.updateNow - updater.count = $ '#count', dialog updater.timer = $ '#timer', dialog - $.append d.body, dialog + for input in $$ 'input', dialog + if input.type is 'checkbox' + $.bind input, 'click', $.cb.checked + $.bind input, 'click', -> conf[@name] = @checked + if input.name is 'Verbose' + $.bind input, 'click', updater.cb.verbose + updater.cb.verbose.call input + else if input.name is 'Auto Update This' + $.bind input, 'click', updater.cb.autoUpdate + updater.cb.autoUpdate.call input + else if input.name is 'Interval' + $.bind input, 'change', updater.cb.interval + else if input.type is 'button' + $.bind input, 'click', updater.updateNow - updater.cb.verbose.call verbose - updater.cb.autoUpdate.call autoUpT + $.append d.body, dialog cb: verbose: -> - if conf['Verbose'] = @checked + if conf['Verbose'] updater.count.textContent = '+0' $.show updater.timer else