Skip to content

Commit

Permalink
Now tickets have a ticket background image
Browse files Browse the repository at this point in the history
  • Loading branch information
clj13001 committed Nov 29, 2016
1 parent bb28155 commit 5adee7c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
Binary file added html/imgs/ticket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 26 additions & 4 deletions html/javascript/shoppingCart.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//here are all the hardcoded devices

var array = new Array;
localStorage.setItem('unavailable',JSON.stringify(array));

var dev1 = {
id: 1,
name:"George",
Expand Down Expand Up @@ -82,7 +79,7 @@ function show(){
var id = cart[i]; //this gets the id value from the cart
for(var j = 0; j < devices.length; j++){ //iterate device list
if(devices[j].id === id){ //match the id's
html += '<div> <input class = "deviceCheckbox" type = "checkbox" id = "' + id + '"> </input>' + devices[j].name + '</div>'; //create listing of all the devices
html += '<div> <input class = "deviceCheckbox" type = "checkbox" id = "' + id + '"> </input><a class = "divlink" href = "#"><div id = "ticket' + id +'" class = "ticket"><p class = "tickettext">' + devices[j].name + '</p></div></a></div>'; //create listing of all the devices
break; //break out of loop when we match
}
}
Expand All @@ -98,6 +95,31 @@ function show(){
for(var i = 0; i < checkboxes.length; i++){ //iterate them
checkboxes[i].addEventListener('click',changeStatus); //when we click on a checkbox, it should add/remove the id from the selected array
}

var tickets = document.getElementsByClassName('ticket');
for(var i = 0; i < tickets.length; i++){
tickets[i].addEventListener('click',clickTicket);
}
}

/**
This allows a ticket click to do the same thing as clicking on the checkbox.
**/
function clickTicket(){
var checkboxes = document.getElementsByClassName('deviceCheckbox');
var id = this.getAttribute('id');
id = parseInt(id.replace(/[^0-9\.]/g,''),10);
if(document.getElementById(id).checked == true){
document.getElementById(id).checked = false;
for(var i = 0; i < checked.length; i++){ //iterate checked array
if(id == checked[i]) //find the right checkbox
checked.splice(i,1); //remove from the array
}
}
else{
document.getElementById(id).checked = true;
checked.push(id);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion html/webpages/requestPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h4>Operating Systems</h4>
</div>

<div class = "displayDevice">
<h2>Available Devices</h2>
<h2>Available Devices</h2>
<div id = "devContainer"></div>
</div>

Expand Down
16 changes: 15 additions & 1 deletion html/webpages/shoppingCart.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
position: absolute;
padding-left: 30px;
}

div.ticket{
background-image: url('../imgs/ticket.png');
display: inline-block;
height: 126px;
width: 240px;
}

p.tickettext{
text-align: center;
vertical-align: middle;
line-height: 126px;
}
</style>

</head>
Expand Down Expand Up @@ -71,10 +84,11 @@ <h4>Shopping Cart Options</h4>
</div>

<div class = "displayDevice">
<h2>Welcome to your shopping cart!</h2>
<div id="shoppingContainer">
</div>
</div>

<script src="../javascript/shoppingCart.js"></script>
</body>
</html>

0 comments on commit 5adee7c

Please sign in to comment.