From d8b3ab00c598ad69288b60c8ab883eedf243b55c Mon Sep 17 00:00:00 2001
From: Robbie Antenesse
Date: Fri, 30 Oct 2015 11:38:41 -0600
Subject: [PATCH] Added Allow Duplicates option Fixed Part of Speech Filter
Updated styling for entries Updated Dictionary is Complete functionality
---
css/styles.css | 29 ++++++++++++++++++-
index.html | 18 +++++++++---
js/dictionaryBuilder.js | 64 +++++++++++++++++++++++++++++------------
3 files changed, 88 insertions(+), 23 deletions(-)
diff --git a/css/styles.css b/css/styles.css
index 0c3d784..5811dd4 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -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 {
diff --git a/index.html b/index.html
index 4b331e6..1d68df0 100644
--- a/index.html
+++ b/index.html
@@ -76,8 +76,9 @@
Dictionary Settings
- The Allow Duplicates 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. Note: Allow Duplicates is not yet in the Settings menu!
+ The Allow Duplicates 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.
The Case-Sensitive 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.
- If Allow Duplicates is checked, this checkbox becomes unavailable. Note: Case-Sensitive is not yet in the Settings menu!
+ If Allow Duplicates is checked, this checkbox becomes unavailable.
The "Dictionary is complete" 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. Note: At the moment, ONLY the word form goes away. Nothing else in this paragraph is implemented yet!
diff --git a/js/dictionaryBuilder.js b/js/dictionaryBuilder.js
index a64ca0a..0211fc7 100644
--- a/js/dictionaryBuilder.js
+++ b/js/dictionaryBuilder.js
@@ -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 += "
";
if (currentDictionary.words[itemIndex].simpleDefinition != "") {
- entryText += " ==> " + currentDictionary.words[itemIndex].simpleDefinition + "";
+ entryText += "" + currentDictionary.words[itemIndex].simpleDefinition + "";
}
if (currentDictionary.words[itemIndex].longDefinition != "") {
entryText += "" + markdown.toHTML(htmlEntitiesParse(currentDictionary.words[itemIndex].longDefinition)) + "";
}
- entryText += ManagementArea(itemIndex);
+ if (!currentDictionary.settings.isComplete) {
+ entryText += ManagementArea(itemIndex);
+ }
entryText += "";
@@ -264,7 +264,7 @@ function ManagementArea(itemIndex) {
managementHTML += "Edit";
managementHTML += "Delete";
- managementHTML += "
Are you sure you want to delete this entry?
";
+ managementHTML += "
Are you sure you want to delete this entry?
";
managementHTML += "No";
managementHTML += "Yes";
managementHTML += "
";
@@ -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;