-
Notifications
You must be signed in to change notification settings - Fork 0
/
interview.html
101 lines (93 loc) · 2.88 KB
/
interview.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<html ng-app="Flatlanders">
<head>
<title>Flatlanders angular</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<div class="container" ng-controller="StoreController">
<div class="row">
<div class="col-md-12">
<div class="jumbotron">
<h1>Flatlanders</h1>
<h4>Buy all your gems and gem accessories here!</h4>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h1>Items to Buy</h1>
<table class="table table-bordered table-striped" id="gemTable">
<thead>
<tr>
<th>Item</th>
<th>Quantity in stock</th>
<th>Price</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="gem in gems">
<td>{{gem.item}}</td>
<td>{{gem.quantity}}</td>
<td>{{gem.price}}</td>
<td ng-if="gem.quantity > 0">
<button class='btn btn-primary' ng-click="buy(gem.index)">Buy!</button>
</td>
<td ng-if="gem.quantity <= 0">
<button class='btn btn-primary' disabled>Buy!</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h1>Items Purchased</h1>
<table class="table table-bordered table-striped" id="purchasedItems">
<thead>
<tr>
<th>Item</th>
<th>Quantity purchased</th>
<th>Price</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in gems | filter: getOnlyPurchased ">
<td>{{item.item}}</td>
<td>{{item.numberPurchased}}</td>
<td>{{item.price}}</td>
<td><button class='btn btn-danger' ng-click="sell(item.index)">Sell!</button></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h5>Amount purchased: ${{amountPurchased}}</h5>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script type="text/javascript">
var gems = [
{item: "Ruby", quantity: 15, price: 3499, index: 0},
{item: "Diamond", quantity: 10, price: 8753, index: 1},
{item: "Emerald", quantity: 87, price: 2343, index: 2},
{item: "Crystal", quantity: 34, price: 123, index: 3},
{item: "Gold", quantity: 105, price: 6735, index: 4}
]
var purchasedItems = [];
var totalPurchased = 0;
</script>
</body>
</html>