-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
89 lines (81 loc) · 2.65 KB
/
index.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
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
const searchInputCAP = document.getElementById('search-input-c');
const searchButtonCAP = document.getElementById('search-button-c');
const searchInputSMALL = document.getElementById('search-input-s');
const searchButtonSMALL = document.getElementById('search-button-s');
const searchInputNUM = document.getElementById('search-input-n');
const searchButtonNUM = document.getElementById('search-button-n');
searchButtonCAP.addEventListener('click', (e)=>{
e.preventDefault();
getASCIICap(searchInputCAP.value);
searchInputCAP.value ='';
})
searchButtonSMALL.addEventListener('click', (e) =>{
e.preventDefault();
getASCIISMALL(searchInputSMALL.value);
searchInputSMALL.value = '';
})
searchButtonNUM.addEventListener('click', (e) =>{
e.preventDefault();
getASCIINUM(searchInputNUM.value);
searchInputNUM.value = '';
})
async function getASCIICap(Caplet) {
try{
const response = await fetch(`https://my-json-server.typicode.com/code-reaper08/ASCII-API/AlphaC?name=${Caplet}`);
const data = await response.json();
console.log(data);
let ASCII = (data[0].ASCII);
console.log(ASCII);
let namecap = (data[0].name);
console.log(namecap);
let msg = document.getElementById('msgCAP');
let name = document.getElementById('capname');
capname.textContent = namecap;
msgCAP.textContent = ASCII;
}
catch(error)
{
console.log("Some fishy error here !")
}
}
async function getASCIISMALL(Smalllet) {
try{
const response = await fetch(`https://my-json-server.typicode.com/code-reaper08/ASCII-API/AlphaS?name=${Smalllet}`);
const data = await response.json();
console.log(data);
let ASCII = (data[0].ASCII);
console.log(ASCII);
let namesmall = (data[0].name);
console.log(namesmall);
let msg = document.getElementById('msgSMALL');
let name = document.getElementById('smallname');
smallname.textContent = namesmall;
msgSMALL.textContent = ASCII;
}
catch(error)
{
console.log("Some fishy error here !")
}
}
async function getASCIINUM(Number) {
try{
const response = await fetch(`https://my-json-server.typicode.com/code-reaper08/ASCII-API/Num?name=${Number}`);
const data = await response.json();
console.log(data);
let ASCII = (data[0].ASCII);
console.log(ASCII);
let namenum = (data[0].name);
console.log(namenum);
let msg = document.getElementById('msgNUM');
let name = document.getElementById('numname');
numname.textContent = namenum;
msgNUM.textContent = ASCII;
}
catch(error)
{
console.log("Some fishy error here !")
}
}
getASCIICap();
getASCIISMALL();
getASCIINUM();