-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoverview.html
More file actions
84 lines (80 loc) · 3.34 KB
/
Copy pathoverview.html
File metadata and controls
84 lines (80 loc) · 3.34 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Overview</title>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="/StocksAPP/pagination.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://pagination.js.org/dist/2.1.5/pagination.js"></script>
</head>
<body>
<div class="w3-panel">
<div class="w3-row w3-margin-bottom">
<div class="w3-bar w3-light-grey w3-border">
<a class="w3-bar-item w3-button w3-border-right" href="/StocksAPP">Home</a>
</div>
</div>
<div class="w3-row" >
<div class='w3-content' id="root"></div>
<div class='w3-content' id="pages"></div>
</div>
</div>
<script>
const country = location.href.split('#')[1]
if (country != undefined) {
function template(data) {
let txts = ''
for (let dt of data) {
const {country,name,symbol,last,high,low,change,change_percentage,turnover,currency} = dt;
const txt = `
<div class="w3-row w3-margin w3-card-4 w3-padding">
<h2 class="w3-center w3-serif">${name}</h2>
<div class="w3-half">
<img src="https://via.placeholder.com/350x250.png?text=${name}" class="w3-image">
</div>
<div class="w3-half">
<ul class="w3-ul w3-border w3-hoverable w3-serif">
<li>${country}</li>
<li>${name}</li>
<li>${symbol}</li>
<li>${currency}</li>
<li>Last:<b>${last}</b></li>
<li>High:<b>${high}</b></li>
<li>Low:<b>${low}</b></li>
<li>Change:<b>${change}</b></li>
<li>Change:<b>${change_percentage}</b></li>
<li>Turnover:<b>${turnover}</b></li>
</ul>
</div>
</div>
`
txts += txt;
}
document.getElementById('root').innerHTML = txts;
}
$('#pages').pagination({
dataSource: function(done){
$.ajax({
beforeSend: function() {
$('#root').html('Loading data from stockapi.deta.dev ...');
},
type: 'GET',
url: `https://stockapi.deta.dev/overview/${country}`,
success: function(response) {
done(response);
}
});
},
pageSize: 5,
callback: function(data, pagination) {
// template method of yourself
const html = template(data);
}
})
}
</script>
</body>
</html>