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;
}
#filterWordCount {
margin: 10px 10px;
display: block;
font-weight: bold;
font-style: italic;
}
entry {
display: block;
width: 90%;

View File

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

View File

@ -219,6 +219,7 @@ function ShowDictionary() {
var dictionaryArea = document.getElementById("theDictionary");
var dictionaryText = "";
var numberOfWordsDisplayed = 0;
if (currentDictionary.words.length > 0) {
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
}
dictionaryText += DictionaryEntry(i);
numberOfWordsDisplayed++;
}
}
}
@ -239,6 +241,7 @@ function ShowDictionary() {
}
dictionaryArea.innerHTML = dictionaryText;
ShowFilterWordCount(numberOfWordsDisplayed);
}
function DictionaryEntry(itemIndex) {

View File

@ -53,6 +53,7 @@ function ShowPublicDictionary() {
var dictionaryArea = document.getElementById("theDictionary");
var dictionaryText = "";
var numberOfWordsDisplayed = 0;
if (publicDictionary.words.length > 0) {
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
}
dictionaryText += PublicDictionaryEntry(i);
numberOfWordsDisplayed++;
}
}
}
@ -72,6 +74,7 @@ function ShowPublicDictionary() {
dictionaryText = "There are no entries in the dictionary."
}
dictionaryArea.innerHTML = dictionaryText;
ShowFilterWordCount(numberOfWordsDisplayed);
} else {
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() {
document.getElementById("settingsScreen").style.display = "none";
document.getElementById("wordEntryForm").style.display = (currentDictionary.settings.isComplete) ? "none" : "block";

View File

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