-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
33 lines (31 loc) · 1.01 KB
/
index.html
File metadata and controls
33 lines (31 loc) · 1.01 KB
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
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf8">
</head>
<body>
<img id="card" data-no="1" data-state="ura" src="ura.jpg" width="320">
<script src="https://fungo.kcg.edu/madoi-20231023/js/madoi.js"></script>
<script>
window.addEventListener("load", ()=>{
// Madoiを作成しサーバに接続する。引数はルームのID。アプリケーション毎に異なるIDを使用する。
const m = new madoi.Madoi("imageflip-zlsdmg34i");
document.getElementById("card").addEventListener("click", e=>{
m.send("flip", e.target.attributes["data-no"].value);
});
m.setHandler("flip", no=>{
const card = document.querySelector(`img[data-no='${no}']`);
const state = card.attributes["data-state"].value;
if(state == "ura"){
card.attributes["data-state"].value = "omote";
card.src = "omote.jpg";
} else{
card.attributes["data-state"].value = "ura";
card.src = "ura.jpg";
}
});
});
</script>
<a href="https://www.vecteezy.com/free-vector/poker-cards">Poker Cards Vectors by Vecteezy</a>
</body>
</html>