forked from alexjpaz-playground/all-i-want-for-christmas-is
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
137 lines (120 loc) · 3.27 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
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class='flex-container'>
<div class='flex-center noselect'>
<div class='tree'>🎄</div>
</div>
</div>
</body>
<style>
.tree {
font-size: 200px;
}
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Old versions of Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome, Opera and Firefox */
}
body,html {
padding: 0;
margin: 0;
font-family: sans-serif;
height: 100%;
}
.flex-container {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
.flex-center {
max-width: 50%;
flex: 1;
}
@media only screen and (min-width: 992px) {
.tree {
max-width: 200px;
margin: auto;
}
.flex-container {
}
}
</style>
<script src="https://cdn.jsdelivr.net/npm/comfy.js@latest/dist/comfy.min.js"></script>
<script>
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
function youSoft() {
setTimeout(function() {
var you = new Audio();
you.src = "./sounds/you-soft.ogg"; // TODO - some browsers don't like mp3
you.play();
}, getRandomInt(5000, 10000));
}
function youC() {
var you = new Audio();
you.src = "./sounds/you-c.ogg"; // TODO - some browsers don't like mp3
you.play();
}
function youDsharp() {
var you = new Audio();
you.src = "./sounds/you-dsharp.ogg"; // TODO - some browsers don't like mp3
you.play();
}
function youLoop() {
var maximum = 15
var minimum = 5
var iterations = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum
let tid = null;
function play() {
if(iterations <= 0) {
var you = new Audio();
you.src = "./sounds/you.ogg"; // TODO - some browsers don't like mp3
you.play();
} else {
var loop = new Audio();
loop.src = "./sounds/is-infinite.ogg"; // TODO - some browsers don't like mp3
loop.play();
iterations--;
setTimeout(play, 900);
}
}
play();
}
function noYou() {
}
ComfyJS.onCommand = ( user, command, message, flags, extra ) => {
if(command === "xmas" ) {
console.log('xmas');
var intro = new Audio();
intro.src = "./sounds/all-i-want-for-christmas-is.ogg"; // TODO - some browsers don't like mp3
intro.play();
var items = [
youLoop,
youSoft,
youDsharp,
youC,
noYou,
];
var item = items[Math.floor(Math.random() * items.length)];
console.log(item);
intro.onended = function() {
item();
};
}
}
ComfyJS.Init( "alexjpaz" );
</script>
</html>