Added word count for searching/filtering.

This commit is contained in:
Robbie Antenesse 2016-01-18 12:14:36 -07:00
parent d7332cb159
commit 9ec5ca325f
6 changed files with 29 additions and 0 deletions

View File

@ -204,6 +204,13 @@ input[type=checkbox] {
margin: 10px 0; margin: 10px 0;
} }
#filterWordCount {
margin: 10px 10px;
display: block;
font-weight: bold;
font-style: italic;
}
entry { entry {
display: block; display: block;
width: 90%; width: 90%;

View File

@ -118,6 +118,8 @@ require_once(SITE_LOCATION . '/php/notificationconditiontree.php');
<option value="">All</option> <option value="">All</option>
</select> </select>
</label> </label>
<div id="filterWordCount"></div>
</div> </div>
<div id="theDictionary"></div> <div id="theDictionary"></div>

View File

@ -219,6 +219,7 @@ function ShowDictionary() {
var dictionaryArea = document.getElementById("theDictionary"); var dictionaryArea = document.getElementById("theDictionary");
var dictionaryText = ""; var dictionaryText = "";
var numberOfWordsDisplayed = 0;
if (currentDictionary.words.length > 0) { if (currentDictionary.words.length > 0) {
for (var i = 0; i < currentDictionary.words.length; i++) { for (var i = 0; i < currentDictionary.words.length; i++) {
@ -231,6 +232,7 @@ function ShowDictionary() {
currentDictionary.words[i].wordId = i + 1; //Account for new property currentDictionary.words[i].wordId = i + 1; //Account for new property
} }
dictionaryText += DictionaryEntry(i); dictionaryText += DictionaryEntry(i);
numberOfWordsDisplayed++;
} }
} }
} }
@ -239,6 +241,7 @@ function ShowDictionary() {
} }
dictionaryArea.innerHTML = dictionaryText; dictionaryArea.innerHTML = dictionaryText;
ShowFilterWordCount(numberOfWordsDisplayed);
} }
function DictionaryEntry(itemIndex) { function DictionaryEntry(itemIndex) {

View File

@ -53,6 +53,7 @@ function ShowPublicDictionary() {
var dictionaryArea = document.getElementById("theDictionary"); var dictionaryArea = document.getElementById("theDictionary");
var dictionaryText = ""; var dictionaryText = "";
var numberOfWordsDisplayed = 0;
if (publicDictionary.words.length > 0) { if (publicDictionary.words.length > 0) {
for (var i = 0; i < publicDictionary.words.length; i++) { for (var i = 0; i < publicDictionary.words.length; i++) {
@ -65,6 +66,7 @@ function ShowPublicDictionary() {
publicDictionary.words[i].wordId = i + 1; //Account for new property publicDictionary.words[i].wordId = i + 1; //Account for new property
} }
dictionaryText += PublicDictionaryEntry(i); dictionaryText += PublicDictionaryEntry(i);
numberOfWordsDisplayed++;
} }
} }
} }
@ -72,6 +74,7 @@ function ShowPublicDictionary() {
dictionaryText = "There are no entries in the dictionary." dictionaryText = "There are no entries in the dictionary."
} }
dictionaryArea.innerHTML = dictionaryText; dictionaryArea.innerHTML = dictionaryText;
ShowFilterWordCount(numberOfWordsDisplayed);
} else { } else {
document.getElementById("dictionaryContainer").innerHTML = publicDictionary; document.getElementById("dictionaryContainer").innerHTML = publicDictionary;
} }

View File

@ -379,6 +379,18 @@ function SetPartsOfSpeech () {
} }
} }
function ShowFilterWordCount(numberOfWords) {
var filter = document.getElementById("wordFilter").value;
var search = htmlEntitiesParseForSearchEntry(document.getElementById("searchBox").value);
var wordCounter = document.getElementById("filterWordCount");
if (filter != "" || search != "") {
wordCounter.innerHTML = "Showing " + numberOfWords.toString() + " result" + ((numberOfWords > 1) ? "s" : "");
} else {
wordCounter.innerHTML = "";
}
}
function HideSettings() { function HideSettings() {
document.getElementById("settingsScreen").style.display = "none"; document.getElementById("settingsScreen").style.display = "none";
document.getElementById("wordEntryForm").style.display = (currentDictionary.settings.isComplete) ? "none" : "block"; document.getElementById("wordEntryForm").style.display = (currentDictionary.settings.isComplete) ? "none" : "block";

View File

@ -102,6 +102,8 @@ catch (PDOException $ex) {}
<option value="">All</option> <option value="">All</option>
</select> </select>
</label> </label>
<div id="filterWordCount"></div>
</div> </div>
<div id="theDictionary"></div> <div id="theDictionary"></div>