Lexiconga/js/min/dictionaryBuilder.js

1 line
26 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=document.getElementById("errorMessage"),a="",c=document.getElementById("updateConflict");if(""==e||""==i&&""==r)""==e?(a+="Word cannot be blank",a+=""==i&&""==r?" and you need at least one definition.":"."):""==i&&""==r&&(a+="You need at least one definition.");else{var s=currentDictionary.settings.allowDuplicates?-1:WordIndex(e);if(s>=0)if(WordAtIndexWasChanged(s,e,t,n,i,r)){document.getElementById("newWordButtonArea").style.display="none",DisableForm(""),c.style.display="block";var d="<span id='updateConflictMessage'>\""+e+'" is already in the dictionary';d+=currentDictionary.words[s].name!=e?' as "'+currentDictionary.words[s].name+'", and your dictionary is set to ignore case.':".",d+="<br>Do you want to update it to what you have set above?</span>",d+='<button type="button" id="updateConfirmButton" onclick="UpdateWord('+s+", '"+htmlEntities(e)+"', '"+htmlEntities(t)+"', '"+htmlEntities(n)+"', '"+htmlEntities(i)+"', '"+htmlEntities(r)+"'); return false;\">Yes, Update it</button>",d+=' <button type="button" id="updateCancelButton" onclick="CloseUpdateConflictArea(\'\'); return false;">No, Leave it</button>',c.innerHTML=d}else a='"'+e+'" is already in the dictionary exactly as it is written above',currentDictionary.words[s].name!=e&&(a+=". (Your dictionary is currently set to ignore case.)");else currentDictionary.words.push({name:e,pronunciation:t,partOfSpeech:n.length>0?n:" ",simpleDefinition:i,longDefinition:r,wordId:currentDictionary.nextWordId++}),SaveAndUpdateWords("new"),FocusAfterAddingNewWord(),NewWordNotification(e);o.innerHTML=""}o.innerHTML=a}function ShowWordEditForm(e){var t=e.toString(),n=currentDictionary.words[e],i='<form id="editForm'+t+'"> <h2>Editing '+n.name+'</h2> <label><span>Word</span> <input type="text" id="word'+t+'" value="'+htmlEntitiesParse(n.name)+'" onkeydown="SubmitWordOnCtrlEnter(this)" /> </label> <label><span>Pronunciation <a class="clickable inline-button" href="http://r12a.github.io/pickers/ipa/" target="_blank" title="IPA Character Picker located at http://r12a.github.io/pickers/ipa/">IPA Characters</a></span> <input type="text" id="pronunciation'+t+'" value="'+htmlEntitiesParse(n.pronunciation)+'" onkeydown="SubmitWordOnCtrlEnter(this)" /> </label> <label><span>Part of Speech</span> <select id="partOfSpeech'+t+'" onkeydown="SubmitWordOnCtrlEnter(this)"></select> </label> <label><span>Definition/Equivalent Word(s)</span> <input type="text" id="simpleDefinition'+t+'" value="'+htmlEntitiesParse(n.simpleDefinition)+'" onkeydown="SubmitWordOnCtrlEnter(this)" /> </label> <label><span>Explanation/Long Definition <span id="showFullScreenTextbox" class="clickable inline-button" onclick="ShowFullScreenTextbox(\'longDefinition'+t+"', 'Explanation/Long Definition')\">Maximize</span></span> <textarea id=\"longDefinition"+t+'" class="longDefinition" onkeydown="SubmitWordOnCtrlEnter(this)">'+htmlEntitiesParse(n.longDefinition)+'</textarea> </label> <span id="errorMessage'+t+'"></span> <div id="editWordButtonArea'+t+'" style="display: block;"> <button type="button" onclick="EditWord(\''+t+'\'); return false;">Edit Word</button> <button type="button" onclick="CancelEditForm('+t+'); return false;">Cancel</button> </div> <div id="updateConflict'+t+'" style="display: none;"></div> </form>';document.getE