-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
222 lines (195 loc) · 6.25 KB
/
Copy pathscript.js
File metadata and controls
222 lines (195 loc) · 6.25 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
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
let myjokes = [
{
"category": "Programming",
"type": "single",
"joke": "\"Honey, go to the store and buy some eggs.\"\n\"OK.\"\n\"Oh and while you're there, get some milk.\"\nHe never returned.",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"id": 18,
"safe": true,
"lang": "en"
},
{
"category": "Programming",
"type": "single",
"joke": "I'd tell you a joke about NAT but I would have to translate.",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 319,
"lang": "en"
},
{
"category": "Programming",
"type": "single",
"joke": "Your momma is so fat, you need to switch to NTFS to store a picture of her.",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": true
},
"id": 55,
"safe": false,
"lang": "en"
},
{
"category": "Programming",
"type": "single",
"joke": "Java is like Alzheimer's, it starts off slow, but eventually, your memory is gone.",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"id": 27,
"safe": false,
"lang": "en"
},
{
"category": "Programming",
"type": "single",
"joke": "Debugging is like being the detective in a crime movie where you're also the murderer at the same time.",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"id": 42,
"safe": true,
"lang": "en"
},
{
"category": "Programming",
"type": "single",
"joke": "A SQL statement walks into a bar and sees two tables.\nIt approaches, and asks \"may I join you?\"",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"id": 5,
"safe": true,
"lang": "en"
},
{
"category": "Programming",
"type": "single",
"joke": "\"Knock, knock.\"\n\"Who's there?\"\n\n[very long pause]\n\n\"Java.\"",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"id": 36,
"safe": true,
"lang": "en"
},
{
"category": "Programming",
"type": "single",
"joke": "Your mama's so FAT she can't save files bigger than 4GB.",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": true
},
"id": 9,
"safe": false,
"lang": "en"
},
{
"category": "Programming",
"type": "single",
"joke": "A man is smoking a cigarette and blowing smoke rings into the air. His girlfriend becomes irritated with the smoke and says \"Can't you see the warning on the cigarette pack? Smoking is hazardous to your health!\" to which the man replies, \"I am a programmer. We don't worry about warnings; we only worry about errors.\"",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"id": 38,
"safe": true,
"lang": "en"
},
{
"category": "Programming",
"type": "single",
"joke": "Four engineers get into a car. The car won't start.\nThe Mechanical engineer says \"It's a broken starter\".\nThe Electrical engineer says \"Dead battery\".\nThe Chemical engineer says \"Impurities in the gasoline\".\nThe IT engineer says \"Hey guys, I have an idea: How about we all get out of the car and get back in\".",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"id": 132,
"safe": true,
"lang": "en"
}
]; // Your array of jokes
let playedJokes = []; // Array to keep track of played jokes
function displayRandomJoke() {
if (playedJokes.length === myjokes.length) {
// All jokes have been played, ask the user if they want to play again
let playAgain = confirm("Do you want to play again?");
if (playAgain) {
// If the user wants to play again, reset the playedJokes array
playedJokes = [];
} else {
// If the user doesn't want to play again, return
return;
}
}
let index;
do {
// Generate a random index that hasn't been played yet
index = Math.floor(Math.random() * myjokes.length);
} while (playedJokes.includes(index));
playedJokes.push(index);
let jokeElement = document.getElementById("joke-content");
jokeElement.innerHTML = myjokes[index].joke;
// Generate random light colors for the background
let randomColor = getRandomLightColor();
document.body.style.backgroundColor = randomColor;
}
function getRandomLightColor() {
// Generating random values for RGB components in the range [150, 255]
let r = Math.floor(Math.random() * 106) + 150;
let g = Math.floor(Math.random() * 106) + 150;
let b = Math.floor(Math.random() * 106) + 150;
return `rgb(${r}, ${g}, ${b})`;
}
document.getElementById("button").onclick = displayRandomJoke;