-
Notifications
You must be signed in to change notification settings - Fork 1
/
resources.js
60 lines (54 loc) · 1.87 KB
/
resources.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
/*
Resource Search JS
Frank Giddens
November 3, 2018
*/
"use strict";
let socket = io.connect();
let resourceCard = "";
let resourceList = [];
document.getElementById("search").addEventListener("click", function(){
let filteredResources = [];
let testFilters = true;
for(let i = 0; i < resourceList.length; i++){
if(!document.getElementById("national").checked && resourceList[i].type == "national"){
testFilters = false;
}
else if(document.getElementById("city").value != "" && resourceList[i].city != document.getElementById("city").value){
testFilters = false;
}
else if(document.getElementById("state").value != "--" && resourceList[i].state != document.getElementById("state").value){
testFilters = false;
}
else if(document.getElementById("zipCode").value != "" && resourceList[i].zipCode != document.getElementById("zipCode").value){
testFilters = false;
}
if(document.getElementById("category").value != "--" && resourceList[i].category != document.getElementById("category").value){
testFilters = false;
}
if(testFilters){
filteredResources[filteredResources.length] = resourceList[i];
}
testFilters = true;
}
document.getElementById("foundResources").innerHTML = "";
for(i = 0; i < filteredResources.length; i++){
resourceCard = "<div class\"card\"><h5 class\"card-title\">";
resourceCard += filteredResources[i].group;
resourceCard += "</h5><p class\"card-body\">Phone: ";
resourceCard += filteredResources[i].phone;
if(filteredResource[i].type != "national"){
resourceCard += "<br/>";
resourceCard += filteredResources[i].city;
resourceCard += ", ";
resourceCard += filteredResources[i].state;
resourceCard += " ";
resourceCard += filteredResources[i].zipCode;
}
resourceCard += "</p></div>";
}
});
socket.on("gotResources", function(data){
resourceList = data.resources;
});
socket.emit("getResources", {});