-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollbutton.html
46 lines (38 loc) · 1.5 KB
/
rollbutton.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>ビンゴまわす</title>
<link rel="stylesheet" type="text/css" href="elm.css">
</head>
<body>
<button type="button" style="width:40rem; height:40rem; font-size:10rem; font-family:メイリオ" id="rollbutton">まわす</button>
<!-- 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();
// db listener
db.collection("rollstatus").doc("rollstatusdoc").onSnapshot((documentSnapshot) => {
if (documentSnapshot.data().status == 0){
document.getElementById("rollbutton").disabled = false;
}
});
document.getElementById("rollbutton").onclick = function(){
// update db
db.collection("rollstatus").doc("rollstatusdoc").update({status:1});
document.getElementById("rollbutton").disabled = true;
};
</script>
</body>
</html>