-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
216 lines (195 loc) · 6.42 KB
/
index.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>"WATCHLIST" System</title>
<link rel="icon" type="image/x-icon" href="images/favicon.ico" />
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<!-- Custom fonts -->
<link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="vendor/simple-line-icons/css/simple-line-icons.css" />
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Muli" rel="stylesheet" />
<!-- Custom CSS -->
<link href="css/custom.css" rel="stylesheet" />
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Datatable CSS & JS -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.16/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.16/datatables.min.js"></script>
</head>
<body id="page-top">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="#page-top"><img src="images/header-logo.png" class="img-responsive" /></a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">Menu<i class="fa fa-bars"></i></button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="#masthead">Home</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="#quotes">Quote List</a></li>
</ul>
</div>
</div>
</nav>
<!-- Header -->
<header class="masthead" id="masthead">
<div class="container h-100">
<div class="row h-100">
<div class="col-lg-12 my-auto">
<div class="header-content mx-auto text-center">
<h1 class="mb-5"><strong>"WATCHLIST"</strong><br />Managed our watchlist and monitor throughout the day!</h1>
<a href="#quotes" class="btn btn-outline btn-xl js-scroll-trigger">Let's Go!</a>
</div>
</div>
</div>
</div>
</header>
<!-- Quote List -->
<section class="quotes" id="quotes">
<div class="container">
<div class="section-heading text-center">
<h2>Quote <strong>List</strong></h2>
<p class="text-muted">Check out what you can do. You can add and remove stocks to monitor throughout the day!</p>
<hr>
</div>
<div class="row my-auto">
<div class="col-lg-12">
<div id="alertPlace"></div>
<form class="form-inline" id="addSymbol">
<input type="hidden" name="action" value="add" />
<input type="text" id="addSymbolInput" class="form-control" name="symbol" value="" placeholder="Enter a symbol..." />
<button type="submit" class="btn btn-outline btn-default">Add Symbol</button>
</form>
</div>
<div class="col-lg-12">
<table id="quoteList" class="mt-0 table table-striped" cellspacing="0" width="100%">
<thead>
<tr>
<th>Symbol</th>
<th>Symbol Name</th>
<th>Last Price</th>
<th>Change</th>
<th>% Change</th>
<th>Volume</th>
<th>Time</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<th>Symbol</th>
<th>Symbol Name</th>
<th>Last Price</th>
<th>Change</th>
<th>% Change</th>
<th>Volume</th>
<th>Time</th>
<th>Action</th>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<script>
$(document).ready(function() {
// Variable to hold request
var request;
// create and populate datatable
var table = $('#quoteList').DataTable({
"emptyTable": "There are no symbols in your watchlist, please add one.",
"paging": true,
"info": true,
"processing": true,
"serverSide": true,
"ajax": "get_data.php",
"columnDefs": [
{
"targets": [0,1,2,3,4,5,6],
"class": "text-center"
},
{
"targets": -1,
"data": null,
"class": "text-center",
"defaultContent": '<button><i class="fa fa-times"></i></button>'
}
]
});
// bind to the submit event of our form
$("#addSymbol").submit(function(event) {
event.preventDefault();
var values = $(this).serialize();
$.ajax({
url: "/api.php",
type: "POST",
dataType: 'json',
data: values ,
success: function (response) {
if (response.success)
{
$('#quoteList').dataTable().api().draw();
$('#addSymbolInput')[0].value = '';
$('#alertPlace').html('<div class="alert alert-success"><strong>Success!</strong> ' + response.errors + '</div>');
}
else
{
console.log(response.errors);
$('#alertPlace').html('<div class="alert alert-danger"><strong>Error!</strong> ' + response.errors + '</div>');
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
});
// bind the remove button
$('#quoteList tbody').on('click', 'button', function (event) {
event.preventDefault();
var row = table.row($(this).parents('tr'));
var remove_data = {
'action': 'remove',
'symbol': row.data()[0]
};
$.ajax({
url: "/api.php",
type: "POST",
dataType: 'json',
data: remove_data ,
success: function (response) {
if (response.success)
{
$('#quoteList').dataTable().api().row($(this).parents('tr')).remove().draw();
$('#alertPlace').html('<div class="alert alert-success"><strong>Success!</strong> ' + response.errors + '</div>');
}
else
{
console.log(response.errors);
$('#alertPlace').html('<div class="alert alert-danger"><strong>Error!</strong> ' + response.errors + '</div>');
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
});
});
</script>
<!-- Footer -->
<footer>
<div class="container">
<p>© 2017 Evgeny Barchukov. All Rights Reserved.</p>
</div>
</footer>
<!-- Plugin JavaScript -->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Custom JS -->
<script type="text/javascript" src="js/custom.js"></script>
</body>
</html>