diff --git a/WebContent/html/javascript/listing.jsp b/WebContent/html/javascript/listing.jsp
index 58a50b1..9ff0462 100644
--- a/WebContent/html/javascript/listing.jsp
+++ b/WebContent/html/javascript/listing.jsp
@@ -24,11 +24,16 @@ String deviceString = ListedDevice.arrayToString(mydevices);
var devices = makeDeviceArray();
//get all the option buttons
-var options = document.getElementsByClassName('option');
+//var options = document.getElementsByClassName('checkboxes');
+var hardwareOptions = document.getElementsByClassName('hw-data-type');
+var softwareOptions = document.getElementsByClassName('sw-data-type');
-options[0].addEventListener('click', showAll);
-for(var a = 1; a < options.length; a++){
- options[a].addEventListener('click', show);
+//options[0].addEventListener('click', showAll);
+for(var a = 0; a < hardwareOptions.length; a++){
+ hardwareOptions[a].addEventListener('click', show);
+}
+for(var a = 0; a < softwareOptions.length; a++){
+ softwareOptions[a].addEventListener('click', show);
}
showAll();
function showAll(){
@@ -56,8 +61,44 @@ function showAll(){
function show(){
var type = this.getAttribute('data-type');
var html = '';
+ var activeHOptions = [];
+ var activeSOptions = [];
+ for(var i = 0; i < hardwareOptions.length; i++) {
+ if (hardwareOptions[i].checked == true) {
+ activeHOptions.push(hardwareOptions[i].getAttribute("data-type"));
+ }
+ }
+ for(var i = 0; i < softwareOptions.length; i++) {
+ if (softwareOptions[i].checked == true) {
+ activeSOptions.push(softwareOptions[i].getAttribute("data-type"));
+ }
+ }
for(var i = 0; i < devices.length; i++){
- if(type.localeCompare(devices[i].hardware) == 0 || type.localeCompare(devices[i].model) == 0){
+ var hardwareMatch = false;
+ var softwareMatch = false;
+
+ for(var j = 0; j < activeHOptions.length; j++) {
+ if (activeHOptions[j] == devices[i].hardware){
+ hardwareMatch = true;
+ }
+ }
+
+ if (activeHOptions.length == 0) {
+ hardwareMatch = true;
+ }
+
+ for(var j = 0; j < activeSOptions.length; j++) {
+ if (activeSOptions[j] == devices[i].manufacturer){
+ softwareMatch = true;
+ }
+ }
+
+ if (activeSOptions.length == 0) {
+ softwareMatch = true;
+ }
+
+
+ if(hardwareMatch == true && softwareMatch == true){
html += '
' + devices[i].name + '
' + devices[i].description + '
'
}
}
@@ -78,33 +119,6 @@ function show(){
}
}
}
- //Generates html and writes to 'devContainer' div in JSP
- function populateDeviceList(){
- //begin empty html
- var htmlString="";
- //iterate returned devices
- for (var i = 0; i < devices.length; i++) {
- //get device values
- var id = devices[i].id;
- var name = devices[i].name;
- var hardware = devices[i].hardware;
- var checkout = devices[i].checkout;
- //HTML representation in divs
- htmlString+="