' + devices[i].description + '
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"%> + + + + +Checked out: " - htmlString+=checkout.toISOString().substring(0,10); - htmlString+="
You've had this device for "; - var milliseconds=new Date().getTime()-checkout.getTime(); - var seconds=Math.floor(milliseconds/1000); - var minutes=Math.floor(seconds/60); - var hours=Math.floor(minutes/60); - var days=Math.floor(hours/24); - var weeks=Math.floor(days/7); - var months=Math.floor(weeks/4); - if(months>=2) htmlString+=months+" months"; - else - { - htmlString+= weeks+ " week"; - if(weeks!=1) htmlString+="s"; - } - htmlString+="!"; - htmlString+="
Approved!
-Approved!
+Name | +Address | +Town | +State | +Zip Code | +
---|
You shouldn't be seeing this page :)
+ +<% +//make instance +MySQLAccess myaccess = new MySQLAccess(); +String name = request.getParameter("name").replace("\"","\\\""); +String address = request.getParameter("address").replace("\"","\\\""); +String town = request.getParameter("town").replace("\"","\\\""); +String state = request.getParameter("state"); +String zip = request.getParameter("zip"); +//add form was submitted +if(request.getParameter("add") != null){ + Location location = new Location(name,address,town,state,zip); + myaccess.addLocation(location); +} +//modify form was submitted +if(request.getParameter("modify") != null){ + //getParameter() always returns string + String strID = request.getParameter("id"); + //turn to int for constructor + int id = Integer.parseInt(strID); + Location location = new Location(id,name,address,town,state,zip); + myaccess.modifyLocation(location); +} +//delete form was submitted +if(request.getParameter("delete") != null){ + String strID = request.getParameter("id"); + int id = Integer.parseInt(strID); + myaccess.deleteLocation(id); +} +%> + + + + + \ No newline at end of file diff --git a/WebContent/html/webpages/map.html b/WebContent/html/webpages/map.html index 5256954..09d9fec 100644 --- a/WebContent/html/webpages/map.html +++ b/WebContent/html/webpages/map.html @@ -1,89 +1,89 @@ - - - - - - - - - -Change profile image:
+ +Already in Cart
- + <%@ include file="../javascript/request.jsp" %> \ No newline at end of file diff --git a/WebContent/html/webpages/returnComplete.jsp b/WebContent/html/webpages/returnComplete.jsp new file mode 100644 index 0000000..08a267d --- /dev/null +++ b/WebContent/html/webpages/returnComplete.jsp @@ -0,0 +1,39 @@ +<%@ page import = "database.MySQLAccess,entities.RentedDevice" %> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + + + + + + + +Thanks for returning some devices!
+ +<% +//make instance +MySQLAccess myaccess = new MySQLAccess(); +//get string from request form +String devices = request.getParameter("devicesToReturn"); +myaccess.returnDevices(devices); +%> + + + + \ No newline at end of file diff --git a/WebContent/html/webpages/returnPage.html b/WebContent/html/webpages/returnPage.html deleted file mode 100644 index fdcda6c..0000000 --- a/WebContent/html/webpages/returnPage.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - -Returned
-