";return t+="
Edit",t+="
Delete',t+="
Are you sure you want to delete this entry?
",t+="No',t+="Yes",t+="
",t+="
"}function SaveSettings(){""!=htmlEntities(document.getElementById("dictionaryNameEdit").value)&&(currentDictionary.name=htmlEntities(document.getElementById("dictionaryNameEdit").value)),currentDictionary.description=htmlEntities(document.getElementById("dictionaryDescriptionEdit").value),CheckForPartsOfSpeechChange(),currentDictionary.settings.allowDuplicates=document.getElementById("dictionaryAllowDuplicates").checked,currentDictionary.settings.caseSensitive=document.getElementById("dictionaryCaseSensitive").checked,currentDictionary.settings.sortByEquivalent=document.getElementById("dictionarySortByEquivalent").checked,currentDictionary.settings.isComplete=document.getElementById("dictionaryIsComplete").checked,document.getElementById("dictionaryIsPublic")&&(currentDictionary.settings.isPublic=document.getElementById("dictionaryIsPublic").checked),HideSettingsWhenComplete(),SaveAndUpdateDictionary(!0),LoadUserDictionaries()}function EmptyWholeDictionary(){confirm("This will delete the entire current dictionary. If you do not have a backed up export, you will lose it forever!\n\nDo you still want to delete?")&&CreateNewDictionary()}function CreateNewDictionary(){ResetDictionaryToDefault(),SaveAndUpdateDictionary(!1),SetPartsOfSpeech(),HideSettings()}function DeleteCurrentDictionary(){if(confirm("This will delete the current dictionary from the database. If you do not have a backed up export, you will lose it forever!\n\nDo you still want to delete?")){ResetDictionaryToDefault();var e=new XMLHttpRequest;e.open("POST","php/ajax_dictionarymanagement.php?action=delete"),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.onreadystatechange=function(){return 4==e.readyState&&200==e.status?(e.responseText.length<31?(console.log(e.responseText),CreateNewDictionary()):(HideSettings(),ShowDictionaryDeleteMenu(e.responseText),0==document.getElementById("loadAfterDelete").options.length&&(document.getElementById("loadAfterDeleteScreen").style.display="none",CreateNewDictionary())),!0):!1},e.send()}}function ResetDictionaryToDefault(){currentDictionary=JSON.parse(defaultDictionaryJSON)}function SaveAndUpdateDictionary(e){currentDictionary.settings.sortByEquivalent?currentDictionary.words.sort(dynamicSort(["simpleDefinition","partOfSpeech"])):currentDictionary.words.sort(dynamicSort(["name","partOfSpeech"])),SaveDictionary(!0,!0),ShowDictionary(),e||ClearForm(),CloseUpdateConflictArea("newWordButtonArea")}function SaveDictionary(e,t){localStorage.setItem("dictionary",JSON.stringify(currentDictionary)),e&&(t="undefined"!=typeof t?t:!1,SendDictionary(t)),SavePreviousDictionary()}function SendDictionary(e){e="undefined"!=typeof e?e:!1;var t="",n="";currentDictionary.externalID>0?(t="update",n=DataToSend(e)):(t="new",n=DataToSend(!0,!0));var i=new XMLHttpRequest;i.open("POST","php/ajax_dictionarymanagement.php?action="+t),i.setRequestHeader("Content-type","application/x-www-form-urlencoded"),i.onreadystatechange=function(){return 4==i.readyState&&200==i.status?("updated successfully"==i.responseText?(console.log(i.responseText),LoadUserDictionaries(),ProcessLoad()):isNaN(parseInt(i.responseText))?console.log(i.responseText):(currentDictionary.externalID=parseInt(i.responseText),LoadUserDictionaries(),ProcessLoad(),console.log("saved successfully")),!0):!1},i.send(n)}function DataToSend(e,t){t="undefined"!=typeof t&&null!=t?t:!1;var n="";return 0==currentDictionary.externalID?(n="name="+encodeURIComponent(currentDictionary.name)+"&description="+encodeURIComponent(currentDictionary.description)+"&words="+encodeURIComponent(JSON.stringify(currentDictionary.words)),n+="&nextwordid="+currentDictionary.nextWordId+"&allowduplicates="+(currentDictionary.settings.allowDuplicates?"1":"0")+"&casesensitive="+(currentDictionary.settings.caseSensitive?"1":"0"),n+="&partsofspeech="+encodeURIComponent(currentDictionary.settings.partsOfSpeech)+"&sortbyequivalent="+(currentDictionary.settings.sortByEquivalent?"1":"0")+"&iscomplete="+(currentDictionary.settings.isComplete?"1":"0")+"&ispublic="+(currentDictionary.settings.isPublic?"1":"0")):((t||currentDictionary.name!=previousDictionary.name)&&(n+="name="+encodeURIComponent(currentDictionary.name)),(t||currentDictionary.description!=previousDictionary.description)&&(n+=(""==n?"":"&")+"description="+encodeURIComponent(currentDictionary.description)),(t||e)&&(n+=(""==n?"":"&")+"words="+encodeURIComponent(JSON.stringify(currentDictionary.words))),(t||currentDictionary.nextWordId!=previousDictionary.nextWordId)&&(n+=(""==n?"":"&")+"nextwordid="+currentDictionary.nextWordId),(t||currentDictionary.settings.allowDuplicates!=previousDictionary.allowDuplicates)&&(n+=(""==n?"":"&")+"allowduplicates="+(currentDictionary.settings.allowDuplicates?"1":"0")),(t||currentDictionary.settings.caseSensitive!=previousDictionary.caseSensitive)&&(n+=(""==n?"":"&")+"casesensitive="+(currentDictionary.settings.caseSensitive?"1":"0")),(t||currentDictionary.settings.partsOfSpeech!=previousDictionary.partsOfSpeech)&&(n+=(""==n?"":"&")+"partsofspeech="+encodeURIComponent(currentDictionary.settings.partsOfSpeech)),(t||currentDictionary.settings.sortByEquivalent!=previousDictionary.sortByEquivalent)&&(n+=(""==n?"":"&")+"sortbyequivalent="+(currentDictionary.settings.sortByEquivalent?"1":"0")),(t||currentDictionary.settings.isComplete!=previousDictionary.isComplete)&&(n+=(""==n?"":"&")+"iscomplete="+(currentDictionary.settings.isComplete?"1":"0")),(t||currentDictionary.settings.isPublic!=previousDictionary.isPublic)&&(n+=(""==n?"":"&")+"ispublic="+(currentDictionary.settings.isPublic?"1":"0"))),n}function LoadDictionary(){LoadLocalDictionary();var e=new XMLHttpRequest;e.open("GET","php/ajax_dictionarymanagement.php?action=load"),e.onreadystatechange=function(){4==e.readyState&&200==e.status&&("no dictionaries"==e.responseText?(currentDictionary.externalID=0,currentDictionary.settings.isPublic=!1,SendDictionary(!0)):e.responseText.length<60?console.log(e.responseText):(currentDictionary=JSON.parse(e.responseText),SaveDictionary(!1,!1))),ProcessLoad()},e.send()}function ChangeDictionary(e){if(e="undefined"!=typeof e&&null!=e?e:document.getElementById("userDictionaries"),currentDictionary.externalID!=e.value&&e.options.length>0){var t=new XMLHttpRequest;t.open("POST","php/ajax_dictionarymanagement.php?action=switch"),t.setRequestHeader("Content-type","application/x-www-form-urlencoded");var n="newdictionaryid="+e.value.toString();t.onreadystatechange=function(){4==t.readyState&&200==t.status&&("no dictionaries"==t.responseText?(console.log(t.responseText),SendDictionary(!1)):t.responseText.length<60?console.log(t.responseText):(currentDictionary=JSON.parse(t.responseText),SaveDictionary(!1,!1),ProcessLoad(),LoadUserDictionaries(),HideSettings()))},t.send(n)}}function LoadLocalDictionary(){if(localStorage.getItem("dictionary")){var e=JSON.parse(localStorage.getItem("dictionary"));(e.words.length>0||"A new dictionary."!=e.description||"New"!=e.name)&&(currentDictionary=JSON.parse(localStorage.getItem("dictionary"))),e=null}}function ProcessLoad(){currentDictionary.hasOwnProperty("nextWordId")||(currentDictionary.nextWordId=currentDictionary.words.length+1),HideSettingsWhenComplete(),ShowDictionary(),SetPartsOfSpeech(),currentDictionary.settings.isComplete&&(document.getElementById("wordEntryForm").style.display="none"),SavePreviousDictionary()}function SavePreviousDictionary(){previousDictionary={name:currentDictionary.name,description:currentDictionary.description,nextWordId:currentDictionary.nextWordId,allowDuplicates:currentDictionary.settings.allowDuplicates,caseSensitive:currentDictionary.settings.caseSensitive,partsOfSpeech:currentDictionary.settings.partsOfSpeech,sortByEquivalent:currentDictionary.settings.sortByEquivalent,isComplete:currentDictionary.settings.isComplete,isPublic:currentDictionary.settings.isPublic}}function ExportDictionary(){var e=removeDiacritics(stripHtmlEntities(currentDictionary.name)).replace(/\W/g,"");""==e&&(e="export"),download(e+".dict",localStorage.getItem("dictionary"))}function ImportDictionary(){if(currentDictionary.externalID>0||confirm("Importing this dictionary will overwrite your current one, making it impossible to retrieve if you have not already exported it! Do you still want to import?")){if(!window.FileReader)return alert("Your browser is not supported"),!1;var e=new FileReader;if(document.getElementById("importFile").files.length>0){var t=document.getElementById("importFile").files[0];e.readAsText(t),e.onloadend=function(){if(e.result&&e.result.length){var t=JSON.parse(e.result);if(t.hasOwnProperty("name")&&t.hasOwnProperty("description")&&t.hasOwnProperty("words")&&t.hasOwnProperty("settings"))currentDictionary=JSON.parse(e.result),currentDictionary.externalID=0,currentDictionary.settings.isPublic=!1,SaveDictionary(!0,!0),ProcessLoad(),HideSettings(),document.getElementById("importFile").value="";else{var n="File is missing:";t.hasOwnProperty("name")||(n+=" name"),t.hasOwnProperty("description")||(n+=" description"),t.hasOwnProperty("words")||(n+=" words"),t.hasOwnProperty("settings")||(n+=" settings"),alert("Uploaded file is not compatible.\n\n"+n)}t=null}else alert("Upload Failed");e=null}}else alert("You must add a file to import.")}}function WordIndex(e){for(var t=0;t