diff --git a/WebContent/html/javascript/listing.jsp b/WebContent/html/javascript/listing.jsp index b9b2c73..64ca8fc 100644 --- a/WebContent/html/javascript/listing.jsp +++ b/WebContent/html/javascript/listing.jsp @@ -1,183 +1,128 @@ -<%@ page import = "database.MySQLAccess,entities.ListedDevice" %> -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - -Insert title here - - -<% -MySQLAccess myaccess = new MySQLAccess(); -ListedDevice[] mydevices = myaccess.getAllDevices(); - -//string representation of array. -String deviceString = ListedDevice.arrayToString(mydevices); -//out.println(description); -//out.println(hardware); - -%> - - - +<%@ page import = "database.MySQLAccess,entities.ListedDevice" %> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> + + + + +Insert title here + + +<% +MySQLAccess myaccess = new MySQLAccess(); +ListedDevice[] mydevices = myaccess.getAllDevices(); + +//string representation of array. +String deviceString = ListedDevice.arrayToString(mydevices); +//out.println(description); +//out.println(hardware); + +%> + + + \ No newline at end of file diff --git a/WebContent/html/javascript/navbar.js b/WebContent/html/javascript/navbar.js index 3e706ea..ba46607 100644 --- a/WebContent/html/javascript/navbar.js +++ b/WebContent/html/javascript/navbar.js @@ -1 +1 @@ -document.getElementById('navbaruniversal').innerHTML = '
' +document.getElementById('navbaruniversal').innerHTML = '
' diff --git a/WebContent/html/javascript/request.js b/WebContent/html/javascript/request.js deleted file mode 100644 index 62ebde9..0000000 --- a/WebContent/html/javascript/request.js +++ /dev/null @@ -1,193 +0,0 @@ -//get all the option buttons - -var hardwareOptions = document.getElementsByClassName('hw-data-type'); -var softwareOptions = document.getElementsByClassName('sw-data-type'); - - -function ajaxFunction(){ - var request; - try { - request = new XMLHttpRequest(); - } - catch(e){ - try { - request = new ActiveXObject("Msxml2.XMLHTTP"); - } - catch(e){ - try { - request = new ActiveXObject(Microsoft.XMLHTTP); - } catch(e) { - alert("Something is wrong with your browser"); - return false; - } - - } - } - - - request.onreadystatechange = function(){ - if(request.readyState == 4){ - var display = document.getElementById('ajaxDiv'); - display.innerHTML = request.responseText; - } - } - -} -var dev1 = { - id: 1, - name:"George", - description:"George is probably the coolest iPhone to exist. Ever. Point blank, period.", - hardware:"iphone", - software:"apple", -}; - -var dev2 = { - id: 2, - name:"Greyson", - description:"Greyson is pretty cool.. I guess.", - hardware:"iphone", - software:"apple", -}; - -var dev3 = { - id: 3, - name:"Linkin Park", - description:'"The hardest part of ending is starting again."', - hardware:"ipad", - 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", -}; - -var dev5 = { - id: 5, - name:"Hulk", - description:"Go ahead and HULK SMASH! this awesome computer stick into your USB.", - hardware:"computerStick", - software:"intel", -}; - -var dev6 = { - id: 6, - name:"Captain America", - description:'"Make America Great Again. Wait, thats someone else.."', - hardware:"computerStick", - 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++){ - 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(){ - - currentFilter = readFilter(); - selectedDevices = getDevices(currentFilter); //when connor is done with the database library getDevices should be redirected there - - - - 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((hw_type.localeCompare(devices[i].hardware) == 0 && sw_type.localeCompare(devices[i].software) == 0) && !isUnavailable(i)){ - html += '
' + devices[i].name + '

' + devices[i].description + '



' - } - } - - if(html.localeCompare("")==0) - html += "

There are no devices with the search criteria: " + this.textContent + "

"; - - //add to HTML page - document.getElementById('devContainer').innerHTML = html; - - //now we need to add event listeners to all the request buttons - var requestbuttons = document.getElementsByClassName('requestbutton'); - for(var i = 0; i < requestbuttons.length; i++){ - requestbuttons[i].addEventListener('click',addToCart); - } -} - -function readFilter() { - //Constrcts a filter object for use in the database library that corresponds to the checked optionsin the sidebar - var hw_type; - var sw_type; - -} - -function addToCart(){ - var id = this.getAttribute('id'); - id = parseInt(id.replace(/[^0-9\.]/g,''),10); //this gets just the numerical value from the id! - if(!inCart(id)){ //if not in the cart - var cart = getCartItems(); //this is an array - cart.push(id); //push to bottom of cart - localStorage.setItem('cart', JSON.stringify(cart)); - $('#added').fadeIn(1000); - $('#added').fadeIn(1000); - $('#added').fadeOut(1000); - } - else{ - $('#already').fadeIn(1000); - $('#already').fadeIn(1000); - $('#already').fadeOut(1000); - } -} - -function inCart(id){ - var cart = getCartItems(); - if(cart.length == 0) //if nothing's in the cart - return 0; - else{ //something is in the cart - for(var i = 0; i < cart.length; i++){ - if(cart[i] === id) - return 1; - } - } - return 0; -} - -function getCartItems(){ - //initiate array for them - var cart = new Array; - //get them from local storage - var cart_str = localStorage.getItem('cart'); - //if there is at least one object already we need to convert it from JSON to string - if (cart_str !== null && cart_str !== "") { - cart = JSON.parse(cart_str); - } - return cart; -} - -function getUnavailableItems(){ - var unavailable = new Array; - var unavailable_str = localStorage.getItem('unavailable'); - if(unavailable_str !== "" && unavailable_str !== null){ - unavailable = JSON.parse(unavailable_str); - } - return unavailable; -} - -function isUnavailable(id){ - var unavailable = getUnavailableItems(); - if(unavailable.length == 0) - return 0; - else{ - for(var i = 0; i < unavailable.length; i++){ - if(unavailable[i] == (id+1)) - return 1; - } - } - return 0; -} - -//this code allows a message to appear that indicates that the item was successfully placed in the shopping cart. diff --git a/WebContent/html/javascript/request.jsp b/WebContent/html/javascript/request.jsp new file mode 100644 index 0000000..b1cca96 --- /dev/null +++ b/WebContent/html/javascript/request.jsp @@ -0,0 +1,195 @@ +<%@ page import = "database.MySQLAccess,entities.ListedDevice" %> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> + + + + +Insert title here + + +<% +MySQLAccess myaccess = new MySQLAccess(); +ListedDevice[] mydevices = myaccess.getAllDevices(); + +//string representation of array. +String deviceString = ListedDevice.arrayToString(mydevices); +//out.println(description); +//out.println(hardware); + +%> + + + + \ No newline at end of file diff --git a/WebContent/html/webpages/index.html b/WebContent/html/webpages/index.html index 5f5a100..20bd2a7 100644 --- a/WebContent/html/webpages/index.html +++ b/WebContent/html/webpages/index.html @@ -47,7 +47,7 @@