Fixed using ctrl+enter to submit edits to words not working.

Removed hotkey for export.
This commit is contained in:
Robbie Antenesse 2016-07-11 15:12:28 -06:00
parent ca97409b44
commit 0a5eb01423
3 changed files with 28 additions and 32 deletions

View File

@ -105,9 +105,8 @@ The "Filter Words" drop-down box allows you to filter your dictionary by part of
**Ctrl/Control +** **Ctrl/Control +**
* **Enter/Return** : Submit Word (when typing in Word Form) * **Enter/Return** : Submit Word (when typing in Word or Edit Form)
* **D** : Toggle Dictionary Description visibility. * **D** : Toggle Dictionary Description visibility.
* **E** : Export current dictionary. (Also Ctrl+Shift+S does this.)
* **H** : Open this help window. * **H** : Open this help window.
* **M** : Maximize/Minimize Full Screen textbox when typing in the boxes that have the Maximize button. * **M** : Maximize/Minimize Full Screen textbox when typing in the boxes that have the Maximize button.
* **S** : Jump to Search box. * **S** : Jump to Search box.

View File

@ -156,6 +156,10 @@ function EditWord(indexString) {
} }
errorMessageArea.innerHTML = errorMessage; errorMessageArea.innerHTML = errorMessage;
if (document.getElementById("updateConfirmButton" + indexString)) {
document.getElementById("updateConfirmButton" + indexString).focus();
}
} }
function UpdateWord(wordIndex, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition) { function UpdateWord(wordIndex, word, pronunciation, partOfSpeech, simpleDefinition, longDefinition) {
@ -859,7 +863,7 @@ function WordAtIndexWasChanged(indexString, word, pronunciation, partOfSpeech, s
return (!currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name.toLowerCase() != word.toLowerCase()) || return (!currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name.toLowerCase() != word.toLowerCase()) ||
(currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name != word) || (currentDictionary.settings.caseSensitive && currentDictionary.words[parseInt(indexString)].name != word) ||
currentDictionary.words[parseInt(indexString)].pronunciation != pronunciation || currentDictionary.words[parseInt(indexString)].pronunciation != pronunciation ||
currentDictionary.words[parseInt(indexString)].partOfSpeech != partOfSpeech || currentDictionary.words[parseInt(indexString)].partOfSpeech.trim() != partOfSpeech ||
currentDictionary.words[parseInt(indexString)].simpleDefinition != simpleDefinition || currentDictionary.words[parseInt(indexString)].simpleDefinition != simpleDefinition ||
currentDictionary.words[parseInt(indexString)].longDefinition != longDefinition; currentDictionary.words[parseInt(indexString)].longDefinition != longDefinition;
} }

View File

@ -2,7 +2,7 @@ function Initialize() {
LoadDictionary(); LoadDictionary();
ClearForm(); ClearForm();
LoadUserDictionaries(); LoadUserDictionaries();
GetTextFile("/README.md", "aboutText", true); GetTextFile("/README.md", "aboutText", true);
GetTextFile("/TERMS.md", "termsText", true); GetTextFile("/TERMS.md", "termsText", true);
GetTextFile("/PRIVACY.md", "privacyText", true); GetTextFile("/PRIVACY.md", "privacyText", true);
@ -37,9 +37,9 @@ function SetKeyboardShortcuts() {
// Only allow shortcuts if not currently using fullscreen textbox // Only allow shortcuts if not currently using fullscreen textbox
if (document.getElementById("fullScreenTextboxScreen").style.display == "none") { if (document.getElementById("fullScreenTextboxScreen").style.display == "none") {
if (keyCode == keyCodeFor("m")) { if (keyCode == keyCodeFor("m")) {
if (document.activeElement.id == "longDefinition") { if (document.activeElement.id.indexOf("longDefinition") >= 0) {
e.preventDefault(); e.preventDefault();
ShowFullScreenTextbox('longDefinition', 'Explanation/Long Definition'); ShowFullScreenTextbox(document.activeElement.id, 'Explanation/Long Definition');
} }
else if (document.activeElement.id == "dictionaryDescriptionEdit") { else if (document.activeElement.id == "dictionaryDescriptionEdit") {
e.preventDefault(); e.preventDefault();
@ -58,16 +58,12 @@ function SetKeyboardShortcuts() {
e.preventDefault(); e.preventDefault();
ToggleDescription(); ToggleDescription();
} }
else if ((e.shiftKey && keyCode == keyCodeFor("s")) || keyCode == keyCodeFor("e")) {
e.preventDefault();
ExportDictionary();
}
else if (keyCode == keyCodeFor("s")) { else if (keyCode == keyCodeFor("s")) {
e.preventDefault(); e.preventDefault();
//ToggleSearchFilter(); //ToggleSearchFilter();
var searchFilterToggle = document.getElementById("searchFilterToggle"); var searchFilterToggle = document.getElementById("searchFilterToggle");
var searchFilterArea = document.getElementById("searchFilterArea"); var searchFilterArea = document.getElementById("searchFilterArea");
if (searchFilterArea.style.display == "none") { if (searchFilterArea.style.display == "none") {
searchFilterArea.style.display = "block"; searchFilterArea.style.display = "block";
searchFilterToggle.innerHTML = "Hide Search/Filter Options"; searchFilterToggle.innerHTML = "Hide Search/Filter Options";
@ -90,9 +86,6 @@ function SetKeyboardShortcuts() {
else if (keyCode == keyCodeFor("d")) { else if (keyCode == keyCodeFor("d")) {
e.preventDefault(); e.preventDefault();
} }
else if ((e.shiftKey && keyCode == keyCodeFor("s")) || keyCode == keyCodeFor("e")) {
e.preventDefault();
}
else if (keyCode == keyCodeFor("s")) { else if (keyCode == keyCodeFor("s")) {
e.preventDefault(); e.preventDefault();
} }
@ -142,10 +135,10 @@ function SubmitWordOnCtrlEnter(keypress) {
if (keyCode === keyCodeFor("ctrlEnter") || (keyCode == keyCodeFor("enter") && event.ctrlKey)) { //Windows and Linux Chrome accept ctrl+enter as keyCode 10. if (keyCode === keyCodeFor("ctrlEnter") || (keyCode == keyCodeFor("enter") && event.ctrlKey)) { //Windows and Linux Chrome accept ctrl+enter as keyCode 10.
event.preventDefault(); event.preventDefault();
AddWord(); if (/\d/.test(document.activeElement.id)) { // If there IS a number in the ID, then it is a word being edited.
EditWord(document.activeElement.id.match(/\d+/)[0]); // .match(/\d+/) returns an array of digits in a string.
if (document.getElementById("newWordButtonArea").style.display == "none" && document.getElementById("editWordButtonArea").style.display == "none") { } else { // Otherwise, it's a new word.
document.getElementById("updateConfirmButton").focus(); AddWord();
} }
} }
} }
@ -170,7 +163,7 @@ function ParseUserDictionariesIntoSelect(selectToPopulate, dicitonaryList) {
selectToPopulate.removeChild(selectToPopulate.options[i]); selectToPopulate.removeChild(selectToPopulate.options[i]);
} }
} }
var dictionaries = dicitonaryList.split("_DICTIONARYSEPARATOR_"); var dictionaries = dicitonaryList.split("_DICTIONARYSEPARATOR_");
for (var j = 0; j < dictionaries.length - 1; j++) { for (var j = 0; j < dictionaries.length - 1; j++) {
var dictionaryOption = document.createElement('option'); var dictionaryOption = document.createElement('option');
@ -198,7 +191,7 @@ function ValidateLogin() {
var errorMessage = document.getElementById("loginError"); var errorMessage = document.getElementById("loginError");
var emailValue = document.getElementById("loginEmailField").value; var emailValue = document.getElementById("loginEmailField").value;
var passwordValue = document.getElementById("loginPasswordField").value; var passwordValue = document.getElementById("loginPasswordField").value;
if (emailValue == "") { if (emailValue == "") {
errorMessage.innerHTML = "Email cannot be blank!"; errorMessage.innerHTML = "Email cannot be blank!";
return false; return false;
@ -219,7 +212,7 @@ function ValidateCreateAccount() {
var passwordValue = document.getElementById("createAccountPasswordField").value; var passwordValue = document.getElementById("createAccountPasswordField").value;
var passwordConfirmValue = document.getElementById("createAccountPasswordConfirmField").value; var passwordConfirmValue = document.getElementById("createAccountPasswordConfirmField").value;
var publicNameValue = document.getElementById("createAccountPublicNameField").value; var publicNameValue = document.getElementById("createAccountPublicNameField").value;
if (emailValue == "") { if (emailValue == "") {
errorMessage.innerHTML = "Email cannot be blank!"; errorMessage.innerHTML = "Email cannot be blank!";
return false; return false;
@ -256,7 +249,7 @@ function ValidateAccountSettings() {
var errorMessage = document.getElementById("accountSettingsError"); var errorMessage = document.getElementById("accountSettingsError");
var emailValue = document.getElementById("accountSettingsEmailField").value; var emailValue = document.getElementById("accountSettingsEmailField").value;
var publicNameValue = document.getElementById("accountSettingsPublicNameField").value; var publicNameValue = document.getElementById("accountSettingsPublicNameField").value;
if (emailValue == "") { if (emailValue == "") {
errorMessage.innerHTML = "Email cannot be blank!"; errorMessage.innerHTML = "Email cannot be blank!";
return false; return false;
@ -274,7 +267,7 @@ function ValidateAccountSettings() {
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;
if (emailValue == "") { if (emailValue == "") {
errorMessage.innerHTML = "Email cannot be blank!"; errorMessage.innerHTML = "Email cannot be blank!";
return false; return false;
@ -302,7 +295,7 @@ function ValidateResetPassword() {
var errorMessage = document.getElementById("resetPasswordError"); var errorMessage = document.getElementById("resetPasswordError");
var passwordValue = document.getElementById("newPasswordField").value; var passwordValue = document.getElementById("newPasswordField").value;
var passwordConfirmValue = document.getElementById("newPasswordConfirmField").value; var passwordConfirmValue = document.getElementById("newPasswordConfirmField").value;
if (passwordValue == "") { if (passwordValue == "") {
errorMessage.innerHTML = "Password cannot be blank!"; errorMessage.innerHTML = "Password cannot be blank!";
return false; return false;
@ -382,7 +375,7 @@ function UnlockWordForm(topValue) {
var leftColumnHeight = leftColumn.offsetHeight; var leftColumnHeight = leftColumn.offsetHeight;
lockButton.innerHTML = "&#128275;"; // Change to the "Unlocked lock" icon. lockButton.innerHTML = "&#128275;"; // Change to the "Unlocked lock" icon.
wordForm.style.position = "fixed"; wordForm.style.position = "fixed";
wordForm.style.top = (typeof topValue !== 'undefined') ? topValue : document.getElementById("dictionaryColumn").offsetTop.toString() + "px"; wordForm.style.top = (typeof topValue !== 'undefined') ? topValue : document.getElementById("dictionaryColumn").offsetTop.toString() + "px";
wordForm.style.width = wordFormWidth.toString() + "px"; wordForm.style.width = wordFormWidth.toString() + "px";
@ -439,7 +432,7 @@ function ClearForm() {
document.getElementById("simpleDefinition").value = ""; document.getElementById("simpleDefinition").value = "";
document.getElementById("longDefinition").value = ""; document.getElementById("longDefinition").value = "";
document.getElementById("editIndex").value = ""; document.getElementById("editIndex").value = "";
document.getElementById("newWordButtonArea").style.display = "block"; document.getElementById("newWordButtonArea").style.display = "block";
document.getElementById("editWordButtonArea").style.display = "none"; document.getElementById("editWordButtonArea").style.display = "none";
document.getElementById("errorMessage").innerHTML = ""; document.getElementById("errorMessage").innerHTML = "";
@ -451,7 +444,7 @@ function ClearForm() {
function ToggleDescription() { function ToggleDescription() {
var descriptionToggle = document.getElementById("descriptionToggle"); var descriptionToggle = document.getElementById("descriptionToggle");
var descriptionArea = document.getElementById("dictionaryDescription"); var descriptionArea = document.getElementById("dictionaryDescription");
if (descriptionArea.style.display == "none") { if (descriptionArea.style.display == "none") {
descriptionArea.style.display = "block"; descriptionArea.style.display = "block";
descriptionToggle.innerHTML = "Hide Description"; descriptionToggle.innerHTML = "Hide Description";
@ -464,7 +457,7 @@ function ToggleDescription() {
function ToggleSearchFilter() { function ToggleSearchFilter() {
var searchFilterToggle = document.getElementById("searchFilterToggle"); var searchFilterToggle = document.getElementById("searchFilterToggle");
var searchFilterArea = document.getElementById("searchFilterArea"); var searchFilterArea = document.getElementById("searchFilterArea");
if (searchFilterArea.style.display == "none") { if (searchFilterArea.style.display == "none") {
searchFilterArea.style.display = "block"; searchFilterArea.style.display = "block";
searchFilterToggle.innerHTML = "Hide Search/Filter Options"; searchFilterToggle.innerHTML = "Hide Search/Filter Options";
@ -510,7 +503,7 @@ function ToggleAccountSettings() {
function ShowAccountSettings(variableName) { function ShowAccountSettings(variableName) {
if (document.getElementById("accountSettingsScreen")) if (document.getElementById("accountSettingsScreen"))
document.getElementById("accountSettingsScreen").style.display = "block"; document.getElementById("accountSettingsScreen").style.display = "block";
HideInfo(); HideInfo();
} }
@ -556,7 +549,7 @@ function HideSettings() {
} else { } else {
document.getElementById("wordEntryForm").style.display = "block"; document.getElementById("wordEntryForm").style.display = "block";
} }
} }
function HideSettingsWhenComplete() { function HideSettingsWhenComplete() {
@ -578,7 +571,7 @@ function ShowFullScreenTextbox(textboxToExpandId, labelText) {
document.getElementById("expandedTextboxId").innerHTML = textboxToExpandId; document.getElementById("expandedTextboxId").innerHTML = textboxToExpandId;
targetTextboxElement.value = sourceTextboxElement.value; targetTextboxElement.value = sourceTextboxElement.value;
document.getElementById("fullScreenTextboxScreen").style.display = "block"; document.getElementById("fullScreenTextboxScreen").style.display = "block";
setSelectionRange(targetTextboxElement, selection.start, selection.end); setSelectionRange(targetTextboxElement, selection.start, selection.end);
} }
@ -590,7 +583,7 @@ function HideFullScreenTextbox() {
targetTextboxElement.value = sourceTextboxElement.value; targetTextboxElement.value = sourceTextboxElement.value;
document.getElementById("fullScreenTextboxScreen").style.display = "none"; document.getElementById("fullScreenTextboxScreen").style.display = "none";
setSelectionRange(targetTextboxElement, selection.start, selection.end); setSelectionRange(targetTextboxElement, selection.start, selection.end);
} }