Lexiconga/js/min/dictionaryBuilder.js

1 line
21 KiB
JavaScript
Raw Normal View History

function AddWord(){var e=htmlEntities(document.getElementById("word").value).trim(),t=htmlEntities(document.getElementById("pronunciation").value).trim(),n=htmlEntities(document.getElementById("partOfSpeech").value).trim(),i=htmlEntities(document.getElementById("simpleDefinition").value).trim(),r=htmlEntities(document.getElementById("longDefinition").value),o=htmlEntities(document.getElementById("editIndex").value),a=document.getElementById("errorMessage"),c="",s=document.getElementById("updateConflict");if(""==e||""==i&&""==r)""==e?(c+="Word cannot be blank",c+=""==i&&""==r?" and you need at least one definition.":"."):""==i&&""==r&&(c+="You need at least one definition.");else{var d=currentDictionary.settings.allowDuplicates?-1:WordIndex(e);if(""!=o)WordAtIndexWasChanged(o,e,t,n,i,r)?(document.getElementById("editWordButtonArea").style.display="none",DisableForm(),s.style.display="block",s.innerHTML="<span id='updateConflictMessage'>Do you really want to change the word \""+currentDictionary.words[parseInt(o)].name+'" to what you have set above?</span>',s.innerHTML+='<button type="button" id="updateConfirmButton" onclick="UpdateWord('+o+", '"+htmlEntities(e)+"', '"+htmlEntities(t)+"', '"+htmlEntities(n)+"', '"+htmlEntities(i)+"', '"+htmlEntities(r)+"'); return false;\">Yes, Update it</button>",s.innerHTML+='<button type="button" id="updateCancelButton" onclick="CloseUpdateConflictArea(\'editWordButtonArea\'); return false;">No, Leave it</button>'):(c='No change has been made to "'+e+'"',currentDictionary.words[parseInt(o)].name!=e&&(c+=". (Your dictionary is currently set to ignore case.)"));else if(d>=0)if(WordAtIndexWasChanged(d,e,t,n,i,r)){document.getElementById("newWordButtonArea").style.display="none",DisableForm(),s.style.display="block";var l="<span id='updateConflictMessage'>\""+e+'" is already in the dictionary';l+=currentDictionary.words[d].name!=e?' as "'+currentDictionary.words[d].name+'", and your dictionary is set to ignore case.':".",l+="<br>Do you want to update it to what you have set above?</span>",l+='<button type="button" id="updateConfirmButton" onclick="UpdateWord('+d+", '"+htmlEntities(e)+"', '"+htmlEntities(t)+"', '"+htmlEntities(n)+"', '"+htmlEntities(i)+"', '"+htmlEntities(r)+"'); return false;\">Yes, Update it</button>",l+=' <button type="button" id="updateCancelButton" onclick="CloseUpdateConflictArea(\'newWordButtonArea\'); return false;">No, Leave it</button>',s.innerHTML=l}else c='"'+e+'" is already in the dictionary exactly as it is written above',currentDictionary.words[d].name!=e&&(c+=". (Your dictionary is currently set to ignore case.)");else currentDictionary.words.push({name:e,pronunciation:t,partOfSpeech:n,simpleDefinition:i,longDefinition:r,wordId:currentDictionary.nextWordId++}),FocusAfterAddingNewWord(),NewWordNotification(e),SaveAndUpdateDictionary(!1);a.innerHTML=""}a.innerHTML=c}function EditWord(e){SaveScroll(),wordFormIsLocked()&&window.scroll(0,0),ClearForm(),document.getElementById("editIndex").value=e.toString(),document.getElementById("word").value=htmlEntitiesParse(currentDictionary.words[e].name),document.getElementById("pronunciation").value=htmlEntitiesParse(currentDictionary.words[e].pronunciation),document.getElementById("partOfSpeech").value=htmlEntitiesParse(currentDictionary.words[e].partOfSpeech),document.getElementById("simpleDefinition").value=htmlEntitiesParse(currentDictionary.words[e].simpleDefinition),document.getElementById("longDefinition").value=htmlEntitiesParse(currentDictionary.words[e].longDefinition),document.getElementById("newWordButtonArea").style.display="none",document.getElementById("editWordButtonArea").style.display="block"}function UpdateWord(e,t,n,i,r,o){currentDictionary.words[e].name=t,currentDictionary.words[e].pronunciation=n,currentDictionary.words[e].partOfSpeech=i,currentDictionary.words[e].simpleDefinition=r,currentDictionary.wor