Added Allow Duplicates option

Fixed Part of Speech Filter
Updated styling for entries
Updated Dictionary is Complete functionality
This commit is contained in:
Robbie Antenesse 2015-10-30 11:38:41 -06:00
parent 310144b9ed
commit d8b3ab00c5
3 changed files with 88 additions and 23 deletions

View File

@ -2,6 +2,7 @@
padding: 0;
margin: 0;
border: none;
font-family: Georgia, 'Times New Roman', Times, serif;
}
footer {
@ -38,11 +39,25 @@ label span {
font-weight: bold;
}
label label {
margin-left: 20px;
}
label span.checkboxlabel {
display: inline;
margin-left: 10px;
}
input, textarea {
display: block;
padding-left: 5px;
}
input[type=checkbox] {
display: inline;
margin: 5px;
}
#longDefinition {
width: 350px;
height: 200px;
@ -69,6 +84,15 @@ input, textarea {
margin: 0 0 5px;
}
#dictionaryDescription {
width: 100%;
max-height: 400px;
overflow-y: auto;
padding: 15px;
border: 1px solid #cacaca;
margin: 10px;
}
.clickable {
font-weight: bold;
cursor: pointer;
@ -98,6 +122,7 @@ entry {
word {
font-weight: bold;
font-size: 20px;
}
partofspeech {
@ -105,8 +130,9 @@ partofspeech {
font-size: 10px;
}
shortdefinition {
simpledefinition {
display: block;
font-style: italic;
}
longdefinition {
@ -167,6 +193,7 @@ longDefinition p {
.deleteConfirm {
display: block;
font-size: 10px;
margin: 10px;
}
#settingsBackgroundFade, #aboutBackgroundFade {

View File

@ -76,8 +76,9 @@
<h2>Dictionary Settings</h2>
<form id="settingsForm">
<div class="settingsCol">
<div id="hideIfComplete">
<label>
<span>Dictionary name</span>
<span>Dictionary Name</span>
<input type="text" id="dictionaryNameEdit" />
</label>
<label><span>Dictionary Description/Rules</span>
@ -88,7 +89,16 @@
<input type="text" id="dictionaryPartsOfSpeechEdit" />
</label>
<label>
<span>Dictionary is complete</span>
<span class="checkboxlabel">Allow Duplicates</span>
<input type="checkbox" id="dictionaryAllowDuplicates" onchange="ToggleCaseSensitiveOption()" />
<label>
<span class="checkboxlabel">Case-Sensitive</span>
<input type="checkbox" id="dictionaryCaseSensitive" />
</label>
</label>
</div>
<label>
<span class="checkboxlabel">Dictionary is Complete</span>
<input type="checkbox" id="dictionaryIsComplete" />
</label>
</div>
@ -147,11 +157,11 @@
Please note that if you have other parts of speech added to existing words, those words will not update and will keep the old parts of speech. You will need to manually update any words with incorrect parts of speech after the fact, which is why I recommend you update the available parts of speech as one of the first things you do if you need to change them at all!
</p>
<p>
The <b>Allow Duplicates</b> checkbox allows you to control whether or not Dictionary Builder will allow you to add the same word multiple times. If you leave Allow Duplicates unchecked and you try to add a word that is already in the dictionary, Dictionary Builder will tell you that the word already exists and will ask if you want to update it with the newly entered word. <em>Note: Allow Duplicates is not yet in the Settings menu!</em>
The <b>Allow Duplicates</b> checkbox allows you to control whether or not Dictionary Builder will allow you to add the same word multiple times. If you leave Allow Duplicates unchecked and you try to add a word that is already in the dictionary, Dictionary Builder will tell you that the word already exists and will ask if you want to update it with the newly entered word.
</p>
<p>
The <b>Case-Sensitive</b> checkbox allows you to control Dictionary Builder's duplicate detection. If you leave Case-Sensitive unchecked, you will be alerted when you are trying to add a word with the same letters to your dictionary a second time. For example, "dog" is identified as the same word as "DOG" or "doG". The dictionary will keep whatever capitalization you save but it will identify words with the same spelling as duplicates. If Case-Sensitive is checked, then it will not identify "dog" and "DOG" as the same word.<br>
If Allow Duplicates is checked, this checkbox becomes unavailable. <em>Note: Case-Sensitive is not yet in the Settings menu!</em>
If Allow Duplicates is checked, this checkbox becomes unavailable.
</p>
<p>
The "<b>Dictionary is complete</b>" checkbox will make the word add/edit form go away so you can view or share it more easily/safely. Plus when you export your dictionary, all of the options to change anything about your dictionary will be excluded when it is re-imported! Your dictionary will become static, and will not be able to be changed or updated without a password. <em>Note: At the moment, ONLY the word form goes away. Nothing else in this paragraph is implemented yet!</em>

View File

@ -6,8 +6,8 @@ var currentDictionary = {
description: "A new dictionary.",
words: [],
settings: {
allowDuplicates: false,
caseSensitive: false,
preferUpperCase: false,
partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction",
isComplete: false
},
@ -96,7 +96,7 @@ function AddWord() {
currentDictionary.words.sort(dynamicSort("name"));
errorMessageArea.innerHTML = "";
ShowDictionary();
ShowDictionary(document.getElementById("wordFilter").value);
SaveDictionary();
} else {
if (word == "") {
@ -152,7 +152,7 @@ function UpdateWord(wordIndex, word, simpleDefinition, longDefinition, partOfSpe
currentDictionary.words[wordIndex].simpleDefinition = simpleDefinition;
currentDictionary.words[wordIndex].longDefinition = longDefinition;
currentDictionary.words[wordIndex].partOfSpeech = partOfSpeech;
ShowDictionary();
ShowDictionary(document.getElementById("wordFilter").value);
SaveDictionary();
ClearForm();
CloseUpdateConflictArea();
@ -165,7 +165,7 @@ function DeleteWord(index) {
ClearForm();
currentDictionary.words.splice(index, 1);
ShowDictionary();
ShowDictionary(document.getElementById("wordFilter").value);
SaveDictionary();
CloseUpdateConflictArea();
@ -189,9 +189,7 @@ function ClearForm() {
}
function UpdateFilter() {
var filter = document.getElementById("wordFilter").value;
ShowDictionary(filter);
ShowDictionary(document.getElementById("wordFilter").value);
}
function ShowDictionary(filter) {
@ -244,14 +242,16 @@ function DictionaryEntry(itemIndex) {
entryText += "<br>";
if (currentDictionary.words[itemIndex].simpleDefinition != "") {
entryText += "<simpledefinition> ==> " + currentDictionary.words[itemIndex].simpleDefinition + "</simpledefinition>";
entryText += "<simpledefinition>" + currentDictionary.words[itemIndex].simpleDefinition + "</simpledefinition>";
}
if (currentDictionary.words[itemIndex].longDefinition != "") {
entryText += "<longdefinition>" + markdown.toHTML(htmlEntitiesParse(currentDictionary.words[itemIndex].longDefinition)) + "</longdefinition>";
}
entryText += ManagementArea(itemIndex);
if (!currentDictionary.settings.isComplete) {
entryText += ManagementArea(itemIndex);
}
entryText += "</entry>";
@ -264,7 +264,7 @@ function ManagementArea(itemIndex) {
managementHTML += "<span class='clickable editButton' onclick='EditWord(" + itemIndex + ")'>Edit</span>";
managementHTML += "<span class='clickable deleteButton' onclick='document.getElementById(\"delete" + itemIndex + "Confirm\").style.display = \"block\";'>Delete</span>";
managementHTML += "<div class='deleteConfirm' id='delete" + itemIndex + "Confirm' style='display:none;'>Are you sure you want to delete this entry?<br>";
managementHTML += "<div class='deleteConfirm' id='delete" + itemIndex + "Confirm' style='display:none;'>Are you sure you want to delete this entry?<br><br>";
managementHTML += "<span class='clickable deleteCancelButton' onclick='document.getElementById(\"delete" + itemIndex + "Confirm\").style.display = \"none\";'>No</span>";
managementHTML += "<span class='clickable deleteConfirmButton' onclick='DeleteWord(" + itemIndex + ")'>Yes</span>";
managementHTML += "</div>";
@ -282,11 +282,21 @@ function HideAbout() {
document.getElementById("aboutScreen").style.display = "none";
}
function ToggleCaseSensitiveOption() {
if (document.getElementById("dictionaryAllowDuplicates").checked) {
document.getElementById("dictionaryCaseSensitive").disabled = true;
} else {
document.getElementById("dictionaryCaseSensitive").disabled = false;
}
}
function ShowSettings() {
document.getElementById("settingsScreen").style.display = "block";
document.getElementById("dictionaryNameEdit").value = htmlEntitiesParse(currentDictionary.name);
document.getElementById("dictionaryDescriptionEdit").value = htmlEntitiesParse(currentDictionary.description);
document.getElementById("dictionaryPartsOfSpeechEdit").value = htmlEntitiesParse(currentDictionary.settings.partsOfSpeech);
document.getElementById("dictionaryAllowDuplicates").checked = currentDictionary.settings.allowDuplicates;
document.getElementById("dictionaryCaseSensitive").checked = currentDictionary.settings.caseSensitive;
document.getElementById("dictionaryIsComplete").checked = currentDictionary.settings.isComplete;
}
@ -299,12 +309,25 @@ function SaveSettings() {
CheckForPartsOfSpeechChange();
currentDictionary.settings.allowDuplicates = document.getElementById("dictionaryAllowDuplicates").checked;
currentDictionary.settings.caseSensitive = document.getElementById("dictionaryCaseSensitive").checked;
currentDictionary.settings.isComplete = document.getElementById("dictionaryIsComplete").checked;
ShowDictionary();
HideSettingsWhenComplete();
ShowDictionary(document.getElementById("wordFilter").value);
SaveDictionary();
}
function HideSettingsWhenComplete() {
if (currentDictionary.settings.isComplete) {
document.getElementById("hideIfComplete").style.display = "none";
} else {
document.getElementById("hideIfComplete").style.display = "block";
}
}
function CheckForPartsOfSpeechChange () {
if (htmlEntities(document.getElementById("dictionaryPartsOfSpeechEdit").value) != currentDictionary.settings.partsOfSpeech) {
if (htmlEntities(document.getElementById("dictionaryPartsOfSpeechEdit").value) != "") {
@ -345,7 +368,7 @@ function HideSettings() {
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?")) {
currentDictionary = JSON.parse(defaultDictionaryJSON);
ShowDictionary();
ShowDictionary("");
SaveDictionary();
SetPartsOfSpeech();
HideSettings();
@ -364,7 +387,10 @@ function LoadDictionary() {
}
tmpDictionary = null;
}
ShowDictionary();
HideSettingsWhenComplete();
ShowDictionary("");
SetPartsOfSpeech();
@ -414,11 +440,13 @@ function ImportDictionary() {
}
function WordIndex(word) {
for (var i = 0; i < currentDictionary.words.length; i++)
{
if ((!currentDictionary.settings.caseSensitive && currentDictionary.words[i].name.toLowerCase() == word.toLowerCase()) ||
(currentDictionary.settings.caseSensitive && currentDictionary.words[i].name == word)) {
return i;
if (!currentDictionary.settings.allowDuplicates) {
for (var i = 0; i < currentDictionary.words.length; i++)
{
if ((!currentDictionary.settings.caseSensitive && currentDictionary.words[i].name.toLowerCase() == word.toLowerCase()) ||
(currentDictionary.settings.caseSensitive && currentDictionary.words[i].name == word)) {
return i;
}
}
}
return -1;