Show link to word after adding it and focus on Word field.

Only for newly added words.
This commit is contained in:
Robbie Antenesse 2015-11-09 17:53:01 -07:00
parent 7fb4dfbb70
commit 6e9d11ec0c
3 changed files with 16 additions and 5 deletions

View File

@ -26,12 +26,10 @@ if ($_GET['adminoverride'] == 'dictionarytotext') {
</div>
</header>
<contents>
<?php if ($notificationMessage) { ?>
<div id="notificationArea">
<div id="notificationArea" style="display:<?php echo (($notificationMessage) ? "block" : "none"); ?>;">
<span id="notificationCloseButton" class="clickable" onclick="document.getElementById('notificationArea').style.display='none';">Close</span>
<?php echo $notificationMessage; ?>
<div id="notificationMessage"><?php echo $notificationMessage; ?></div>
</div>
<?php } ?>
<div id="leftColumn">
<form id="wordEntryForm">
<label><span>Word</span>

View File

@ -103,10 +103,11 @@ function AddWord() {
}
} else {
currentDictionary.words.push({name: word, pronunciation: pronunciation, partOfSpeech: partOfSpeech, simpleDefinition: simpleDefinition, longDefinition: longDefinition, wordId: currentDictionary.nextWordId++});
FocusAfterAddingNewWord();
NewWordNotification(word);
SaveAndUpdateDictionary(false);
}
errorMessageArea.innerHTML = "";
} else {
if (word == "") {

View File

@ -99,4 +99,16 @@ function SetPartsOfSpeech () {
function HideSettings() {
document.getElementById("settingsScreen").style.display = "none";
document.getElementById("wordEntryForm").style.display = (currentDictionary.settings.isComplete) ? "none" : "block";
}
function NewWordNotification(word) {
var notificationArea = document.getElementById("notificationArea");
var notificationMessage = document.getElementById("notificationMessage");
var wordId = currentDictionary.nextWordId - 1;
notificationArea.style.display = "block";
notificationMessage.innerHTML = "New Word Added: <a href='#" + wordId.toString() + "'>" + word + "</a>";
}
function FocusAfterAddingNewWord() {
document.getElementById("word").focus();
}