]> git.ardis.lu - erc-165-calculator/commitdiff
Fix regression where custom functions are overwritten
authorArdis Lu <ardisglu@gmail.com>
Sat, 13 Apr 2024 06:31:34 +0000 (23:31 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sat, 13 Apr 2024 06:31:34 +0000 (23:31 -0700)
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

index 5ff22a90dd74062754805a17ae5ce33d45e87dc0..c7d2620b25be0e4b05047f9122b13827d7e73614 100644 (file)
       select.insertAdjacentHTML('beforeend', `<option value="${i}">${i}</option>`);
     }
 
+    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();
       }
     });
 
This page took 0.037054 seconds and 4 git commands to generate.