Skip to content

Commit

Permalink
A couple adjusting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
clj13001 committed Apr 5, 2017
1 parent 0e5d59b commit 8b460df
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions WebContent/html/javascript/listing.jsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%@ page import = "database.*,entities.ListedDevice" %>
<%@ page import = "database.*,entities.Device" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
Expand All @@ -8,9 +8,9 @@
</head>
<body>
<%
ListedDevice[] mydevices = DeviceQueries.getAllDevices();
Device[] mydevices = DeviceQueries.getAllDevices();
//string representation of array.
String deviceString = ListedDevice.arrayToString(mydevices);
String deviceString = Device.arrayToString(mydevices);
//out.println(description);
//out.println(hardware);
%>
Expand Down
15 changes: 8 additions & 7 deletions WebContent/html/javascript/request.jsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%@ page import = "database.*,entities.ListedDevice" %>
<%@ page import = "database.*,entities.Device" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
Expand All @@ -8,9 +8,9 @@
</head>
<body>
<%
ListedDevice[] mydevices = DeviceQueries.getAllDevices();
Device[] mydevices = DeviceQueries.getAllDevices();
//string representation of array.
String deviceString = ListedDevice.arrayToString(mydevices);
String deviceString = Device.arrayToString(mydevices);
//out.println(description);
//out.println(hardware);
%>
Expand Down Expand Up @@ -68,7 +68,7 @@ function show(deviceArray){
// var type = this.getAttribute('data-type');
var html = '';
for (var i = 0; i < deviceArray.length; i++) {
html += '<div class = "deviceContainer"><div class = "imgContainer"><img src="../imgs/my-icons-collection-devices/png/' + deviceArray[i].hardware + '.png" class = "device">' + deviceArray[i].name + '</div><div class = "deviceDescp"><p>' + deviceArray[i].description + '</p><button class = "requestbutton" id = "button' + (i+1) + '" type="button">Order device</button></div></div><br><br>'
html += '<div class = "deviceContainer"><div class = "imgContainer"><img src="../imgs/my-icons-collection-devices/png/' + deviceArray[i].hardware + '.png" onerror="this.src=\'../imgs/synchrony-financial-logo-dlpx_1.png\';" class = "device">' + deviceArray[i].name + '</div><div class = "deviceDescp"><p>' + deviceArray[i].description + '</p><button class = "requestbutton" id = "button' + (deviceArray[i].id) + '" type="button">Order device</button></div></div><br><br>'
}
if(html.localeCompare("")==0)
Expand Down Expand Up @@ -175,9 +175,10 @@ function fuzzyFilter(deviceArray) {
}
function addToCart(){
var id = this.getAttribute('id');
id = parseInt(id.replace(/[^0-9\.]/g,''),10); //this gets just the numerical value from the id!
id = id.replace(/[^0-9\.]/g,'');
if(!inCart(id)){ //if not in the cart
var cart = getCartItems(); //this is an array
id = parseInt(id,10); //this gets just the numerical value from the id!
cart.push(devices[id - 1]); //push to bottom of cart
localStorage.setItem('cart', JSON.stringify(cart));
$('#added').fadeIn(1000);
Expand All @@ -196,7 +197,7 @@ function inCart(id){
return 0;
else{ //something is in the cart
for(var i = 0; i < cart.length; i++){
if(cart[i] === id)
if(id.localeCompare(cart[i].id) == 0)
return 1;
}
}
Expand All @@ -205,7 +206,7 @@ function inCart(id){
function getCartItems(){
//initiate array for them
var cart = new Array;
//get them from local storage
//get them from local age
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 !== "") {
Expand Down
2 changes: 1 addition & 1 deletion WebContent/html/webpages/requestPage.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<li><label><input type="checkbox" class="hw-data-type" data-type = "Computer"> Computers</label></li>
<li><label><input type="checkbox" class="hw-data-type" data-type = "Camera"> Cameras</label></li>
<li><label><input type="checkbox" class="hw-data-type" data-type = "Smartphone"> Smartphone</label></li>
<li><label><input type="checkbox" class="hw-data-type" data-type = "Storage"> Storage Devices</label></li>
<li><label><input type="checkbox" class="hw-data-type" data-type = "Storage Device"> Storage Devices</label></li>
<li><label><input type="checkbox" class="hw-data-type" data-type = "Tablet"> Tablet</label></li>
<li><label><input type="checkbox" class="hw-data-type" data-type = "Other"> Other</label></li> <!-- same -->
</ul>
Expand Down

0 comments on commit 8b460df

Please sign in to comment.