From cf33b0669d172b4142c4a63c43e928d35638d7c0 Mon Sep 17 00:00:00 2001 From: "Jakob L. Kreuze" Date: Fri, 5 Dec 2025 15:12:26 -0500 Subject: Enable saving via network --- srs-anywhere-network.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/srs-anywhere-network.js b/srs-anywhere-network.js index 4d8e187..e5bedff 100644 --- a/srs-anywhere-network.js +++ b/srs-anywhere-network.js @@ -17,13 +17,13 @@ window.addEventListener("load", () => { const btn = document.getElementById('open-network'); - const password = document.getElementById('network-password').value; if (!btn) { console.warn('Button with id="open-network" not found.'); return; } btn.addEventListener('click', function () { + const password = document.getElementById('network-password').value; const xhr = new XMLHttpRequest(); xhr.open('GET', '/cgi-bin/deck.py', true); xhr.setRequestHeader('PASSWORD', password); @@ -39,3 +39,19 @@ window.addEventListener("load", () => { xhr.send(); }); }); + +const downloadJSONOld = downloadJSON; +function downloadJSON() { + const password = document.getElementById('network-password').value; + const xhr = new XMLHttpRequest(); + xhr.open('POST', '/cgi-bin/deck.py', true); + xhr.setRequestHeader('PASSWORD', password); + xhr.onreadystatechange = function () { + if (xhr.readyState === XMLHttpRequest.DONE) { + if (xhr.status < 200 || xhr.status >= 300) { + reportException(xhr.statusText); + } + } + }; + xhr.send(JSON.stringify(window.allCards, null, 2)); +} -- cgit v1.3