From f881b4360c64b875841195e94f63ebc2dd733073 Mon Sep 17 00:00:00 2001 From: Chisel Date: Mon, 22 May 2023 21:42:45 +0100 Subject: [PATCH] update web page defaults for new 'sample' world --- www/custom.js | 30 ++++++++++++++++++++++++------ www/index.html | 12 +++++++----- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/www/custom.js b/www/custom.js index de1d132c..3e0049cc 100644 --- a/www/custom.js +++ b/www/custom.js @@ -17,7 +17,10 @@ document.addEventListener('DOMContentLoaded', function () { /* find the .needsEasyPrint class elements */ document.querySelectorAll('.needs-easyprint').forEach((dependant) => { /* if the selected value is "EasyPrint" */ - if (event.target.value == 'easyprint') { + if ( + event.target.value == 'easyprint' || + event.target.value == 'sample' + ) { /* enable the element */ dependant.disabled = false; } else { @@ -27,14 +30,29 @@ document.addEventListener('DOMContentLoaded', function () { }); }); - /* only force the 'regular' option if we don't have a value in localStorage */ + /* do something sensible if we haven't got a value in localStorage */ if (!localStorage.getItem('scriptFormat')) { - console.debug('✎ setting scriptFormat to regular'); + console.debug('✎ setting scriptFormat to sample'); // set to "regular" by default; it's not what Chisel uses, but it's // probably the least surprising - match.value = 'regular'; - // trigger the change event to disable the other options - match.dispatchEvent(new Event('change')); + match.value = 'sample'; + + // selector and default value to choose + const defaults = { + '#scriptFormat': 'sample', + '#printFormat': 'doubleSided', + '#playerNightInfo': 'yes', + '#playerCount': 'sample', + }; + + // loop through the defaults and set them + for (const [selector, value] of Object.entries(defaults)) { + document.querySelector(selector).value = value; + // match the item, store the value in localStorage, and trigger a change event + let itemname = document.querySelector(selector).name; + localStorage.setItem(itemname, value); + document.querySelector(selector).dispatchEvent(new Event('change')); + } } }); diff --git a/www/index.html b/www/index.html index d1d8f8b8..71796a72 100644 --- a/www/index.html +++ b/www/index.html @@ -147,16 +147,15 @@
Format:
info @@ -214,13 +213,16 @@ + info