Organized functions more logically.
This commit is contained in:
parent
2e346e597f
commit
3bb9bab9a8
|
@ -107,24 +107,6 @@ function AddWord() {
|
||||||
errorMessageArea.innerHTML = errorMessage;
|
errorMessageArea.innerHTML = errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
function WordAtIndexWasChanged(indexString, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition) {
|
|
||||||
return (!currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name.toLowerCase() != word.toLowerCase()) ||
|
|
||||||
(currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name != word) ||
|
|
||||||
currentDictionary.words[parseInt(indexString)].pronunciation != pronunciation ||
|
|
||||||
currentDictionary.words[parseInt(indexString)].partOfSpeech != partOfSpeech ||
|
|
||||||
currentDictionary.words[parseInt(indexString)].simpleDefinition != simpleDefinition ||
|
|
||||||
currentDictionary.words[parseInt(indexString)].longDefinition != longDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
function SaveScroll() {
|
|
||||||
var doc = document.documentElement;
|
|
||||||
var left = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
|
|
||||||
var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
|
|
||||||
|
|
||||||
savedScroll.x = left;
|
|
||||||
savedScroll.y = top;
|
|
||||||
}
|
|
||||||
|
|
||||||
function EditWord(index) {
|
function EditWord(index) {
|
||||||
SaveScroll();
|
SaveScroll();
|
||||||
if (wordFormIsLocked()) {
|
if (wordFormIsLocked()) {
|
||||||
|
@ -144,20 +126,6 @@ function EditWord(index) {
|
||||||
document.getElementById("editWordButtonArea").style.display = "block";
|
document.getElementById("editWordButtonArea").style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
function SaveAndUpdateDictionary(keepFormContents) {
|
|
||||||
if (!currentDictionary.settings.sortByEquivalent) {
|
|
||||||
currentDictionary.words.sort(dynamicSort("name"));
|
|
||||||
} else {
|
|
||||||
currentDictionary.words.sort(dynamicSort("simpleDefinition"));
|
|
||||||
}
|
|
||||||
SaveDictionary(true, true);
|
|
||||||
ShowDictionary();
|
|
||||||
if (!keepFormContents) {
|
|
||||||
ClearForm();
|
|
||||||
}
|
|
||||||
CloseUpdateConflictArea('newWordButtonArea');
|
|
||||||
}
|
|
||||||
|
|
||||||
function UpdateWord(wordIndex, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition) {
|
function UpdateWord(wordIndex, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition) {
|
||||||
currentDictionary.words[wordIndex].name = word;
|
currentDictionary.words[wordIndex].name = word;
|
||||||
currentDictionary.words[wordIndex].pronunciation = pronunciation;
|
currentDictionary.words[wordIndex].pronunciation = pronunciation;
|
||||||
|
@ -357,15 +325,6 @@ function SaveSettings() {
|
||||||
LoadUserDictionaries();
|
LoadUserDictionaries();
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckForPartsOfSpeechChange() {
|
|
||||||
if (htmlEntities(document.getElementById("dictionaryPartsOfSpeechEdit").value) != currentDictionary.settings.partsOfSpeech) {
|
|
||||||
if (htmlEntities(document.getElementById("dictionaryPartsOfSpeechEdit").value) != "") {
|
|
||||||
currentDictionary.settings.partsOfSpeech = htmlEntities(document.getElementById("dictionaryPartsOfSpeechEdit").value);
|
|
||||||
SetPartsOfSpeech();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function EmptyWholeDictionary() {
|
function EmptyWholeDictionary() {
|
||||||
if (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?")) {
|
if (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();
|
CreateNewDictionary();
|
||||||
|
@ -414,6 +373,20 @@ function ResetDictionaryToDefault() {
|
||||||
currentDictionary = JSON.parse(defaultDictionaryJSON);
|
currentDictionary = JSON.parse(defaultDictionaryJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SaveAndUpdateDictionary(keepFormContents) {
|
||||||
|
if (!currentDictionary.settings.sortByEquivalent) {
|
||||||
|
currentDictionary.words.sort(dynamicSort("name"));
|
||||||
|
} else {
|
||||||
|
currentDictionary.words.sort(dynamicSort("simpleDefinition"));
|
||||||
|
}
|
||||||
|
SaveDictionary(true, true);
|
||||||
|
ShowDictionary();
|
||||||
|
if (!keepFormContents) {
|
||||||
|
ClearForm();
|
||||||
|
}
|
||||||
|
CloseUpdateConflictArea('newWordButtonArea');
|
||||||
|
}
|
||||||
|
|
||||||
function SaveDictionary(sendToDatabase, sendWords) {
|
function SaveDictionary(sendToDatabase, sendWords) {
|
||||||
localStorage.setItem('dictionary', JSON.stringify(currentDictionary));
|
localStorage.setItem('dictionary', JSON.stringify(currentDictionary));
|
||||||
|
|
||||||
|
@ -670,6 +643,33 @@ function WordIndex(word) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function WordAtIndexWasChanged(indexString, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition) {
|
||||||
|
return (!currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name.toLowerCase() != word.toLowerCase()) ||
|
||||||
|
(currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name != word) ||
|
||||||
|
currentDictionary.words[parseInt(indexString)].pronunciation != pronunciation ||
|
||||||
|
currentDictionary.words[parseInt(indexString)].partOfSpeech != partOfSpeech ||
|
||||||
|
currentDictionary.words[parseInt(indexString)].simpleDefinition != simpleDefinition ||
|
||||||
|
currentDictionary.words[parseInt(indexString)].longDefinition != longDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
function CheckForPartsOfSpeechChange() {
|
||||||
|
if (htmlEntities(document.getElementById("dictionaryPartsOfSpeechEdit").value) != currentDictionary.settings.partsOfSpeech) {
|
||||||
|
if (htmlEntities(document.getElementById("dictionaryPartsOfSpeechEdit").value) != "") {
|
||||||
|
currentDictionary.settings.partsOfSpeech = htmlEntities(document.getElementById("dictionaryPartsOfSpeechEdit").value);
|
||||||
|
SetPartsOfSpeech();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function SaveScroll() {
|
||||||
|
var doc = document.documentElement;
|
||||||
|
var left = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
|
||||||
|
var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
|
||||||
|
|
||||||
|
savedScroll.x = left;
|
||||||
|
savedScroll.y = top;
|
||||||
|
}
|
||||||
|
|
||||||
function htmlEntities(string) {
|
function htmlEntities(string) {
|
||||||
return String(string).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\\/g, '\').replace(/\n/g, '<br>');
|
return String(string).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\\/g, '\').replace(/\n/g, '<br>');
|
||||||
}
|
}
|
||||||
|
|
76
js/ui.js
76
js/ui.js
|
@ -119,18 +119,6 @@ function ValidateAccountSettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function WarnEmailChange() {
|
|
||||||
var emailChangeWarning = document.getElementById("accountSettingsEmailChangeWarning");
|
|
||||||
var emailValue = document.getElementById("accountSettingsEmailField").value;
|
|
||||||
var originalEmailValue = document.getElementById("accountSettingsPreviousEmailField").value;
|
|
||||||
|
|
||||||
if (emailValue != originalEmailValue) {
|
|
||||||
emailChangeWarning.style.display = "block";
|
|
||||||
} else {
|
|
||||||
emailChangeWarning.style.display = "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ValidateForgotPassword() {
|
function ValidateForgotPassword() {
|
||||||
var errorMessage = document.getElementById("forgotError");
|
var errorMessage = document.getElementById("forgotError");
|
||||||
var emailValue = document.getElementById("forgotEmailField").value;
|
var emailValue = document.getElementById("forgotEmailField").value;
|
||||||
|
@ -174,6 +162,18 @@ function ValidateResetPassword() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function WarnEmailChange() {
|
||||||
|
var emailChangeWarning = document.getElementById("accountSettingsEmailChangeWarning");
|
||||||
|
var emailValue = document.getElementById("accountSettingsEmailField").value;
|
||||||
|
var originalEmailValue = document.getElementById("accountSettingsPreviousEmailField").value;
|
||||||
|
|
||||||
|
if (emailValue != originalEmailValue) {
|
||||||
|
emailChangeWarning.style.display = "block";
|
||||||
|
} else {
|
||||||
|
emailChangeWarning.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function LoggedInResetPassword() {
|
function LoggedInResetPassword() {
|
||||||
var resetPasswordRequest = new XMLHttpRequest();
|
var resetPasswordRequest = new XMLHttpRequest();
|
||||||
resetPasswordRequest.open('GET', "php/ajax_setnewpassword.php");
|
resetPasswordRequest.open('GET', "php/ajax_setnewpassword.php");
|
||||||
|
@ -340,21 +340,6 @@ function HideAccountSettings() {
|
||||||
document.getElementById("accountSettingsScreen").style.display = "none";
|
document.getElementById("accountSettingsScreen").style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShowDictionaryDeleteMenu(dictionaryList) {
|
|
||||||
document.getElementById('loadAfterDeleteScreen').style.display = 'block';
|
|
||||||
//Parse response into the list that forces you to load one and reload select in settings.
|
|
||||||
ParseUserDictionariesIntoSelect(document.getElementById("loadAfterDelete"), dictionaryList);
|
|
||||||
ParseUserDictionariesIntoSelect(document.getElementById("userDictionaries"), dictionaryList);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ToggleCaseSensitiveOption() {
|
|
||||||
if (document.getElementById("dictionaryAllowDuplicates").checked) {
|
|
||||||
document.getElementById("dictionaryCaseSensitive").disabled = true;
|
|
||||||
} else {
|
|
||||||
document.getElementById("dictionaryCaseSensitive").disabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ShowSettings() {
|
function ShowSettings() {
|
||||||
document.getElementById("settingsScreen").style.display = "block";
|
document.getElementById("settingsScreen").style.display = "block";
|
||||||
document.getElementById("dictionaryNameEdit").value = htmlEntitiesParse(currentDictionary.name);
|
document.getElementById("dictionaryNameEdit").value = htmlEntitiesParse(currentDictionary.name);
|
||||||
|
@ -371,6 +356,17 @@ function ShowSettings() {
|
||||||
document.getElementById("numberOfWordsInDictionary").innerHTML = currentDictionary.words.length.toString();
|
document.getElementById("numberOfWordsInDictionary").innerHTML = currentDictionary.words.length.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function HideSettings() {
|
||||||
|
document.getElementById("settingsScreen").style.display = "none";
|
||||||
|
if (currentDictionary.settings.isComplete) {
|
||||||
|
LockWordForm();
|
||||||
|
document.getElementById("wordEntryForm").style.display = "none";
|
||||||
|
} else {
|
||||||
|
document.getElementById("wordEntryForm").style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function HideSettingsWhenComplete() {
|
function HideSettingsWhenComplete() {
|
||||||
if (document.getElementById("settingsScreen")) {
|
if (document.getElementById("settingsScreen")) {
|
||||||
if (currentDictionary.settings.isComplete) {
|
if (currentDictionary.settings.isComplete) {
|
||||||
|
@ -381,6 +377,21 @@ function HideSettingsWhenComplete() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ShowDictionaryDeleteMenu(dictionaryList) {
|
||||||
|
document.getElementById('loadAfterDeleteScreen').style.display = 'block';
|
||||||
|
//Parse response into the list that forces you to load one and reload select in settings.
|
||||||
|
ParseUserDictionariesIntoSelect(document.getElementById("loadAfterDelete"), dictionaryList);
|
||||||
|
ParseUserDictionariesIntoSelect(document.getElementById("userDictionaries"), dictionaryList);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ToggleCaseSensitiveOption() {
|
||||||
|
if (document.getElementById("dictionaryAllowDuplicates").checked) {
|
||||||
|
document.getElementById("dictionaryCaseSensitive").disabled = true;
|
||||||
|
} else {
|
||||||
|
document.getElementById("dictionaryCaseSensitive").disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function TogglePublicLink() {
|
function TogglePublicLink() {
|
||||||
if (document.getElementById("dictionaryIsPublic").checked) {
|
if (document.getElementById("dictionaryIsPublic").checked) {
|
||||||
var publicLink = "http://lexicon.ga/view/?dict=" + currentDictionary.externalID;
|
var publicLink = "http://lexicon.ga/view/?dict=" + currentDictionary.externalID;
|
||||||
|
@ -435,17 +446,6 @@ function ShowFilterWordCount(numberOfWords) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function HideSettings() {
|
|
||||||
document.getElementById("settingsScreen").style.display = "none";
|
|
||||||
if (currentDictionary.settings.isComplete) {
|
|
||||||
LockWordForm();
|
|
||||||
document.getElementById("wordEntryForm").style.display = "none";
|
|
||||||
} else {
|
|
||||||
document.getElementById("wordEntryForm").style.display = "block";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function NewWordNotification(word) {
|
function NewWordNotification(word) {
|
||||||
var notificationArea = document.getElementById("notificationArea");
|
var notificationArea = document.getElementById("notificationArea");
|
||||||
var notificationMessage = document.getElementById("notificationMessage");
|
var notificationMessage = document.getElementById("notificationMessage");
|
||||||
|
|
Loading…
Reference in New Issue