aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob L. Kreuze2026-05-08 19:37:33 -0400
committerJakob L. Kreuze2026-05-08 19:37:33 -0400
commit54f92cc92cb25dea07f4325afc00cc64c67018c9 (patch)
treed3c6d115515aeb60e0136a6ff63c6024ee0da211
parentac7031554f3be0219e6fabf39e93ce8e001b69c8 (diff)
Just save the JSON file if there's an exception
-rw-r--r--srs-anywhere-network.js45
1 files changed, 17 insertions, 28 deletions
diff --git a/srs-anywhere-network.js b/srs-anywhere-network.js
index ac92a82..8fe925b 100644
--- a/srs-anywhere-network.js
+++ b/srs-anywhere-network.js
@@ -59,36 +59,25 @@ function downloadJSON(obj) {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status < 200 || xhr.status >= 300) {
reportException(xhr.statusText);
- }
- }
- };
- xhr.send(JSON.stringify(window.allCards, null, 2));
-
- const inputButton = document.getElementById('cards-input');
-
- const saveButton = document.createElement('button');
- saveButton.textContent = "Save JSON";
- saveButton.addEventListener('click', () => {
- // We move the logic inside the click listener so that it
- // always saves the CURRENT state of 'obj' if it has changed.
- const jsonString = JSON.stringify(obj, null, 2);
- const blob = new Blob([jsonString], { type: 'application/json' });
- const url = URL.createObjectURL(blob);
+ const jsonString = JSON.stringify(obj, null, 2);
+ const blob = new Blob([jsonString], { type: 'application/json' });
+ const url = URL.createObjectURL(blob);
- // Create a "ghost" anchor to trigger the download
- const a = document.createElement('a');
- a.href = url;
- a.download = 'data.json';
+ // Create a "ghost" anchor to trigger the download
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = 'data.json';
- // Append to body, click it, and remove it immediately
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
+ // Append to body, click it, and remove it immediately
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
- // Clean up the URL object to free up memory
- URL.revokeObjectURL(url);
- });
-
- inputButton.parentNode.insertBefore(saveButton, inputButton);
+ // Clean up the URL object to free up memory
+ URL.revokeObjectURL(url);
+ }
+ }
+ };
+ xhr.send(JSON.stringify(window.allCards, null, 2));
}

© 2015 - 2026 Jakob L. Kreuze