-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
30 lines (30 loc) · 984 Bytes
/
script.js
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
window.addEventListener('load', () => {
loadData();
});
function reloadpage() {
loadData();
}
function loadData() {
var res;
var pal = document.getElementById('pal');
var yiyal = document.getElementById('yiyal');
var athikaram = document.getElementById('athikaram');
var line1 = document.getElementById('line1');
var line2 = document.getElementById('line2');
var exp = document.getElementById('kural-exp');
var num = Math.floor(Math.random() * (1330 - 1 + 1)) + 1;
var url = "https://api-thirukkural.vercel.app/api?num=" + num;
fetch(url)
.then(response => response.json())
.then(data => {
res = data;
})
.then(() => {
pal.innerText = res.sect_tam;
yiyal.innerText = res.chapgrp_tam;
athikaram.innerText = res.chap_tam;
line1.innerText = res.line1;
line2.innerText = res.line2;
exp.innerText = res.tam_exp;
});
}