From: Ardis Lu Date: Sat, 13 Apr 2024 06:31:34 +0000 (-0700) Subject: Fix regression where custom functions are overwritten X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=d29c0e7de24ee20bd96228b4fbd258394fdb84a6;p=erc-165-calculator Fix regression where custom functions are overwritten Must only set customFunctions if the immediately previous selection was "Custom", otherwise it will be overwritten if switching between different non-custom selections. --- diff --git a/index.html b/index.html index 5ff22a9..c7d2620 100644 --- a/index.html +++ b/index.html @@ -154,27 +154,29 @@ select.insertAdjacentHTML('beforeend', ``); } + let lastSelection = 'Custom'; let customFunctions = ''; select.addEventListener('change', e => { const selection = e.target.value; + if (lastSelection === 'Custom') { + customFunctions = textarea.value; + textarea.readOnly = true; + } + lastSelection = selection; + if (selection === 'Custom') { textarea.value = customFunctions; textarea.readOnly = false; form.requestSubmit(); } + else if (typeof interfaces[selection] === 'string') { + textarea.value = 'No functions: the interface ID for this ERC is hardcoded.'; + output.textContent = interfaces[selection]; + } else { - customFunctions = textarea.value; - textarea.readOnly = true; - - if (typeof interfaces[selection] === 'string') { - textarea.value = 'No functions: the interface ID for this ERC is hardcoded.'; - output.textContent = interfaces[selection]; - } - else { - textarea.value = interfaces[selection].join('\n'); - form.requestSubmit(); - } + textarea.value = interfaces[selection].join('\n'); + form.requestSubmit(); } });