summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--srs-anywhere-network.js18
1 files changed, 17 insertions, 1 deletions
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));
+}