Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
2017-CSE-Senior-Project-Team-2/WebContent/html/javascript/listing.jsp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
152 lines (149 sloc)
4.71 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page import = "database.MySQLAccess" %> | |
<%@ 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> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
<title>Insert title here</title> | |
</head> | |
<body> | |
<% | |
MySQLAccess myaccess = new MySQLAccess(); | |
myaccess.connectDB(); | |
String name = myaccess.getResult()[0][0]; | |
String description = myaccess.getResult()[0][1]; | |
String hardware = myaccess.getResult()[0][2]; | |
System.out.println(name); | |
//out.println(description); | |
//out.println(hardware); | |
%> | |
<script type=text/javascript> | |
//gets variables for database data | |
/*(function(){ | |
window.myname = "<=name>" ; --> add percents to make them work in the name box things | |
window.mydesc = "<=description>" ; | |
window.myhard = "<=hardware>" ; | |
})(); */ | |
//get all the option buttons | |
var options = document.getElementsByClassName('option'); | |
/*var dev7 = { | |
name: window.myname, | |
description: window.mydesc, | |
hardware: window.myhard, | |
software:"intel" | |
};*/ | |
var dev1 = { | |
name:"George", | |
description:"George is probably the coolest iPhone to exist. Ever. Point blank, period.", | |
hardware:"iphone", | |
software:"apple" | |
}; | |
var dev2 = { | |
name:"Greyson", | |
description:"Greyson is pretty cool.. I guess.", | |
hardware:"iphone", | |
software:"apple" | |
}; | |
var dev3 = { | |
name:"Linkin Park", | |
description:'"The hardest part of ending is starting again."', | |
hardware:"ipad", | |
software:"apple" | |
}; | |
var dev4 = { | |
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 = { | |
name:"Hulk", | |
description:"Go ahead and HULK SMASH! this awesome computer stick into your USB.", | |
hardware:"computerStick", | |
software:"intel" | |
}; | |
var dev6 = { | |
name:"Captain America", | |
description:'"Make America Great Again. Wait, thats someone else.."', | |
hardware:"computerStick", | |
software:"intel" | |
}; | |
var devices = [dev1, dev2, dev3, dev4, dev5, dev6, dev7]; | |
options[0].addEventListener('click', showAll); | |
for(var a = 1; a < options.length; a++){ | |
options[a].addEventListener('click', show); | |
} | |
showAll(); | |
function showAll(){ | |
var html = ''; | |
for(var i = 0; i < devices.length; i++){ | |
html += '<div class = "deviceContainer"><div class = "imgContainer"><img src="../imgs/' + devices[i].hardware + '.png" class = "device">' + devices[i].name + '</div><div class = "deviceDescp"><p>' + devices[i].description + '</p><div class = "availableAnchor" id = "' + (i+1) + '"></div></div></div><br><br>'; | |
} | |
document.getElementById('devContainer').innerHTML = html; | |
var unavailable = getUnavailableItems(); | |
var anchors = document.getElementsByClassName('availableAnchor'); | |
for(var i = 0; i < anchors.length; i++){ | |
var anchor = anchors[i]; | |
var id = anchor.getAttribute('id'); | |
if(isUnavailable(id)){ | |
document.getElementById(id).innerHTML = 'Unavailable'; | |
id = '#' + id; | |
$(id).css({'background-color':'#ff3535'}); | |
} | |
else{ | |
document.getElementById(id).innerHTML = 'Available'; | |
id = '#' + id; | |
$(id).css({'background-color':'#1fe07f'}); | |
} | |
} | |
} | |
function show(){ | |
var type = this.getAttribute('data-type'); | |
var html = ''; | |
for(var i = 0; i < devices.length; i++){ | |
if(type.localeCompare(devices[i].hardware) == 0 || type.localeCompare(devices[i].software) == 0){ | |
html += '<div class = "deviceContainer"><div class = "imgContainer"><img src="../imgs/' + devices[i].hardware + '.png" class = "device">' + devices[i].name + '</div><div class = "deviceDescp"><p>' + devices[i].description + '</p><div class = "availableAnchor" id = "' + (i+1) + '"></div></div></div><br><br>' | |
} | |
} | |
document.getElementById('devContainer').innerHTML = html; | |
var unavailable = getUnavailableItems(); | |
var anchors = document.getElementsByClassName('availableAnchor'); | |
for(var i = 0; i < anchors.length; i++){ | |
var anchor = anchors[i]; | |
var id = anchor.getAttribute('id'); | |
if(isUnavailable(id)){ | |
document.getElementById(id).innerHTML = 'Unavailable'; | |
id = '#' + id; | |
$(id).css({'background-color':'#ff3535'}); | |
} | |
else{ | |
document.getElementById(id).innerHTML = 'Available'; | |
id = '#' + id; | |
$(id).css({'background-color':'#1fe07f'}); | |
} | |
} | |
} | |
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)) | |
return 1; | |
} | |
} | |
return 0; | |
} | |
</script> | |
</body> | |
</html> |