Skip to content

Commit b900fad

Browse files
feat: add persistence helpers for saving and loading password and user ID settings
1 parent 1cdc27f commit b900fad

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

script.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,61 @@ const VOWELS = "aeiouy";
1919
const DIGITS = "0123456789";
2020
const DEFAULT_SYMBOLS = "!@#$%^&*()-_=+[]{};:,.<>/?";
2121

22+
// ------------------------------
23+
// PERSISTENCE HELPERS
24+
// ------------------------------
25+
function savePasswordSettings() {
26+
const config = {
27+
length: Number(lengthInput.value),
28+
useLower: lowercaseCheckbox.checked,
29+
useUpper: uppercaseCheckbox.checked,
30+
useDigits: digitsCheckbox.checked,
31+
useSymbols: symbolsCheckbox.checked,
32+
customSymbols: customSymbolsInput.value,
33+
icloudPreset: icloudPresetCheckbox.checked
34+
};
35+
36+
localStorage.setItem("passwordSettings", JSON.stringify(config));
37+
}
38+
39+
function loadPasswordSettings() {
40+
const raw = localStorage.getItem("passwordSettings");
41+
if (!raw) return null;
42+
43+
try {
44+
return JSON.parse(raw);
45+
} catch {
46+
console.warn("Password settings corrupted — using defaults.");
47+
return null;
48+
}
49+
}
50+
51+
function saveUserIdSettings() {
52+
const config = {
53+
syllables: Number(uidSyllables.value),
54+
addDigits: uidAddDigits.checked,
55+
digitsCount: Number(uidDigitsCount.value),
56+
addSuffix: uidAddSuffix.checked,
57+
suffix: uidSuffix.value,
58+
maxLength: Number(uidMaxLength.value),
59+
count: Number(uidCount.value)
60+
};
61+
62+
localStorage.setItem("userIdSettings", JSON.stringify(config));
63+
}
64+
65+
function loadUserIdSettings() {
66+
const raw = localStorage.getItem("userIdSettings");
67+
if (!raw) return null;
68+
69+
try {
70+
return JSON.parse(raw);
71+
} catch {
72+
console.warn("User ID settings corrupted — using defaults.");
73+
return null;
74+
}
75+
}
76+
2277
// ------------------------------
2378
// RANDOM HELPERS
2479
// ------------------------------

0 commit comments

Comments
 (0)