diff --git a/index.html b/index.html index 18e9278..d29b96b 100644 --- a/index.html +++ b/index.html @@ -197,13 +197,13 @@ - Allow Duplicate Words - - Checking this box will allow any number of the exact same spelling of a word to be added + Prevent Duplicate Words + + Checking this box will prevent the creation of words with the exact same spelling. Words are Case-Sensitive - Checking this box will allow any words spelled the same but with different capitalization to be added. + Checking this box will allow the creation of words with the exact same spelling if their capitalization is different. Sort by Definition diff --git a/src/js/dictionaryManagement.js b/src/js/dictionaryManagement.js index 86592ac..f6dddda 100644 --- a/src/js/dictionaryManagement.js +++ b/src/js/dictionaryManagement.js @@ -28,8 +28,9 @@ export function openEditModal() { document.getElementById('editOrthography').value = orthography.notes; document.getElementById('editGrammar').value = grammar.notes; - document.getElementById('editAllowDuplicates').checked = allowDuplicates; + document.getElementById('editPreventDuplicates').checked = !allowDuplicates; document.getElementById('editCaseSensitive').checked = caseSensitive; + if (allowDuplicates) document.getElementById('editCaseSensitive').disabled = true; document.getElementById('editSortByDefinition').checked = sortByDefinition; document.getElementById('editIsComplete').checked = isComplete; document.getElementById('editIsPublic').checked = isPublic; @@ -54,7 +55,7 @@ export function save() { window.currentDictionary.details.orthography.notes = removeTags(document.getElementById('editOrthography').value.trim()); window.currentDictionary.details.grammar.notes = removeTags(document.getElementById('editGrammar').value.trim()); - window.currentDictionary.settings.allowDuplicates = document.getElementById('editAllowDuplicates').checked; + window.currentDictionary.settings.allowDuplicates = !document.getElementById('editPreventDuplicates').checked; window.currentDictionary.settings.caseSensitive = document.getElementById('editCaseSensitive').checked; window.currentDictionary.settings.sortByDefinition = document.getElementById('editSortByDefinition').checked; window.currentDictionary.settings.isComplete = document.getElementById('editIsComplete').checked; diff --git a/src/js/setupListeners.js b/src/js/setupListeners.js index 4da5ccb..ea79d3f 100644 --- a/src/js/setupListeners.js +++ b/src/js/setupListeners.js @@ -35,6 +35,7 @@ function setupDetailsTabs() { }); }); setupEditFormTabs(); + setupEditFormInteractions(); setupEditFormButtons(); } @@ -52,6 +53,22 @@ function setupEditFormTabs() { }); } +function setupEditFormInteractions() { + const preventDuplicatesBox = document.getElementById('editPreventDuplicates'); + preventDuplicatesBox.addEventListener('change', () => { + console.log('changed'); + const caseSensitiveBox = document.getElementById('editCaseSensitive'); + if (preventDuplicatesBox.checked) { + console.log('checked'); + caseSensitiveBox.disabled = false; + } else { + console.log('unchecked'); + caseSensitiveBox.disabled = true; + caseSensitiveBox.checked = false; + } + }); +} + function setupEditFormButtons() { document.getElementById('editSave').addEventListener('click', () => save()); document.getElementById('editSaveAndClose').addEventListener('click', () => saveAndClose());