-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
44 lines (41 loc) · 1.49 KB
/
index.html
File metadata and controls
44 lines (41 loc) · 1.49 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
<head>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="./search.css">
<script src="./search.js"></script>
</head>
<body>
<input type="text" id="search" style="width:90%;">
<script>
function callBack(num) {
if(parseInt(num, 10) > 0)
return $.get("https://api.icndb.com/jokes/random/"+num)
.done(function(data) {
console.log("Success!", data);
})
.then(function(data) {
return data["value"]
.map(i => i["joke"]);
});
else {
console.error("invalid integer supplied.")
return Promise.resolve();
}
}
// function callBack(res) {
// return new Promise(function (resolve, reject) {
// setTimeout(function () {
// var arr = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"]
// .filter(s => s.indexOf(res) >= 0)
// .map(s => "<div>" + s + "</div>");
// resolve(arr);
// }, 50);
// });
// }
$(document).ready(function () {
srch.setup("#search", callBack)
});
</script>
</body>