From d29c0e7de24ee20bd96228b4fbd258394fdb84a6 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Fri, 12 Apr 2024 23:31:34 -0700 Subject: [PATCH] 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. --- index.html | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) 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(); } }); -- 2.47.3