diff --git a/settings-experiment/custom-settings.js b/settings-experiment/custom-settings.js index 3beffd0..ed89bc0 100644 --- a/settings-experiment/custom-settings.js +++ b/settings-experiment/custom-settings.js @@ -22,8 +22,7 @@ export function textInputField(text, subtext, placeholder, onApply, initialValue inputEl.classList.add('inputDefault-_djjkz', 'input-cIJ7To'); inputEl.placeholder = placeholder; inputEl.type = 'text'; - inputEl.value = initialValue ? initialValue : ''; - + inputWrapEl.appendChild(inputEl); // Button field @@ -47,6 +46,16 @@ export function textInputField(text, subtext, placeholder, onApply, initialValue dividerEl.classList.add('divider-3573oO', 'dividerDefault-3rvLe-'); dividerEl.style.marginTop = subtext ? '20px' : '45px'; + // Insertion checker + // A bit hacky... + // But works :) + let insertCheckId = setInterval(() => { + if (el.parentNode != null) { + inputEl.value = initialValue != undefined ? initialValue() : ''; + clearInterval(insertCheckId); + } + }, 1000); + el.appendChild(textEl); el.appendChild(buttonEl); el.appendChild(inputWrapEl); diff --git a/settings-experiment/goosemodModule.json b/settings-experiment/goosemodModule.json index 47a53df..c028a46 100644 --- a/settings-experiment/goosemodModule.json +++ b/settings-experiment/goosemodModule.json @@ -7,5 +7,5 @@ "authors": ["186496078273708033"], - "version": "1.0.0" + "version": "1.1.0" } diff --git a/settings-experiment/index.js b/settings-experiment/index.js index cd6c5c0..a5cb62b 100644 --- a/settings-experiment/index.js +++ b/settings-experiment/index.js @@ -6,6 +6,7 @@ import { textInputField } from './custom-settings.js'; let settingsPage = "Settings Experiment"; let settings; let defaultSettings = { + inputText: "Default value" }; export default { @@ -130,13 +131,26 @@ export default { { type: "custom", element: textInputField( - "Text Input", + "Text Input (static initial value)", "Prototype", "Placeholder", value => { showToast(`Text Input: ${value}`); }, - "Preset value" + () => "Preset value" + ) + }, + { + type: "custom", + element: textInputField( + "Text Input (loading from and saving to settings)", + "Prototype", + "Placeholder", + value => { + showToast(`Text Input: ${value}`); + settings.inputText = value; + }, + () => settings.inputText ) } ]);