-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
330 lines (273 loc) · 12.4 KB
/
index.html
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
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UTF-8">
<meta name = "viewport" content = "width-device-width, intial-scale=1.0">
<meta http-equiv = "X-UA-Compatible" content="ie-edge">
<title> Tarot Reader 1.0 </title>
<link rel="stylesheet" href = "css/main.css">
<script data-ad-client="ca-pub-4957642040936191" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</head>
<body>
<div class="container">
<h1> Would you like a tarot reading? </h1>
<form id="myForm">
<span class="msg">Full name please!</span>
<input type="submit" value="Yes, please." class="btn" onclick="doRead()">
</form>
</div>
<div class="cards">
<div class = "card" id = "card1">
<img src = "cardback.JPG" id = "card1img" style="max-height: 200px; max-width: 120px;">
</div>
<div class = "card" id = "card2">
<img src = "cardback.JPG" id = "card2img" style="max-height: 200px; max-width: 120px;">
</div>
<div class = "card" id = "card3">
<img src = "cardback.JPG" id = "card3img" style="max-height: 200px; max-width: 120px;">
</div>
</div>
<div class = "commentary">
<h1 id = "readtitle"></h1>
<p id = "knowledge"></p>
<button type="button" id = "proceed" class="btn2" onclick="proceed()"></button>
</div>
<span class="dot"></span>
<script src="https://unpkg.com/popmotion/dist/popmotion.global.min.js"></script>
<script src="https://d3js.org/d3.v6.min.js"></script>
<script>
var form = document.getElementById("myForm");
function handleForm(event) { event.preventDefault(); }
form.addEventListener('submit', handleForm);
var state = 0;
function getReading()
{
const NUM_CARDS = 78;
var cardOne = 0;
var cardTwo = 0;
var cardThree = 0;
cardOne = Math.floor(Math.random() *(78));
cardTwo = Math.floor(Math.random() *(78));
cardThree = Math.floor(Math.random() *(78));
while (cardOne == cardTwo || cardTwo == cardThree || cardOne == cardThree)
{
cardOne = Math.floor(Math.random() *(78));
cardTwo = Math.floor(Math.random() *(78));
cardThree = Math.floor(Math.random() *(78));
}
const readers = [cardOne, cardTwo, cardThree];
console.log(readers);
return readers;
}
var prestitle = "";
var preswords = "";
var pasttitle = "";
var pastwords = "";
var futtitle = "";
var futwords = "";
var summary = "";
function doRead()
{
console.log("Make the cards appear and all");
fadeout.start(container.set);
const cards = d3.json("tarot.json").then(function(data)
{
console.log(data);
var cool = getReading();
console.log(data[cool[1]]);
var img1 = document.getElementById("card1img");
var img2 = document.getElementById("card2img");
var img3 = document.getElementById("card3img");
img1.src = "cards/"+data[cool[0]].img;
img2.src = "cards/"+data[cool[1]].img;
img3.src = "cards/"+data[cool[2]].img;
tableup.start(
{update: table.set,
complete: () => {bringEmUp()}
});
//For present: "Your current mantra seems to be : affirmation. Keep your current habit of : light. However, don't continue: shadow"
//For future: "Ask yourself: question. Fortune Telling. In the future you will be : light"
pasttitle= "Your past has been defined by the card "+ data[cool[0]].name;
document.getElementById("readtitle").innerHTML = pasttitle;
pastwords = "You may have been "+ (data[cool[0]].meanings.light[Math.floor(Math.random()*4)]).toLowerCase() +". In some moments, you have been " + (data[cool[0]].meanings.shadow[Math.floor(Math.random()*4)]).toLowerCase() +".";
document.getElementById("knowledge").innerHTML = pastwords;
document.getElementById("proceed").innerHTML = "Continue?";
tableup.start(words.set);
prestitle = "Your present has been defined by the card " + data[cool[1]].name;
preswords = "You believe in " + data[cool[1]].keywords[0] +". Keep your current habit of " + (data[cool[1]].meanings.light[Math.floor(Math.random()*4)]).toLowerCase() + "; however, do not continue " + (data[cool[1]].meanings.shadow[Math.floor(Math.random()*4)]).toLowerCase() +".";
futtitle = "Your future is told by the card " + data[cool[2]].name;
futwords = data[cool[2]].fortune_telling[0] + ". You will be surrounded by " + data[cool[2]].keywords[Math.floor(Math.random()*2)] + ". Soon, you will be " + (data[cool[2]].meanings.light[Math.floor(Math.random()*4)]).toLowerCase() + ".";
//your past ... has lead you to ...light in the present. Use the ...key word
//Summary ... key word in your past has lead you to key word in your present. Use this to face shadow future. Remember,
summary = "It seems as though " + data[cool[0]].keywords[0] + " has lead you to " + data[cool[1]].keywords[1] +" in the present. Use this growth to resist " + (data[cool[2]].meanings.shadow[Math.floor(Math.random()*4)]).toLowerCase() + " in your future. Remember, " + data[cool[2]].fortune_telling[0].toLowerCase() + ".";
});
}
function proceed()
{
if (state == 3)
{
window.location.reload(true);
}
if (state == 2)
{
tabledown.start(table.set);
tableupup.start(words.set);
document.getElementById("readtitle").innerHTML = "Summary";
document.getElementById("knowledge").innerHTML = summary;
document.getElementById("proceed").innerHTML = "Do another reading";
state = 3;
}
if (state == 1)
{
bringup1.start(card3.set);
document.getElementById("readtitle").innerHTML = futtitle;
document.getElementById("knowledge").innerHTML = futwords;
document.getElementById("proceed").innerHTML = "View Summary";
state = 2;
}
if (state == 0)
{
bringup1.start(card2.set);
document.getElementById("readtitle").innerHTML = prestitle;
document.getElementById("knowledge").innerHTML = preswords;
state = 1;
}
}
const container = popmotion.styler(document.querySelector('.container'));
const table = popmotion.styler(document.querySelector('.cards'));
const card1=popmotion.styler(document.getElementById("card1"));
const card2=popmotion.styler(document.getElementById("card2"));
const card3=popmotion.styler(document.getElementById("card3"));
const words = popmotion.styler(document.querySelector('.commentary'));
const formElements = document.querySelector('.inner');
const msgPop = popmotion.styler(document.querySelector('.msg'));
const beginani = popmotion.tween({
from: {
scale: .3,
opacity: 0
},
to: {
scale: 1,
opacity:1
},
duration: 2000
})
const setzero = popmotion.tween({
from: {
scale: 0,
opacity: 0
},
to: {
scale: 0,
opacity:0
},
duration: 2000
})
const cardslide = popmotion.tween({
from: {
scale: .3,
opacity: 1,
y: 500
},
to: {
scale: 1,
opacity:1,
y:0
},
duration: 2000
})
const tableup = popmotion.tween({
from: {
y: 0
},
to: {
scale: 1,
opacity:1,
y:-300
},
duration: 2000
})
const tableupup = popmotion.tween({
from: {
y: -300
},
to: {
scale: 1,
opacity:1,
y:-600
},
duration: 2000
})
const tabledown = popmotion.tween({
from: {
y: -300,
scale: 1,
opacity: 1
},
to: {
scale: 0.7,
opacity:0,
y: 200
},
duration: 2000
})
const bringup1 = popmotion.tween({
from: {
x: 0,
scale: 1
},
to: {
scale: 2,
x: 50
},
duration: 2000
})
const bringdown1 = popmotion.tween({
from: {
x: 50,
scale: 2
},
to: {
scale: 1,
x: 0
},
duration: 2000
})
const bringup2 = popmotion.tween({
from: {
x: 0,
scale: 1
},
to: {
scale: 2,
x: 1
},
duration: 2000
})
function bringEmUp ()
{
bringup1.start(card1.set);
}
setzero.start(card1)
setzero.start(card2)
setzero.start(card3)
beginani.start(
{
update: container.set,
}
);
{cardslide.start(card1.set), cardslide.start(card2.set),cardslide.start(card3.set)}
const fadeout = popmotion.tween({
from: {
scale: 1,
opacity: 1
},
to: {
scale: 0.5,
opacity:0
},
duration: 2000
})
</script>
</body>
</html>