-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.html
52 lines (43 loc) · 1.43 KB
/
index2.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>ビンゴうつす</title>
<script src="elm.js"></script>
<link rel="stylesheet" type="text/css" href="elm.css">
</head>
<body>
<div id="elm"></div>
<!-- firebase librarys -->
<script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-auth.js"></script>
<script>
// Initialize Cloud Firestore through Firebase
firebase.initializeApp({
apiKey: 'AIzaSyAssBS2SbnvsYTtmzR4ScmJe5Gzswf1vko',
authDomain: 'https://bounenkai2019-91211.firebaseapp.com/',
projectId: 'bounenkai2019-91211'
});
firebase.auth().signInAnonymously().catch(function(error) {
// Handle Errors here.
});
var db = firebase.firestore();
// Elm
var app = Elm.Main.init({
node: document.getElementById('elm')
});
// db listener
db.collection("rollstatus").doc("rollstatusdoc").onSnapshot((documentSnapshot) => {
if (documentSnapshot.data().status == 1){
// send to elm
app.ports.rollstart.send();
}
});
app.ports.rollend.subscribe(() => {
// update db
db.collection("rollstatus").doc("rollstatusdoc").update({status:0});
});
</script>
</body>
</html>