diff options
| author | Jakob L. Kreuze | 2026-10-16 13:41:53 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze | 2026-10-16 14:17:20 -0400 |
| commit | eaf3ff2a11b3134dc64f264ba9fbd7218901a9c2 (patch) | |
| tree | 4537bdb03d84694cabfd256780d61f7c6c743119 /srs-anywhere-network.js | |
| parent | 480242a932a58c4d9e8afe6179442dcb9912a2c2 (diff) | |
Diffstat (limited to 'srs-anywhere-network.js')
| -rw-r--r-- | srs-anywhere-network.js | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/srs-anywhere-network.js b/srs-anywhere-network.js index 40291a8..0decbdb 100644 --- a/srs-anywhere-network.js +++ b/srs-anywhere-network.js @@ -61,48 +61,48 @@ function enableNetworkFeatures() { }; xhr.send(); }); -} - -window.addEventListener("load", () => { - if (SRS_ANYWHERE_CONFIG.network) { - enableNetworkFeatures(); - } -}); -const downloadJSONOld = downloadJSON; -function downloadJSON(obj) { - try { - 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); + const downloadJSONOld = downloadJSON; + downloadJSON = (obj) => { + try { + 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); - 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); + // Clean up the URL object to free up memory + URL.revokeObjectURL(url); + } } - } - }; - xhr.send(JSON.stringify(window.allCards, null, 2)); - } catch (e) { - reportException(e); - downloadJSONOld(obj); + }; + xhr.send(JSON.stringify(window.allCards, null, 2)); + } catch (e) { + reportException(e); + downloadJSONOld(obj); + } } } + +window.addEventListener("load", () => { + if (SRS_ANYWHERE_CONFIG.network) { + enableNetworkFeatures(); + } +}); |