diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-02-10 00:23:28 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-02-12 12:04:43 +0100 |
commit | 61e0d18ed045ed89ba9abd711fe7b1b5be2ec095 (patch) | |
tree | 7645dd219a8c2dfedda76463b46b245c8ea1bbb7 | |
parent | 38b70fbe8262f089e3ca8b20acd2b4f67d74523f (diff) | |
download | server-61e0d18ed045ed89ba9abd711fe7b1b5be2ec095.tar.gz |
Use exports.default_scenario to set default selection.
-rw-r--r-- | server.js | 2 | ||||
-rw-r--r-- | views/create.pug | 25 |
2 files changed, 18 insertions, 9 deletions
@@ -1808,7 +1808,7 @@ app.get("/create/:title_id", function (req, res) { user: req.user, title: title, limit: req.user ? check_create_game_limit(req.user) : null, - scenarios: RULES[title_id].scenarios, + rules: RULES[title_id], }) }) diff --git a/views/create.pug b/views/create.pug index d45903e..c4c5c2a 100644 --- a/views/create.pug +++ b/views/create.pug @@ -19,27 +19,36 @@ html p.error You are not logged in! form(method="post" action="/create/"+title.title_id) - if Array.isArray(scenarios) - if scenarios.length > 1 + if Array.isArray(rules.scenarios) + if rules.scenarios.length > 1 p Scenario: br select(name="scenario") - each scenario in scenarios - option(value=scenario)= scenario + each scenario in rules.scenarios + if scenario === rules.default_scenario + option(value=scenario selected)= scenario + else + option(value=scenario)= scenario else - input(type="hidden" name="scenario" value=scenarios[0]) + input(type="hidden" name="scenario" value=rules.scenarios[0]) else p Scenario: br select(name="scenario") - each list, name in scenarios + each list, name in rules.scenarios if name === "" each scenario in list - option(value=scenario)= scenario + if scenario === rules.default_scenario + option(value=scenario selected)= scenario + else + option(value=scenario)= scenario else optgroup(label=name) each scenario in list - option(value=scenario)= scenario + if scenario === rules.default_scenario + option(value=scenario selected)= scenario + else + option(value=scenario)= scenario | !{ title.create_html } |