-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
343 lines (300 loc) · 12.5 KB
/
main.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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
var cards = [
// structure:----> console.log(cards[0].card); = the fool
{
card: "The Fool",
name: "Kirsten Maiwaldt",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/2fsGq6inE",
code: "https://editor.p5js.org/melaniehoff/sketches/2fsGq6inE",
interaction: "<img class='click' src='assets/mouse.png'>",
interactionText: "Move mouse"
},
{
card: "The Magician",
name: "Marinelle Manansala",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/tXz9E7jd0",
code: "https://editor.p5js.org/melaniehoff/sketches/tXz9E7jd0",
interaction: "<img class='click' src='assets/mouse.png'> <img class='click' src='assets/click.png'> A B C D E",
interactionText: "Move mouse, click, press A, B, C, D, E"
},
{
card: "The High Priestess",
name: "Danielle Farah",
website: "http://artfiles.rutgers.edu/[email protected]/tarot",
sketch: "https://editor.p5js.org/melaniehoff/embed/cbjTgdqFM",
code: "https://editor.p5js.org/melaniehoff/sketches/cbjTgdqFM",
interaction: "<img class='click' src='assets/click.png'>",
interactionText: "Click"
},
{
card: "The Empress",
name: "Elyssa Feerrar",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/pKXvxBY8f",
code: "https://editor.p5js.org/melaniehoff/sketches/pKXvxBY8f",
interaction: "<img class='click' src='assets/click.png'>",
interactionText: "Click"
},
{
card: "The Emperor",
name: "Elyssa Feerrar",
website: "http://artfiles.rutgers.edu/[email protected]/tarot%202/",
sketch: "https://editor.p5js.org/melaniehoff/embed/FUKeNgxvC",
code: "https://editor.p5js.org/melaniehoff/sketches/FUKeNgxvC",
interaction: "<img class='click' src='assets/click.png'>",
interactionText: "Click"
},
{
card: "The Hierophant", //TODO
name: "MH",
website: "https://melanie-hoff.com/tarot/hierophant/",
sketch: "https://editor.p5js.org/melaniehoff/embed/MtfvWmYz6",
code: "https://editor.p5js.org/melaniehoff/sketches/MtfvWmYz6",
interaction: "<img class='click' src='assets/mouse.png'> <img class='click' src='assets/click.png'>",
interactionText: "Move mouse to play pong, also click"
},
{
card: "The Lovers", //TODO
name: "Alexandria Eisen",
website: "https://melanie-hoff.com/tarot/lovers",
sketch: "https://editor.p5js.org/melaniehoff/embed/poq8yuXSq",
code: "https://editor.p5js.org/melaniehoff/sketches/poq8yuXSq",
interaction: "<span><img class='click' src='assets/click.png'> R</span>",
interactionText: "Click, press R"
},
{
card: "The Chariot",
name: "Jenna MacNeill",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/OgyCbc4-z",
code: "https://editor.p5js.org/melaniehoff/sketches/OgyCbc4-z",
interaction: "<img class='click' src='assets/mouse.png'> <img class='click' src='assets/click.png'>",
interactionText: "Move mouse, click"
},
{
card: "Strength",
name: "Yuchao Wang",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/r3eekK1O0",
code: "https://editor.p5js.org/melaniehoff/sketches/r3eekK1O0",
interaction: "<img class='click' src='assets/mouse.png'> <img class='click' src='assets/click.png'>",
interactionText: "Click + hold"
},
{
card: "The Hermit", //TODO -- fred's https://editor.p5js.org/fredkq1/sketches/AUvwFDPvy
name: "Fred Quayenortey",
website: "http://artfiles.rutgers.edu/[email protected]/tarot_2/",
sketch: "https://editor.p5js.org/melaniehoff/embed/5h8TKriVb",
code: "https://editor.p5js.org/melaniehoff/sketches/5h8TKriVb",
interaction: "<img class='click' src='assets/click.png'> [SPACE] E F",
interactionText: "Click, press spacebar, E key, F key"
},
{
card: "Wheel of Fortune", //TODO
name: "MH",
website: "https://melanie-hoff.com/tarot/wheeloffortune",
sketch: "https://editor.p5js.org/melaniehoff/embed/H7E65rqDb",
code: "https://editor.p5js.org/melaniehoff/sketches/H7E65rqDb",
interaction: "<img class='click' src='assets/mouse.png'>",
interactionText: "Move mouse"
},
{
card: "Justice",
name: "Conor Fin",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/8gZLw_VYr",
code: "https://editor.p5js.org/melaniehoff/sketches/8gZLw_VYr",
interaction: "<img class='click' src='assets/mouse.png'> <img class='click' src='assets/click.png'>",
interactionText: "Move mouse, click"
},
{
card: "The Hanged Man",
name: "Fred Quayenortey",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/C2BJdFo9_",
code: "https://editor.p5js.org/melaniehoff/sketches/C2BJdFo9_",
interaction: "<img class='click' src='assets/click.png'>",
interactionText: "Move mouse, click + listen"
},
{
card: "Death",
name: "Yuchao Wang",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/death",
sketch: "https://editor.p5js.org/melaniehoff/embed/PZ0GnLKyT",
code: "https://editor.p5js.org/melaniehoff/sketches/PZ0GnLKyT",
interaction: "<img class='click' src='assets/mouse.png'>",
interactionText: "Move mouse"
},
{
card: "Temperance", //TODO
name: "MH",
website: "https://melanie-hoff.com/tarot/temperence/",
sketch: "https://editor.p5js.org/melaniehoff/embed/ml_VPt1xc",
code: "https://editor.p5js.org/melaniehoff/sketches/ml_VPt1xc",
interaction: "<img class='click' src='assets/click.png'>",
interactionText: "Click"
},
{
card: "The Devil", //TODO
name: "MH",
website: "https://melanie-hoff.com/tarot/devil",
sketch: "https://editor.p5js.org/melaniehoff/embed/bbs_vgFxZ",
code: "https://editor.p5js.org/melaniehoff/sketches/bbs_vgFxZ",
interaction: "<span><img class='click' src='assets/mouse.png'> <img class='click' src='assets/click.png'></span>",
interactionText: "Move mouse, click, click + hold"
},
{
card: "The Tower",
name: "Valerie Lozano",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/GFKaSQWhC",
code: "https://editor.p5js.org/melaniehoff/sketches/GFKaSQWhC",
interaction: "<img class='click' src='assets/key.png'>",
interactionText: "Press any key"
},
{
card: "The Star",
name: "Sherry Mi",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/wS2zJaZXC",
code: "https://editor.p5js.org/melaniehoff/sketches/wS2zJaZXC",
interaction: "<img class='click' src='assets/mouse.png'> <img class='click' src='assets/key.png'>",
interactionText: "Move mouse, press any key"
},
{
card: "The Moon",
name: "Sheila Leonard",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/9HQ_TLpGg",
code: "https://editor.p5js.org/melaniehoff/sketches/9HQ_TLpGg",
interaction: "<img class='click' src='assets/mouse.png'> <img class='click' src='assets/click.png'> <img class='click' src='assets/key.png'>",
interactionText: "Move mouse"
},
{
card: "The Sun",
name: "Gilbert Espinoza",
website: "http://artfiles.rutgers.edu/[email protected]/tarot/",
sketch: "https://editor.p5js.org/melaniehoff/embed/v1YzgP6-u",
code: "https://editor.p5js.org/melaniehoff/sketches/v1YzgP6-u",
interaction: "<img class='click' src='assets/space.png'>",
interactionText: ""
},
{
card: "Judgement", //TODO copy to my p5
name: "Valerie Lozano",
website: "https://melanie-hoff.com/tarot/judgement/",
sketch: "https://editor.p5js.org/melaniehoff/embed/LiEPr44Id",
code: "https://editor.p5js.org/melaniehoff/sketches/LiEPr44Id",
interaction: "<img class='click' src='assets/space.png'>",
interactionText: ""
},
{
card: "The World",
name: "Jamie Noor",
website: "http://artfiles.rutgers.edu/[email protected]/tarot",
sketch: "https://editor.p5js.org/melaniehoff/embed/oUL56jqc1",
code: "https://editor.p5js.org/melaniehoff/sketches/oUL56jqc1",
interaction: "<img class='click' src='assets/mouse.png'>",
interactionText: "Move mouse"
}
];
displayCards(cards);
//FUNCTIONS
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
alert("Generative Tarot is MUCH better viewed on desktop.\nYou'll be missing out on the card interactions.\nContinue anyway?");
}
function displayCards(cards) {
console.log("Check out this console log!");
// Shuffle array
const shuffledCards = shuffle(cards);
// Get sub-array of first 3 elements after shuffled
let shuffledThree = shuffledCards.slice(0, 3);
//Print the three pulled cards
// console.log(shuffledThree);
console.log(shuffledThree[0].card);
console.log(shuffledThree[1].card);
console.log(shuffledThree[2].card);
//website
$("#title-1").attr("href", shuffledThree[0].website);
$("#title-1").text(shuffledThree[0].card);
$("#code-1").attr("href", shuffledThree[0].code);
$("#code-1").text(shuffledThree[0].name);
$("#title-2").attr("href", shuffledThree[1].website);
$("#title-2").text(shuffledThree[1].card);
$("#code-2").attr("href", shuffledThree[1].code);
$("#code-2").text(shuffledThree[1].name);
$("#title-3").attr("href", shuffledThree[2].website);
$("#title-3").text(shuffledThree[2].card);
$("#code-3").attr("href", shuffledThree[2].code);
$("#code-3").text(shuffledThree[2].name);
//interaction
$("#interaction-1").html(shuffledThree[0].interaction);
$("#interaction-2").html(shuffledThree[1].interaction);
$("#interaction-3").html(shuffledThree[2].interaction);
$("#interactionText-1").html(shuffledThree[0].interactionText);
$("#interactionText-2").html(shuffledThree[1].interactionText);
$("#interactionText-3").html(shuffledThree[2].interactionText);
//Show the iframes
loadIframe("one", shuffledThree[0].sketch);
loadIframe("two", shuffledThree[1].sketch);
loadIframe("three", shuffledThree[2].sketch);
//
return
}
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function pullAgain() {
hidePage();
console.log("should be displaying");
setTimeout(showPageAgain, 2000);
console.log("should be displaying after 2 secs");
}
function loadIframe(iframeName, url) {
var $iframe = $('#' + iframeName);
if ( $iframe.length ) {
$iframe.attr('src',url);
return false;
}
return true;
}
function loader() {
setTimeout(showPage, 2000);
}
function showPage() {
document.getElementById("loader").style.display = "none";
document.getElementById("pulled-cards").style.display = "flex";
document.getElementById("top-buttons").style.display = "block";
document.getElementById("bottom-container").style.display = "flex";
}
function showPageAgain() {
displayCards(cards);
showPage();
}
function hidePage() {
document.getElementById("loader").style.display = "block";
document.getElementById("pulled-cards").style.display = "none";
document.getElementById("top-buttons").style.display = "none";
}
$("#scrollLink").click(function() {
$([document.documentElement, document.body]).animate({
scrollTop: $("#info-about").offset().top
}, 800);
});
// $("#scroll-exercise").click(function() {
// $([document.documentElement, document.body]).animate({
// scrollTop: $("#info-exercise").offset().top
// }, 800);
// });