diff --git a/js/dictionaryBuilder.js b/js/dictionaryBuilder.js
index c6cbad3..7f19dde 100644
--- a/js/dictionaryBuilder.js
+++ b/js/dictionaryBuilder.js
@@ -34,7 +34,7 @@ function AddWord() {
var partOfSpeech = htmlEntities(document.getElementById("partOfSpeech").value).trim();
var simpleDefinition = htmlEntities(document.getElementById("simpleDefinition").value).trim();
var longDefinition = htmlEntities(document.getElementById("longDefinition").value);
- var editIndex = htmlEntities(document.getElementById("editIndex").value);
+ // var editIndex = htmlEntities(document.getElementById("editIndex").value);
var errorMessageArea = document.getElementById("errorMessage");
var errorMessage = "";
var updateConflictArea = document.getElementById("updateConflict");
@@ -42,23 +42,7 @@ function AddWord() {
if (word != "" && (simpleDefinition != "" || longDefinition != "")) {
var wordIndex = (!currentDictionary.settings.allowDuplicates) ? WordIndex(word) : -1;
- if (editIndex != "") {
- if (WordAtIndexWasChanged(editIndex, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition)) {
- document.getElementById("editWordButtonArea").style.display = "none";
- DisableForm();
- updateConflictArea.style.display = "block";
- updateConflictArea.innerHTML = "Do you really want to change the word \"" + currentDictionary.words[parseInt(editIndex)].name + "\" to what you have set above?";
- updateConflictArea.innerHTML += '';
- updateConflictArea.innerHTML += '';
- } else {
- errorMessage = "No change has been made to \"" + word + "\"";
- if (currentDictionary.words[parseInt(editIndex)].name != word) {
- errorMessage += ". (Your dictionary is currently set to ignore case.)"
- }
- }
- } else if (wordIndex >= 0) {
+ if (wordIndex >= 0) {
if (WordAtIndexWasChanged(wordIndex, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition)) {
document.getElementById("newWordButtonArea").style.display = "none";
DisableForm();
@@ -74,7 +58,7 @@ function AddWord() {
updateConflictText += '';
- updateConflictText += ' ';
+ updateConflictText += ' ';
updateConflictArea.innerHTML = updateConflictText;
} else {
@@ -107,23 +91,70 @@ function AddWord() {
errorMessageArea.innerHTML = errorMessage;
}
-function EditWord(index) {
- SaveScroll();
- if (wordFormIsLocked()) {
- window.scroll(0, 0);
+function ShowWordEditForm(index) {
+ var indexString = index.toString(); // Variable for reduced processing
+ var word = currentDictionary.words[index]; // Reference for easier reading
+ var editForm = '
';
+
+ document.getElementById("entry" + indexString).innerHTML = editForm;
+
+ SetPartsOfSpeech("partOfSpeech" + indexString);
+}
+
+function CancelEditForm(index) {
+ document.getElementById("entry" + index.toString()).innerHTML = DictionaryEntry(index).replace("", "").replace("", "");
+}
+
+function EditWord(indexString) {
+ var word = htmlEntities(document.getElementById("word" + indexString).value).trim();
+ var pronunciation = htmlEntities(document.getElementById("pronunciation" + indexString).value).trim();
+ var partOfSpeech = htmlEntities(document.getElementById("partOfSpeech" + indexString).value).trim();
+ var simpleDefinition = htmlEntities(document.getElementById("simpleDefinition" + indexString).value).trim();
+ var longDefinition = htmlEntities(document.getElementById("longDefinition" + indexString).value);
+ // var editIndex = htmlEntities(document.getElementById("editIndex").value);
+ var errorMessageArea = document.getElementById("errorMessage" + indexString);
+ var errorMessage = "";
+ var updateConflictArea = document.getElementById("updateConflict" + indexString);
+
+ if (WordAtIndexWasChanged(indexString, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition)) {
+ document.getElementById("editWordButtonArea" + indexString).style.display = "none";
+ DisableForm();
+ updateConflictArea.style.display = "block";
+ updateConflictArea.innerHTML = "Do you really want to change the word \"" + currentDictionary.words[parseInt(indexString)].name + "\" to what you have set above?";
+ updateConflictArea.innerHTML += '';
+ updateConflictArea.innerHTML += '';
+ } else {
+ errorMessage = "No change has been made to \"" + word + "\"";
+ if (currentDictionary.words[parseInt(indexString)].name != word) {
+ errorMessage += ". (Your dictionary is currently set to ignore case.)";
+ }
}
- ClearForm();
-
- document.getElementById("editIndex").value = index.toString();
- document.getElementById("word").value = htmlEntitiesParse(currentDictionary.words[index].name);
- document.getElementById("pronunciation").value = htmlEntitiesParse(currentDictionary.words[index].pronunciation);
- document.getElementById("partOfSpeech").value = htmlEntitiesParse(currentDictionary.words[index].partOfSpeech);
- document.getElementById("simpleDefinition").value = htmlEntitiesParse(currentDictionary.words[index].simpleDefinition);
- document.getElementById("longDefinition").value = htmlEntitiesParse(currentDictionary.words[index].longDefinition);
-
- document.getElementById("newWordButtonArea").style.display = "none";
- document.getElementById("editWordButtonArea").style.display = "block";
+ errorMessageArea.innerHTML = errorMessage;
}
function UpdateWord(wordIndex, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition) {
@@ -219,7 +250,7 @@ function ShowDictionary() {
function DictionaryEntry(itemIndex) {
displayPublic = (typeof displayPublic !== 'undefined' && displayPublic != null) ? displayPublic : false;
- var entryText = "🔗";
+ var entryText = "🔗";
var searchTerm = regexParseForSearch(document.getElementById("searchBox").value);
var searchByWord = document.getElementById("searchOptionWord").checked;
@@ -290,7 +321,7 @@ function DictionaryEntry(itemIndex) {
function ManagementArea(itemIndex) {
var managementHTML = "";
- managementHTML += "
Edit";
+ managementHTML += "
Edit";
managementHTML += "
Delete";
managementHTML += "
Are you sure you want to delete this entry?
";
@@ -387,7 +418,7 @@ function SaveAndUpdateDictionary(keepFormContents) {
if (!keepFormContents) {
ClearForm();
}
- CloseUpdateConflictArea('newWordButtonArea');
+ CloseUpdateConflictArea('newWordButtonArea', 'updateConflict');
}
function SaveDictionary(sendToDatabase, sendWords) {
diff --git a/js/ui.js b/js/ui.js
index 2956ef2..bc069b6 100644
--- a/js/ui.js
+++ b/js/ui.js
@@ -369,12 +369,12 @@ function LockWordForm() {
wordForm.removeAttribute('style');
}
-function CloseUpdateConflictArea(displayId) {
+function CloseUpdateConflictArea(displayId, hideId) {
displayId = (typeof displayId !== 'undefined' && displayId != null) ? displayId : false;
if (displayId != false) {
document.getElementById(displayId).style.display = "block";
}
- document.getElementById("updateConflict").style.display = "none";
+ document.getElementById(hideId).style.display = "none";
EnableForm();
}
@@ -579,19 +579,18 @@ function TogglePublicLink() {
}
}
-function SetPartsOfSpeech () {
- var partsOfSpeechSelect = document.getElementById("partOfSpeech");
+function SetPartsOfSpeech (selectId) {
+ selectId = (typeof selectId !== 'undefined') ? selectId : "partOfSpeech";
+ var partsOfSpeechSelect = document.getElementById(selectId);
var wordFilterOptions = document.getElementById("filterOptions");
var wordFiltersSelected = GetSelectedFilters();
// Clear parts of speech.
- if (partsOfSpeechSelect.options.length > 0) {
- for (var i = partsOfSpeechSelect.options.length - 1; i >= 0; i--) {
- partsOfSpeechSelect.removeChild(partsOfSpeechSelect.options[i]);
- }
- wordFilterOptions.innerHTML = "";
+ for (var i = partsOfSpeechSelect.options.length - 1; i >= 0; i--) {
+ partsOfSpeechSelect.removeChild(partsOfSpeechSelect.options[i]);
}
+ wordFilterOptions.innerHTML = "";
// Rebuild parts of speech
var newPartsOfSpeech = htmlEntitiesParse(currentDictionary.settings.partsOfSpeech).trim().split(",");