@@ -20,7 +20,7 @@ const DIGITS = "0123456789";
2020const DEFAULT_SYMBOLS = "!@#$%^&*()-_=+[]{};:,.<>/?" ;
2121
2222// ------------------------------
23- // WORD LISTS (STEP 2)
23+ // WORD LISTS
2424// ------------------------------
2525let WORD_ADJECTIVES = [ ] ;
2626let WORD_NOUNS = [ ] ;
@@ -218,7 +218,7 @@ function generateUserIdList(options, count) {
218218}
219219
220220// ------------------------------
221- // WORD NORMALIZATION (STEP 3)
221+ // WORD NORMALIZATION
222222// ------------------------------
223223function normalizeWord ( raw ) {
224224 return raw
@@ -228,7 +228,7 @@ function normalizeWord(raw) {
228228}
229229
230230// ------------------------------
231- // WORDS MODE GENERATOR (STEP 3)
231+ // WORDS MODE GENERATOR
232232// ------------------------------
233233function generateWordsModeId ( options ) {
234234 const {
@@ -359,7 +359,7 @@ const uidWordsDigitsCount = document.getElementById("uidWordsDigitsCount");
359359const uidWordsMaxLength = document . getElementById ( "uidWordsMaxLength" ) ;
360360
361361// ------------------------------
362- // PERSISTENCE HELPERS (unchanged )
362+ // PERSISTENCE HELPERS (STEP 4 )
363363// ------------------------------
364364function savePasswordSettings ( ) {
365365 const config = {
@@ -391,19 +391,22 @@ function saveUserIdSettings() {
391391 const config = {
392392 mode : uidMode . value ,
393393
394+ // CVC mode
394395 syllables : Number ( uidSyllables . value ) ,
395396 addDigits : uidAddDigits . checked ,
396397 digitsCount : Number ( uidDigitsCount . value ) ,
397398 addSuffix : uidAddSuffix . checked ,
398399 suffix : uidSuffix . value ,
399400 maxLength : Number ( uidMaxLength . value ) ,
400401
402+ // Words mode
401403 wordsCount : Number ( uidWordsCount . value ) ,
402404 wordsSeparator : uidWordsSeparator . value ,
403405 wordsAddDigits : uidWordsAddDigits . checked ,
404406 wordsDigitsCount : Number ( uidWordsDigitsCount . value ) ,
405407 wordsMaxLength : Number ( uidWordsMaxLength . value ) ,
406408
409+ // Shared
407410 count : Number ( uidCount . value )
408411 } ;
409412
@@ -423,7 +426,7 @@ function loadUserIdSettings() {
423426}
424427
425428// ------------------------------
426- // RESTORE UI STATE
429+ // RESTORE UI STATE (STEP 4)
427430// ------------------------------
428431function showRestoredNotice ( text ) {
429432 const el = document . getElementById ( "restoreNotice" ) ;
@@ -466,114 +469,10 @@ function restoreUserIdUI() {
466469 return ;
467470 }
468471
472+ // Mode
469473 if ( config . mode === "cvc" || config . mode === "words" ) {
470474 uidMode . value = config . mode ;
471475 }
472476
473- if ( config . syllables === 2 || config . syllables === 3 ) {
474- uidSyllables . value = config . syllables ;
475- }
476-
477- uidAddDigits . checked = ! ! config . addDigits ;
478- uidDigitsCount . value = config . digitsCount || 2 ;
479-
480- uidAddSuffix . checked = ! ! config . addSuffix ;
481- uidSuffix . value = config . suffix || "" ;
482-
483- uidMaxLength . value = config . maxLength || 15 ;
484-
485- if ( config . wordsCount === 2 || config . wordsCount === 3 ) {
486- uidWordsCount . value = config . wordsCount ;
487- }
488-
489- if ( [ "_" , "." , "-" , "none" ] . includes ( config . wordsSeparator ) ) {
490- uidWordsSeparator . value = config . wordsSeparator ;
491- }
492-
493- uidWordsAddDigits . checked = ! ! config . wordsAddDigits ;
494- uidWordsDigitsCount . value = config . wordsDigitsCount || 2 ;
495-
496- uidWordsMaxLength . value = config . wordsMaxLength || 20 ;
497-
498- uidCount . value = config . count || 10 ;
499-
500- uidDigitsCount . disabled = ! uidAddDigits . checked ;
501- uidSuffix . disabled = ! uidAddSuffix . checked ;
502-
503- updateUserIdModeUI ( ) ;
504-
505- showRestoredNotice ( "User ID settings restored from previous session" ) ;
506- }
507-
508- // ------------------------------
509- // UI STATE
510- // ------------------------------
511- function updateIcloudUIState ( ) {
512- const on = icloudPresetCheckbox . checked ;
513-
514- lengthInput . disabled = on ;
515- lowercaseCheckbox . disabled = on ;
516- uppercaseCheckbox . disabled = on ;
517- digitsCheckbox . disabled = on ;
518- symbolsCheckbox . disabled = on ;
519- customSymbolsInput . disabled = on ;
520-
521- presetInfo . textContent = on ? "iCloud preset is active: settings are fixed." : "" ;
522- }
523-
524- // ------------------------------
525- // USER ID MODE UI (STEP 2)
526- // ------------------------------
527- function updateUserIdModeUI ( ) {
528- const mode = uidMode . value ;
529-
530- if ( mode === "cvc" ) {
531- uidCvcControls . style . display = "" ;
532- uidWordsControls . style . display = "none" ;
533- } else {
534- uidCvcControls . style . display = "none" ;
535- uidWordsControls . style . display = "" ;
536- }
537- }
538-
539- // ------------------------------
540- // LOAD WORD LISTS (STEP 2)
541- // ------------------------------
542- async function loadWordLists ( ) {
543- try {
544- const [ adjsRes , nounsRes ] = await Promise . all ( [
545- fetch ( "data/adjs.json" ) ,
546- fetch ( "data/nouns.json" )
547- ] ) ;
548-
549- if ( ! adjsRes . ok || ! nounsRes . ok ) {
550- throw new Error ( "Network error" ) ;
551- }
552-
553- const adjsJson = await adjsRes . json ( ) ;
554- const nounsJson = await nounsRes . json ( ) ;
555-
556- WORD_ADJECTIVES = ( adjsJson . adjs || adjsJson )
557- . map ( normalizeWord )
558- . filter ( Boolean ) ;
559-
560- WORD_NOUNS = ( nounsJson . nouns || nounsJson )
561- . map ( normalizeWord )
562- . filter ( Boolean ) ;
563-
564- wordsLoaded = true ;
565- } catch ( e ) {
566- console . error ( "Failed to load word lists" , e ) ;
567- uidError . textContent = "Could not load word lists. Please refresh the page." ;
568- }
569- }
570-
571- // ------------------------------
572- // PASSWORD GENERATE HANDLER
573- // ------------------------------
574- function handleGenerate ( ) {
575- if ( icloudPresetCheckbox . checked ) {
576- presetInfo . textContent = "iCloud preset is active: length and character sets are fixed." ;
577-
578- const password = generateIcloudPassword ( ) ;
579- passwordInput
477+ // CVC mode
478+ if ( config . syll
0 commit comments