mirror of
https://github.com/NovaGM/Modules.git
synced 2024-08-14 22:47:01 +00:00
Updated Module Settings Experiment
This commit is contained in:
parent
e1667e6865
commit
04e817908e
3 changed files with 28 additions and 5 deletions
|
@ -22,7 +22,6 @@ 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);
|
||||
|
||||
|
@ -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);
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
|
||||
"authors": ["186496078273708033"],
|
||||
|
||||
"version": "1.0.0"
|
||||
"version": "1.1.0"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
]);
|
||||
|
|
Loading…
Reference in a new issue