This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
111 lines (94 loc) · 3.15 KB
/
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
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
//onload function
function instan() {
document.getElementById('searchbar').value = "";
}
//search bar
function google() {
console.clear();
var x = document.getElementById("fe");
var y = document.getElementsByTagName("li");
var input = document.getElementById('searchbar').value.toLowerCase();
$.each($("#fe").children(), (i, v) => {
if (v.innerText.indexOf(input) >= 0) {
$(v).show();
} else {
$(v).hide();
}
})
}
// all jokes
function alls() {
$('#ani2').removeClass('active');
$('#foo2').removeClass('active');
$('#oth2').removeClass('active');
if ( $('#home').hasClass('active') ) {} else {$('#home').addClass('active');}
$.getJSON('/jokes.json', function (data) {
$('#fe').empty();
for (var i = 0; i < data.jokes.length; i++) {
var node = document.createElement("LI");
var textnode = document.createTextNode(data.jokes[i].joke);
node.appendChild(textnode);
document.getElementById("fe").appendChild(node);
}
});
}
//animal jokes
function anis1() {
$('#home').removeClass('active');
$('#foo2').removeClass('active');
$('#oth2').removeClass('active');
if ( $('#ani2').hasClass('active') ) {} else {$('#ani2').addClass('active');}
$.getJSON('/jokes.json', function (data) {
$('#fe').empty();
for (var i = 0; i < data.animals.length; i++) {
var node = document.createElement("LI");
var textnode = document.createTextNode(data.animals[i].joke);
node.appendChild(textnode);
document.getElementById("fe").appendChild(node);
}
});
}
//food jokes
function food1() {
$('#home').removeClass('active');
$('#ani2').removeClass('active');
$('#oth2').removeClass('active');
if ( $('#foo2').hasClass('active') ) {} else {$('#foo2').addClass('active');}
$.getJSON('/jokes.json', function (data) {
$('#fe').empty();
for (var i = 0; i < data.food.length; i++) {
var node = document.createElement("LI");
var textnode = document.createTextNode(data.food[i].joke);
node.appendChild(textnode);
document.getElementById("fe").appendChild(node);
}
});
}
//other jokes
function oth1() {
$('#home').removeClass('active');
$('#foo2').removeClass('active');
$('#ani2').removeClass('active');
if ( $('#oth2').hasClass('active') ) {} else {$('#oth2').addClass('active');}
$.getJSON('/jokes.json', function (data) {
$('#fe').empty();
for (var i = 0; i < data.other.length; i++) {
var node = document.createElement("LI");
var textnode = document.createTextNode(data.other[i].joke);
node.appendChild(textnode);
document.getElementById("fe").appendChild(node);
}
});
}
/*random joke-
$.getJSON('jokes.json', function(data) {
joe = data.jokes
console.log(joe[Math.floor(Math.random() * joe.length)])
});
*/
function day() {
var daynum = Math.round((new Date().setHours(23) - new Date(new Date().getYear() + 1900, 0, 1, 0, 0, 0)) / 1000 / 60 / 60 / 24);
$.getJSON('/jokes.json', function (data) {
var stev = document.getElementById('jd').innerText = data.jokes[daynum].joke;
});
}