aboutsummaryrefslogtreecommitdiffhomepage
path: root/script.js
blob: 6e177af7e260f440c0ee0150ad81f39ac875e731 (plain) (blame)
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
particlesJS("starBackground", {
    "particles": {
        "number": {
            "value": 355,
            "density": {
                "enable": true,
                "value_area": 789.1476416322727
            }
        },
        "color": {
            "value": "#ffffff"
        },
        "shape": {
            "type": "circle",
            "stroke": {
                "width": 0,
                "color": "#000000"
            },
            "polygon": {
                "nb_sides": 5
            }
        },
        "opacity": {
            "value": 0.48927153781200905,
            "random": false,
            "anim": {
                "enable": true,
                "speed": 0.2,
                "opacity_min": 0,
                "sync": false
            }
        },
        "size": {
            "value": 2,
            "random": true,
            "anim": {
                "enable": true,
                "speed": 2,
                "size_min": 0,
                "sync": false
            }
        },
        "line_linked": {
            "enable": false,
            "distance": 150,
            "color": "#ffffff",
            "opacity": 0.4,
            "width": 1
        },
        "move": {
            "enable": true,
            "speed": 0.2,
            "direction": "none",
            "random": true,
            "straight": false,
            "out_mode": "out",
            "bounce": false,
            "attract": {
                "enable": false,
                "rotateX": 600,
                "rotateY": 1200
            }
        }
    },
    "interactivity": {
        "detect_on": "canvas",
        "events": {
            "onhover": {
                "enable": true,
                "mode": "bubble"
            },
            "onclick": {
                "enable": true,
                "mode": "push"
            },
            "resize": true
        },
        "modes": {
            "grab": {
                "distance": 400,
                "line_linked": {
                    "opacity": 1
                }
            },
            "bubble": {
                "distance": 83.91608391608392,
                "size": 1,
                "duration": 3,
                "opacity": 1,
                "speed": 3
            },
            "repulse": {
                "distance": 200,
                "duration": 0.4
            },
            "push": {
                "particles_nb": 4
            },
            "remove": {
                "particles_nb": 2
            }
        }
    },
    "retina_detect": true
});

/*
    Whale Partyy!
 */
const whaleDialog =
    "Aaaahhhhhhhhh! Wooooooooooh!\n" +
    "\n" +
    "What's happening?\n" +
    "\n" +
    "Who am I?\n" +
    "\n" +
    "Why am I here? What’s my purpose in life?\n" +
    "\n" +
    "What do I mean by who am I?\n" +
    "\n" +
    "Okay, okay, calm down and get a grip now. Ooh, that is an interesting sensation. What is it? It’s a sort of tingling in my - well I suppose I better start finding names for things. Let's call it a tail! Yeah, tail!\n" +
    "\n" +
    "And hey, what’s this roaring sound whooshing past what I’m suddenly going to call my head? Wind! Is that a good name? It’ll do.\n" +
    "\n" +
    "Yeah, this is really exciting. I’m dizzy with anticipation!\n" +
    "\n" +
    "Or is it the wind?\n" +
    "\n" +
    "Theres an awful lot of that now isn’t it?\n" +
    "\n" +
    "And what’s this thing suddenly coming towards me very fast? So big and flat and round, it needs a big wide sounding name like 'ow', 'ownge', 'round', 'ground'! That’s it! Ground! Ha!\n" +
    "\n" +
    "I wonder if it will be friends with me? Hello Ground!\n";
const flowerPotDialog = "Oh no, not again...";
const timeout = 20000;

setTimeout(() => {
    generateObject();
    setInterval(() => {
        generateObject()
    }, timeout)
}, timeout);

function generateObject() {
    let whale = document.getElementById("whaleParty");
    let petuniaBowl = document.getElementById("petuniaBowlParty");
    let randomLeftOffset = Math.floor(Math.random() * 70) + 1,
        randomSelector = Math.floor(Math.random() * 2) + 1,
        current,
        newObject;

    if (randomSelector === 1) {
        current = whale;
        speak(whaleDialog);
        console.log(whaleDialog);
    } else {
        current = petuniaBowl;
        speak(flowerPotDialog);
        console.log(flowerPotDialog);
    }
    newObject = current.cloneNode(true);
    current.parentNode.replaceChild(newObject, current);
    newObject.classList.add("dropObject");
    newObject.style.left = randomLeftOffset.toString() + "%";
}

function speak(message) {
    const msg = new SpeechSynthesisUtterance(message);
    const voices = window.speechSynthesis.getVoices();
    msg.voice = voices[0];
    window.speechSynthesis.speak(msg)
}