-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path上家.html
123 lines (110 loc) · 3.7 KB
/
上家.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
<html>
<head>
<script type="text/javascript">
//Set server URI
var uri = "ws://localhost:12345"
var ws = null;
//connect
function open() {
if (ws === null) {
ws = new WebSocket(uri);
ws.onopen = (msg) => {
console.log("Connect..")
document.getElementById("container").classList.add("fade_right")
};
ws.onmessage = (msg) => {
if (msg && msg.data) {
var message = JSON.parse(msg.data);
if (typeof message.kamitya !== 'undefined') {
document.getElementById("player").innerHTML = message.kamitya.name;
document.getElementById("player").style.backgroundColor = message.kamitya.color
switch (Number(message.status)) {
case 1:
document.getElementById("container").classList.remove("fade_left")
document.getElementById("container").classList.add("fade_right")
break;
case 2:
document.getElementById("container").classList.remove("fade_right")
document.getElementById("container").classList.add("fade_left")
break;
}
}
else {
document.getElementById("container").classList.remove("fade_left")
document.getElementById("container").classList.add("fade_right")
}
}
};
ws.onclose = (msg) => {
console.log("disconnect(" + msg.code + ")");
webSocket = null;
location.reload();
};
ws.onerror = (msg) => {
console.log("Error " + msg);
};
}
}
open();
</script>
<style type="text/css">
body {
margin: 0;
}
#container {
margin: 0px;
display: flex;
flex-wrap: wrap;
gap: 5px 10px;
}
#player {
width: 60px;
height: 500px;
background: #ffb7b7;
clip-path: polygon( 100% 0%, 100% 100%, 0% 100%, 0% 0%);
box-sizing: border-box;
text-align: center;
font-size: 40px;
writing-mode: vertical-rl;
text-orientation: upright;
}
.fade_right {
animation-name: fade_right_motion;
animation-duration: 1s;
animation-fill-mode: forwards;
opacity: 0;
}
@keyframes fade_right_motion {
from {
opacity: 1;
transform: translateX(0);
}
to {
opacity: 1;
transform: translateX(100px);
}
}
.fade_left {
animation-name: fade_left_motion;
animation-duration: 1s;
animation-fill-mode: forwards;
opacity: 0;
}
@keyframes fade_left_motion {
from {
opacity: 1;
transform: translateX(100px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
</style>
</head>
<body>
<div id="container">
<div id="player">接続待機中</div>
</div>
</body>
</html>