Skip to content

Commit dbeee48

Browse files
feat: implement UI restore logic for password and user ID generators
1 parent b900fad commit dbeee48

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

script.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,59 @@ function pick(pool) {
8787
return pool[randomInt(pool.length)];
8888
}
8989

90+
// ------------------------------
91+
// RESTORE UI STATE
92+
// ------------------------------
93+
function restorePasswordUI() {
94+
const config = loadPasswordSettings();
95+
if (!config) return;
96+
97+
// Validate before applying
98+
if (typeof config.length === "number" && config.length >= 4 && config.length <= 64) {
99+
lengthInput.value = config.length;
100+
}
101+
102+
lowercaseCheckbox.checked = !!config.useLower;
103+
uppercaseCheckbox.checked = !!config.useUpper;
104+
digitsCheckbox.checked = !!config.useDigits;
105+
symbolsCheckbox.checked = !!config.useSymbols;
106+
107+
if (typeof config.customSymbols === "string") {
108+
customSymbolsInput.value = config.customSymbols;
109+
}
110+
111+
icloudPresetCheckbox.checked = !!config.icloudPreset;
112+
113+
updateIcloudUIState();
114+
updateGenerateButtonState();
115+
116+
showRestoredNotice("Password settings restored from previous session");
117+
}
118+
119+
function restoreUserIdUI() {
120+
const config = loadUserIdSettings();
121+
if (!config) return;
122+
123+
if (config.syllables === 2 || config.syllables === 3) {
124+
uidSyllables.value = config.syllables;
125+
}
126+
127+
uidAddDigits.checked = !!config.addDigits;
128+
uidDigitsCount.value = config.digitsCount || 2;
129+
130+
uidAddSuffix.checked = !!config.addSuffix;
131+
uidSuffix.value = config.suffix || "";
132+
133+
uidMaxLength.value = config.maxLength || 15;
134+
uidCount.value = config.count || 10;
135+
136+
uidDigitsCount.disabled = !uidAddDigits.checked;
137+
uidSuffix.disabled = !uidAddSuffix.checked;
138+
139+
showRestoredNotice("User ID settings restored from previous session");
140+
}
141+
142+
90143
// ------------------------------
91144
// SYMBOL VALIDATION
92145
// ------------------------------

0 commit comments

Comments
 (0)