diff options
| -rw-r--r-- | srs-anywhere-network.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/srs-anywhere-network.js b/srs-anywhere-network.js index e5bedff..3687402 100644 --- a/srs-anywhere-network.js +++ b/srs-anywhere-network.js @@ -16,6 +16,14 @@ License along with SRS Anywhere. If not, see <https://www.gnu.org/licenses/>. */ window.addEventListener("load", () => { + const passwordField = document.getElementById('network-password'); + + const urlParams = new URLSearchParams(window.location.search); + let password = localStorage.getItem('password') || urlParams.get('password'); + if (password) { + passwordField.value = password; + } + const btn = document.getElementById('open-network'); if (!btn) { console.warn('Button with id="open-network" not found.'); @@ -23,13 +31,14 @@ window.addEventListener("load", () => { } btn.addEventListener('click', function () { - const password = document.getElementById('network-password').value; + const password = passwordField.value; const xhr = new XMLHttpRequest(); xhr.open('GET', '/cgi-bin/deck.py', true); xhr.setRequestHeader('PASSWORD', password); xhr.onreadystatechange = function () { if (xhr.readyState === XMLHttpRequest.DONE) { if (xhr.status >= 200 && xhr.status < 300) { + localStorage.setItem('password', password); loadCards(JSON.parse(xhr.responseText)); } else { reportException(xhr.statusText); |