Skip to content

Commit f5a2b08

Browse files
authored
fix settings strings and tooltips (#2170)
1 parent 51e14ef commit f5a2b08

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

randomizer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ <h4>Your Most Recent Seed</h4>
712712
await import('./static/js/PlandoUtils.js');
713713

714714
// Nunjucks configuration after PlandoUtils.js is loaded
715-
var env = nunjucks.configure('/templates', { autoescape: true, web: { useCache: true } });
715+
var env = nunjucks.configure('/templates', { autoescape: false, web: { useCache: true } });
716716

717717
// Use the imported functions from PlandoUtils
718718
env.addFilter("plando_custom_loc_restrict", PlandoCustomLocationFilter);

static/js/generate_buttons.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,15 +496,22 @@ document.getElementById("import_settings").addEventListener("click", async funct
496496
}
497497

498498
const selector = document.getElementById(key);
499-
// Pre clear all selections
500-
for (let option of selector.options) {
501-
option.selected = false;
502-
}
499+
503500
if (selector.tagName === "SELECT") {
501+
let MapName = SettingsMap[key];
502+
// Flip the attributes so the value is the key and the key is the value
503+
let flipped = {};
504+
for (let key in MapName) {
505+
flipped[MapName[key]] = key;
506+
}
507+
// Pre clear all selections
508+
for (let option of selector.options) {
509+
option.selected = false;
510+
}
504511
settings[key].forEach(item => {
505-
let val = item - 1;
512+
// Find the selected option by the value of the option
506513
for (let option of selector.options) {
507-
if (option.value === Object.keys(SettingsMap[key])[val]) {
514+
if (option.value === flipped[item]) {
508515
option.selected = true;
509516
}
510517
}

static/js/initalize.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,15 +1168,22 @@ function preset_select_changed(event) {
11681168
}
11691169

11701170
const selector = document.getElementById(key);
1171-
// Pre clear all selections
1172-
for (let option of selector.options) {
1173-
option.selected = false;
1174-
}
1171+
11751172
if (selector.tagName === "SELECT") {
1173+
let MapName = SettingsMap[key];
1174+
// Flip the attributes so the value is the key and the key is the value
1175+
let flipped = {};
1176+
for (let key in MapName) {
1177+
flipped[MapName[key]] = key;
1178+
}
1179+
// Pre clear all selections
1180+
for (let option of selector.options) {
1181+
option.selected = false;
1182+
}
11761183
settings[key].forEach(item => {
1177-
let val = item - 1;
1184+
// Find the selected option by the value of the option
11781185
for (let option of selector.options) {
1179-
if (option.value === Object.keys(SettingsMap[key])[val]) {
1186+
if (option.value === flipped[item]) {
11801187
option.selected = true;
11811188
}
11821189
}
@@ -1186,7 +1193,6 @@ function preset_select_changed(event) {
11861193
const selector = document.getElementById(key);
11871194
if (selector.tagName === "SELECT" && key !== "random-weights") {
11881195
let MapName = SettingsMap[key];
1189-
let map_keys = MapName
11901196
// Flip the attributes so the value is the key and the key is the value
11911197
let flipped = {};
11921198
for (let key in MapName) {

static/js/spoiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const TIED_POOL_ITEMS = {
4848
async function generateSpoiler(spoiler) {
4949
/** Pass spoiler to the template and modify DOM with rendered content. */
5050
//const templateEnv = new nunjucks.Environment();
51-
var env = nunjucks.configure('/templates', { autoescape: true });
51+
var env = nunjucks.configure('/templates', { autoescape: false });
5252
env.addFilter("timeconvert", timectime);
5353
env.addFilter("filterId", filterId);
5454
env.addFilter("wothpathindex", getWotHPathIndex);

0 commit comments

Comments
 (0)