diff --git a/html/javascript/request.js b/html/javascript/request.js index b27d54e..f0a7022 100644 --- a/html/javascript/request.js +++ b/html/javascript/request.js @@ -2,63 +2,139 @@ var options = document.getElementsByClassName('option'); var dev1 = { + id: 1, name:"George", description:"George is probably the coolest iPhone to exist. Ever. Point blank, period.", hardware:"iphone", - software:"apple" + software:"apple", }; var dev2 = { + id: 2, name:"Greyson", description:"Greyson is pretty cool.. I guess.", hardware:"iphone", - software:"apple" + software:"apple", }; var dev3 = { + id: 3, name:"Linkin Park", description:'"The hardest part of ending is starting again."', hardware:"ipad", - software:"apple" + software:"apple", }; var dev4 = { + id: 4, name:"Abercrombie", description:"To all the people that hated me in high school, I have the prettiest clothes you all wear now!!", hardware:"ipad", - software:"apple" + software:"apple", }; var dev5 = { + id: 5, name:"Hulk", description:"Go ahead and HULK SMASH! this awesome computer stick into your USB.", hardware:"computerStick", - software:"intel" + software:"intel", }; var dev6 = { + id: 6, name:"Captain America", description:'"Make America Great Again. Wait, thats someone else.."', hardware:"computerStick", - software:"intel" + software:"intel", }; var devices = [dev1, dev2, dev3, dev4, dev5, dev6]; +//add event listeners to the options in the left sidebar for(var a = 0; a < options.length; a++){ var type = options[a].getAttribute('data-type'); options[a].addEventListener('click', show); } +//when an option is selected, show a new list of devices based on what the user asked for function show(){ + //get the option that you selected var type = this.getAttribute('data-type'); var html = ''; + //iterate through the hardcoded device DB and select all the ones that match the selected option for(var i = 0; i < devices.length; i++){ - if(type.localeCompare(devices[i].hardware) == 0 || type.localeCompare(devices[i].software) == 0){ - html += '
' + devices[i].description + '
' + devices[i].description + '