From a2b80dce048c2ea2ebb17c500ef317831e61ba65 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 20 Jul 2019 13:52:08 -0700 Subject: [PATCH] Make this settings code easier to maintain. --- src/General/Settings.coffee | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 133164d82..cccf7968b 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -561,10 +561,13 @@ Settings = $.id('lastarchivecheck').textContent = 'never' items = {} - for name in ['archiveLists', 'archiveAutoUpdate', 'fourchanImageHost', 'captchaLanguage', 'captchaServiceDomain', 'boardnav', 'time', 'timeLocale', 'backlink', 'pastedname', 'fileInfo', 'QR.personas', 'favicon', 'usercss', 'customCooldown', 'jsWhitelist'] + for name, input of inputs when name not in ['captchaServiceKey', 'Interval', 'Custom CSS'] items[name] = Conf[name] - input = inputs[name] - event = if name in ['archiveLists', 'archiveAutoUpdate', 'QR.personas', 'favicon', 'usercss'] then 'change' else 'input' + event = if ( + input.nodeName is 'SELECT' or + input.type in ['checkbox', 'radio'] or + (input.nodeName is 'TEXTAREA' and name not of Settings) + ) then 'change' else 'input' $.on input, event, $.cb[if input.type is 'checkbox' then 'checked' else 'value'] $.on input, event, Settings[name] if name of Settings