forked from PitchforkEmporium/pitchforkemporium.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.html
74 lines (73 loc) · 4.24 KB
/
checkout.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<html>
<head>
<link rel="icon" href="http://picturelements.github.io/pitchforkemporium/PEicon.png">
<link href='https://fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,900' rel='stylesheet' type='text/css'>
<link href='pitchfork.css' rel='stylesheet' type='text/css'>
<script>
function setCart(){
var pitchforks=[],info=[],no=[];
var items=0,tot=sessionStorage.getItem("userItems");
items=sessionStorage.getItem("userItemsFull");
if (items==null){items=0;}
if (sessionStorage.getItem("username")==null){
document.getElementById("innerdisplay").style="text-align:center; font-size:5vw; height:500px; line-height:500px; font-family:Roboto,Arial,sans-serif; font-weight:900;";
document.getElementById("innerdisplay").innerHTML="<a href=\"http:\/\/pitchforkemporium.github.io/login\" style=\"text-decoration:none;\">Log in to purchase</a>";
}else if(tot==0){
document.getElementById("innerdisplay").style="text-align:center; font-size:5vw; height:500px; line-height:500px; font-family:Roboto,Arial,sans-serif; font-weight:900;";
document.getElementById("innerdisplay").innerHTML="Cart empty";
}else{
document.getElementById("checkoutheader").style.display="block";
var isDuplicate;
for (i=0;i<items;i++){
var check=sessionStorage.getItem("item"+i);
isDuplicate=0;
for (n=0;n<pitchforks.length;n++){
if (check==pitchforks[n]&&check!=""){isDuplicate=1; no[n]++; break;}
}
if (check==""){isDuplicate=1;}
if (isDuplicate==0&&check!=null){ //code should work without check!=null...
pitchforks.push(check);
info.push(sessionStorage.getItem("info"+i));
no.push(1);
}
}
var outStr="<table><tr><th>Type</th><th>Model number</th><th>Price</th><th>Quantity</th><th>Total</th></tr>";
var totSum=0;
for (i=0;i<pitchforks.length;i++){
var pitch=pitchforks[i];
var sum=0;
for (n=0;n<pitch.length;n++){sum+=pitch.charCodeAt(n);}
sum=Math.floor(sum/10)*10;
outStr+="<tr><td>"+pitchforks[i]+"</td><td>"+info[i]+"</td><td>"+sum+" karma</td><td>"+no[i]+"</td><td>"+sum*no[i]+" karma</td></tr>";
totSum+=sum*parseInt(no[i]);
}
outStr+="</table><br><br><table style=\"margin-bottom:3vw\"><tr><th>Total quantity</th><th>Grand total</th><th>Balance</th></tr><tr><td>"+tot+"</td><td>"+totSum+" karma</td><td>"+(sessionStorage.getItem("userBalance"))+" karma</td></tr></table>";
document.getElementById("innerdisplay").innerHTML=outStr;
}
}
</script>
</head>
<body onload=setCart()>
<div id="wrapper">
<div id="header">
<div id="name"><a href="http://pitchforkemporium.github.io/products">Pitchfork Emporium</a></div>
<div id="subtitle">Premium source of anti-OP wares</div>
</div>
<div id="content">
<div id="displayBox" style="margin-top:50px; font-family:Roboto,Arial,sans-serif;">
<div id="checkoutheader" style="display: none; position: relative;width: 90%;left: 5%;text-align: center;font-family: Roboto, Arial, sans-serif;font-weight: 900;font-size: 3vw;margin-top: 1vw;margin-bottom: 1.5vw;border-bottom: 1px dashed #ccc;">Checkout</div>
<div id="innerdisplay" style="display:block; position:relative; width:100%; min-height:50px; font-family:Roboto,Arial,sans-serif;"></div>
<!--<div id="checkInner" style="display:block; position:absolute; width:90%; height:90%; top:5%; left:5%; font-family:Roboto,Arial,sans-serif; font-weight:900;"></div>-->
</div>
</div>
<div id="footer">
<inner>
Pitchfork Emporium reserves the right to test-stab OP before wares are shipped. Any damages induced during stabbing will be repaired by the Pitchfork Emporium repairs and replacement division free of charge. Pitchforks misused to move or stack hay void all warranty.
<br><br>
© 2016 Pitchfork Emporium Industries
</inner>
</div>
</div>
</body>
</html>