diff options
| author | Jakob L. Kreuze | 2026-10-16 12:52:40 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze | 2026-10-16 12:52:40 -0400 |
| commit | 319cc47ae6abafd2458cf9a014b791f14419d7ea (patch) | |
| tree | 8518a9d31e34fc0819bd6b083e1d73887eb5e4e5 | |
| parent | 00b5b3541c3b960b7a2f5ff69b5cc7e9a4582496 (diff) | |
Implement runtime-configurable features
In particular these things can now be enabled or disabled depending on
the user's requirements:
- A netbanner (previously implemented, later removed, hard-coded into fork)
- Interactions with a scheduler server (previously implemented in branch cgi-storage)
| -rw-r--r-- | srs-anywhere-config.js | 21 | ||||
| -rw-r--r-- | srs-anywhere-network.js | 24 | ||||
| -rw-r--r-- | srs-anywhere.css | 33 | ||||
| -rw-r--r-- | srs-anywhere.html | 13 | ||||
| -rw-r--r-- | srs-anywhere.js | 25 |
5 files changed, 110 insertions, 6 deletions
diff --git a/srs-anywhere-config.js b/srs-anywhere-config.js new file mode 100644 index 0000000..77c5332 --- /dev/null +++ b/srs-anywhere-config.js @@ -0,0 +1,21 @@ +/* Copyright © 2025 - 2026 Jakob L. Kreuze + + This file is part of SRS Anywhere. + + SRS Anywhere is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + SRS Anywhere is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public + License along with SRS Anywhere. If not, see <https://www.gnu.org/licenses/>. */ + +const SRS_ANYWHERE_CONFIG = { + banner: false, + network: false +}; diff --git a/srs-anywhere-network.js b/srs-anywhere-network.js index 8fe925b..8d972cc 100644 --- a/srs-anywhere-network.js +++ b/srs-anywhere-network.js @@ -1,4 +1,4 @@ -/* Copyright © 2025 Jakob L. Kreuze +/* Copyright © 2025 - 2026 Jakob L. Kreuze This file is part of SRS Anywhere. @@ -15,7 +15,21 @@ You should have received a copy of the GNU Affero General Public License along with SRS Anywhere. If not, see <https://www.gnu.org/licenses/>. */ -window.addEventListener("load", () => { +function enableInputs() { + const target = document.querySelector('#cards-input'); + const el1 = document.createElement('input'); + el1.type = "text"; + el1.id = "network-password"; + const el2 = document.createElement('button'); + el2.id = "open-network"; + el2.innerText = "Go!"; + const el3 = document.createElement('br'); + target.before(el1, el2, el3); +} + +function enableNetworkFeatures() { + enableInputs(); + const passwordField = document.getElementById('network-password'); const urlParams = new URLSearchParams(window.location.search); @@ -47,6 +61,12 @@ window.addEventListener("load", () => { }; xhr.send(); }); +} + +window.addEventListener("load", () => { + if (SRS_ANYWHERE_CONFIG.network) { + enableNetworkFeatures(); + } }); const downloadJSONOld = downloadJSON; diff --git a/srs-anywhere.css b/srs-anywhere.css index bcef4fb..78e6e2d 100644 --- a/srs-anywhere.css +++ b/srs-anywhere.css @@ -155,3 +155,36 @@ textarea { #flashcard img { width: 100%; } + +* { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +.banner { + position: fixed; + width: 100%; + color: white; + text-align: center; + font-weight: bold; + line-height: 16px; + font-size: 12px; + z-index: 100; +} + +.top-banner { + top: 0; + background-color: #008000; +} + +.bottom-banner { + bottom: 0; + background-color: #008000; +} + +.content { + padding: 20px; + max-width: 800px; + margin: auto; +} diff --git a/srs-anywhere.html b/srs-anywhere.html index 3897063..83b7633 100644 --- a/srs-anywhere.html +++ b/srs-anywhere.html @@ -8,9 +8,15 @@ <link rel="icon" href="srs-anywhere.ico"> </head> <body style="display: flex;"> - <div id="flashcard"> - <div id="flashcard-front"></div> - <div id="flashcard-back"></div> + <div class="banner top-banner" hidden>UNCLASSIFIED</div> + + <div class="banner bottom-banner" hidden>UNCLASSIFIED</div> + + <div class="content"> + <div id="flashcard"> + <div id="flashcard-front"></div> + <div id="flashcard-back"></div> + </div> </div> <div class="status-section"> @@ -76,6 +82,7 @@ <script src="srs-anywhere.js"></script> <script src="srs-anywhere-network.js"></script> + <script src="srs-anywhere-config.js"></script> <script src="srs-anywhere-custom-card-types.js"></script> </body> </html> diff --git a/srs-anywhere.js b/srs-anywhere.js index 8f77f02..1348a37 100644 --- a/srs-anywhere.js +++ b/srs-anywhere.js @@ -1,4 +1,4 @@ -/* Copyright © 2025 Jakob L. Kreuze +/* Copyright © 2025 - 2026 Jakob L. Kreuze This file is part of SRS Anywhere. @@ -482,3 +482,26 @@ window.addEventListener('keydown', (event) => { endReview(); } }); + +/*********************************************************************** + * Runtime configuration * + ***********************************************************************/ + +function enableClassificationBanner() { + console.log('here'); + const banners = document.querySelectorAll('div.banner'); + banners.forEach(banner => { + banner.removeAttribute('hidden'); + }); + + const buttonContainer = document.getElementById('button-container'); + if (buttonContainer) { + buttonContainer.style.bottom = '1rem'; + } +} + +window.addEventListener('load', () => { + if (SRS_ANYWHERE_CONFIG.banner) { + enableClassificationBanner(); + } +}); |