-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.html
278 lines (227 loc) · 9.4 KB
/
api.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<html>
<head>
<title>API</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./img/368604041_840485437510684_2113001665853681955_n.jpg">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="styl.css">
<style>
body,h1,h2,h3,h4,h5,h6 {font-family: "Raleway", sans-serif}
body, html {
height: 100%;
line-height: 1.8;
}
/* Full height image header */
.bgimg-1 {
background-position: cnter;
background-size: cover;
background-image: url("img/368604041_840485437510684_2113001665853681955_n.jpg");
min-height: 180%;
}
.w3-bar .w3-button {
padding: 16px;
}
.cond{
padding: 10px;
margin: auto;
background: linear-gradient(to right, rgb(210, 56, 56), blue);
align-items: center;
justify-content: center;
}
</style>
</head>
<body>
<!-- Navbar (sit on top) -->
<div class="w3-top">
<div class="w3-bar w3-white w3-card" id="myNavbar">
<a href="#home" class="w3-bar-item w3-button w3-wide">LOGO</a>
<!-- Right-sided navbar links -->
<div class="w3-right w3-hide-small">
<a href="#about" class="w3-bar-item w3-button">ABOUT</a>
<a href="index.html" class="w3-bar-item w3-button"><i class="fa fa-user"></i> index</a>
<a href="java.html" class="w3-bar-item w3-button"><i class="fa fa-th"></i> java</a>
<a href="api.html" class="w3-bar-item w3-button"><i class="fa fa-usd"></i> api</a>
<a href="#contact" class="w3-bar-item w3-button"><i class="fa fa-envelope"></i> CONTACT</a>
</div>
<!-- Hide right-floated links on small screens and replace them with a menu icon -->
<a href="javascript:void(0)" class="w3-bar-item w3-button w3-right w3-hide-large w3-hide-medium" onclick="w3_open()">
<i class="fa fa-bars"></i>
</a>
</div>
</div>
<!-- Sidebar on small screens when clicking the menu icon -->
<nav class="w3-sidebar w3-bar-block w3-black w3-card w3-animate-left w3-hide-medium w3-hide-large" style="display:none" id="mySidebar">
<a href="javascript:void(0)" onclick="w3_close()" class="w3-bar-item w3-button w3-large w3-padding-16">Close ×</a>
<a href="#about" onclick="w3_close()" class="w3-bar-item w3-button">ABOUT</a>
<a href="#team" onclick="w3_close()" class="w3-bar-item w3-button">TEAM</a>
<a href="#work" onclick="w3_close()" class="w3-bar-item w3-button">WORK</a>
<a href="#pricing" onclick="w3_close()" class="w3-bar-item w3-button">PRICING</a>
<a href="#contact" onclick="w3_close()" class="w3-bar-item w3-button">CONTACT</a>
</nav>
<!-- Header with full-height image -->
<!-- Contact Section -->
<div class="w3-container w3-light-grey r2 w3-animate-zoom " style="padding:128px 16px" id="contact">
<h3 class="w3-center w3-black w3-padding-large w3-padding-32 ">API</h3>
<p class="w3-center w3-large w3-red w3-padding-22">Apiname</p>
<div style="margin-top:150px ">
<div class="cond">
<h1>API 1 </h1>
<h2>Click to change</h2>
<p id="demo1"></p>
<button onclick="myFunction()">Click</button>
<h2>API 2 : สร้าง input แล้วมีปุ่มให้ Click เพื่อเปลี่ยน Parameter ส่งไปพร้อมกับ api แล้วนำผลมาแสดง</h2>
<label for="nameInput">ชื่อ</label>
<input type="text" id="nameInput" placeholder="กรอกชื่อ">
<button onclick="getGender()">กดปุ๋ม</button>
<p id="result"></p>
<br>
<h1> Random Dog Image</h1>
<button onclick="fetchRandomDog()">คลิกเพื่อดูรูปภาพหมา</button>
<br>
<img id="dogImage" src="" alt="Random">
<h2>Coinbase API Demo</h2>
<div id="lastUpdateTime">
<p>Last Update Time: 22:28:31 </p>
</div>
<div id="prices">
<p>1 use =</p>
</div>
<h1>API4</h1>
<form
method="POST"
action="https://script.google.com/macros/s/AKfycbwjHow-eUpxz7qC__zHuOWdhwGr1bm6bKBf3-1GoSJbD_qP8oOtJ87AU0sx1OPBPF5Ycw/exec"
>
<input name="Email" type="email" placeholder="Email" required>
<input name="Name" type="text" placeholder="Name" required>
<button type="submit">Send</button>
</form>
<iframe width="80%" height="400" src="https://docs.google.com/spreadsheets/d/e/2PACX-1vQo9BzGHFDs6VTwkG0YIcs4QdwowBwysm2tA4pcPzhpWps-V68rtgT0dSeWam4VXHP8dbAR52oMIY9L/pubchart?oid=896376270&format=interactive" frameborder="0"></iframe>
<hr>
<iframe width="80%" height="400" src="https://docs.google.com/spreadsheets/d/e/2PACX-1vQo9BzGHFDs6VTwkG0YIcs4QdwowBwysm2tA4pcPzhpWps-V68rtgT0dSeWam4VXHP8dbAR52oMIY9L/pubhtml?gid=0&single=true"></iframe><hr>
</div>
<!-- Image of location/map -->
<img src="/img/20210522011402.jpg" class="w3-image w3-greyscale" style="width:100%;margin-top:48px">
</div>
</div>
<!-- Footer -->
<footer class="w3-center w3-grey w3-padding-64">
<a href="api.html" class="w3-button w3-light-grey"><i class="fa fa-arrow-up w3-margin-right"></i>To the top</a>
<div class="w3-xlarge w3-section">
<i class="fa fa-facebook-official w3-hover-opacity"></i>
<i class="fa fa-instagram w3-hover-opacity"></i>
<i class="fa fa-snapchat w3-hover-opacity"></i>
<i class="fa fa-pinterest-p w3-hover-opacity"></i>
<i class="fa fa-twitter w3-hover-opacity"></i>
<i class="fa fa-linkedin w3-hover-opacity"></i>
</div>
<p>Powered by <a href="https://www.w3schools.com/w3css/default.asp" title="W3.CSS" target="_blank" class="w3-hover-text-green">w3.css</a></p>
</footer>
<script>
// Modal Image Gallery ต้องมาทำตอ
function onClick(element) {
document.getElementById("img01").src = element.src;
document.getElementById("modal01").style.display = "block";
var captionText = document.getElementById("caption");
captionText.innerHTML = element.alt;
}
// Toggle between showing and hiding the sidebar when clicking the menu icon
var mySidebar = document.getElementById("mySidebar");
function w3_open() {
if (mySidebar.style.display === 'block') {
mySidebar.style.display = 'none';
} else {
mySidebar.style.display = 'block';
}
}
// Close the sidebar with the close button
function w3_close() {
mySidebar.style.display = "none";
}
function myFunction() {
fetch("https://catfact.ninja/fact")
.then(function(response){
return response.json()
})
.then(function(data){
let txt = "";
for (let x in data) {
txt += data[x] + " ";
document.getElementById("demo1").innerHTML = txt;
};
return data;
})
}
</script>
<script>
function getGender() {
const inputName = document.getElementById('nameInput').value;
const apiUrl = `https://api.genderize.io/?name=${inputName}`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
document.getElementById('result').innerText = `Name: ${data.name}, Gender: ${data.gender}, Probability: ${data.probability}`;
})
.catch(error => {
console.error('Error fetching gender data:', error);
});
}
</script>
<script>
function fetchRandomDog() {
// Fetch data from the API
fetch('https://random.dog/woof.json')
.then(response => response.json())
.then(data => {
const url = data.url;
// Update the image source with the fetched URL
document.getElementById('dogImage').src = url;
// Display the image
document.getElementById('dogImage').style.display = 'block';
})
.catch(error => {
console.error('Error fetching random dog:', error);
});
}
</script>
<script>
function fetchPrices() {
var now = new Date();
var currentTime = now.toLocaleTimeString();
fetch('https://api.coinbase.com/v2/exchange-rates?currency=USDT')
.then(response => response.json())
.then(data => {
displayPrices(data);
displayLastUpdateTime(currentTime);
})
.catch(error => {
console.error('Error fetching data:', error);
alert('Error fetching data. Please try again.');
});
}
function displayPrices(data) {
var pricesDiv = document.getElementById('prices');
var rates = data.data.rates;
var currencies = ['1INCH', 'AAVE', 'ABT', 'ACH', 'ACS', 'ADA', 'AED', 'BTC', 'ETH'];
var pricesHtml = '<p>1 USDT can buy:</p><ul>';
currencies.forEach(currency => {
if (rates[currency]) {
pricesHtml += `<li>${currency}: ${rates[currency]}</li>`;
} else {
pricesHtml += `<li>${currency}: N/A</li>`;
}
});
pricesHtml += '</ul>';
pricesDiv.innerHTML = pricesHtml;
}
function displayLastUpdateTime(currentTime) {
var updateTimeDiv = document.getElementById('lastUpdateTime');
updateTimeDiv.innerHTML = `<p>Last Update Time: ${currentTime}</p>`;
}
fetchPrices();
setInterval(fetchPrices, 3000);
</script>
</body>
</html>