-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
148 lines (135 loc) · 4.44 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Testing animations</title>
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans:wght@300;500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="magic.min.css">
<style>
body {
margin: 0;
padding: 0;
background: black;
}
.title {
width: 600px;
height: 120px;
background: white;
padding: 1em;
display: flex;
flex-direction: row;
border-radius: 1em;
font-family: 'Fira Sans', sans-serif;
}
.title img {
max-width: 96px;
margin-right: 1em;
}
.title .text {
display: flex;
flex-direction: column;
}
.title .text .top {
font-size: 240%;
color: #383838;
}
.title .text .bottom {
font-size: 170%;
color: #8a00d4;
}
.hidden {
visibility: hidden;
}
</style>
</head>
<body>
<article class="title title-twitch hidden">
<img class="hidden" src="assets/twitch.svg" alt="Twitch">
<div class="text">
<div class="top hidden">Santiago Martín</div>
<div class="bottom hidden">santiMA10</div>
</div>
</article>
<script id="__bs_script__">//<![CDATA[
document.write("<script async src='http://HOST:3000/browser-sync/browser-sync-client.js?v=2.26.7'><\/script>".replace("HOST", location.hostname));
//]]></script>
<script src="https://www.gstatic.com/firebasejs/7.14.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.4/firebase-firestore.js"></script>
<script>
const firebaseConfig = {
apiKey: "AIzaSyBfhhf_W8UHsUv-TWyNZc8cp1YyfOKy3Ms",
authDomain: "titles-8fe07.firebaseapp.com",
databaseURL: "https://titles-8fe07.firebaseio.com",
projectId: "titles-8fe07",
storageBucket: "titles-8fe07.appspot.com",
messagingSenderId: "133194977487",
appId: "1:133194977487:web:bba6c98d56e05a2b0e27ba"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const wait = (seconds) => {
return new Promise((resolve, reject) => {
setTimeout(resolve, seconds * 1000);
});
};
const container = document.querySelector('article');
const textTop = document.querySelector('.top');
const textBottom = document.querySelector('.bottom');
const icon = document.querySelector('img');
/**
*
* @param {string} topText
* @param {string} bottomText
* @param {number} duration
* @returns {Promise<void>}
*/
const displayTitle = async (topText, bottomText, duration) => {
textTop.innerText = topText;
textBottom.innerText = bottomText;
container.classList.remove('hidden');
container.classList.add('magictime','spaceInDown');
await wait(.2);
icon.classList.remove('hidden');
icon.classList.add('magictime','vanishIn');
await wait(.1);
textTop.classList.remove('hidden');
textTop.classList.add('magictime','vanishIn');
await wait(.1);
textBottom.classList.remove('hidden');
textBottom.classList.add('magictime','vanishIn');
await wait(duration);
container.classList.remove('spaceInDown');
container.classList.add('slideDown');
await wait(1);
textBottom.classList.add('hidden');
textTop.classList.add('hidden');
container.classList.add('hidden');
textBottom.classList.remove('magictime');
textTop.classList.remove('magictime');
container.classList.remove('magictime');
};
const shown = {};
document.addEventListener('DOMContentLoaded', async () => {
const collection = firebase.firestore().collection('titles');
collection.onSnapshot({next: async (snapshot) => {
console.log('Query returns new data');
const showTitles = [];
snapshot.forEach(doc => {
if (shown[doc.id]) {
console.log(`Skipping already shown title: ${doc.id}`);
return;
}
const {top, bottom, duration} = doc.data();
showTitles.push(() => {
shown[doc.id] = true;
return displayTitle(top, bottom, duration);
});
});
for ( let t of showTitles) {
await t();
}
}});
})
</script>
</body>
</html>