-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictionary.js
99 lines (69 loc) · 2.27 KB
/
dictionary.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//====================================================================
//
// D I C T I O N A R Y
//
//====================================================================
//===================================
// DICTIONARY VARIABLES
//===================================
// Build the myDictionary array.
var myDictionary = {
litigate: [
"litigation",
"litigations",
"litigate",
"litigated",
"litigates",
"litigator",
"litigators"
],
dispute: [
"dispute",
"disputed",
"disputes",
"disputer"
]
};
//===================================
// Search Box Searching Dictionary
//===================================
// Every time the user presses a key down
$("input#input-keyword").keydown(function() {
// Convert search to lowercase.
var mySearch = $(this).val().toLowerCase();
// Set 700ms timeout.
setTimeout(function() {
// Do results show up?
var myResults = $(".typeahead-list.typeahead-list--undefined.ng-scope.active");
// If the results menu appears...
if (myResults.length > 0) {
// Get new results.
var tempResults = $("button.typeahead-list-item");
// Run the function.
tempResults.each(function(e) {
// Setup variables.
var i = $("button.typeahead-list-item")[e].innerText;
// Something...
console.log(i);
});
}
}, 700);
});
// For every result...
for (x = 0; myResults.length > x; x++) {
// Go through our dictionary...
for (i = 0; myDictionary.length > i; i++) {
var myContainer = [];
// And search for our search phrase.
if (myResults[x].innerText.search(myDictionary[i]) !== -1) {
//console.log( 'SUCCESS - "' + myDictionary[i] + '" in [' + myResults[x].innerText + '].' );
var theHTML = String($(myResults[x].outerHTML)[0].innerHTML);
var theHTML = theHTML.replace(myDictionary[i], "<div class='linkText' style='display: inline; letter-spacing: 1px;'>" + myDictionary[i] + "</div>");
myContainer.push(theHTML);
}
}
// Change those colors.
myResults[x].innerHTML = theHTML;
}
}, 700);
});