-
Notifications
You must be signed in to change notification settings - Fork 33
/
example.html
167 lines (153 loc) · 4.19 KB
/
example.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html>
<head>
<script src="mus.js"></script>
<style>
.controls {
margin-bottom: 20px;
}
.controls td {
vertical-align: top;
padding: 0 20px;
}
.move-mouse-here {
width: 400px;
height: 200px;
display: table;
margin: 0 auto;
background-color: #33ff00;
text-align: center;
line-height: 200px;
}
.click-here {
width: 400px;
height: 200px;
display: table;
margin: 0 auto;
background-color: #00ffff;
text-align: center;
line-height: 200px;
}
.scroll-here {
width: 400px;
height: 2000px;
display: table;
margin: 0 auto;
background-color: #00c4ff;
text-align: center;
line-height: 200px;
}
#console {
font-size: 10px;
}
</style>
</head>
<body>
<table class="controls">
<tr>
<td>
<h1>Mus.js</h1>
<p>Status: <span id="status"></span></p>
<p>Speed: <span id="speed">Normal</span></p>
<br/>
<button id="recording" onclick="toggleRecord();">Start recording</button>
<button id="play" onclick="play();">Playback</button>
<br/>
<button onclick="mus.setPlaybackSpeed(mus.speed.SLOW);">Slow</button>
<button onclick="mus.setPlaybackSpeed(mus.speed.NORMAL);">Normal</button>
<button onclick="mus.setPlaybackSpeed(mus.speed.FAST);">Fast</button>
<br/>
<button id="timePoint" onclick="setTimePoint();">Enable time point</button>
<br/>
<button onclick="releaseMus();">Release</button>
</td>
<td>
<h2>Data console</h2>
<textarea id="console" rows="12" cols="100"></textarea>
</td>
</tr>
</table>
<div class="guide">
<div style="display: flex; flex-direction: column; width: 40%;">
<input type="text" placeholder="Type here !"/>
<textarea placeholder="Type here !"></textarea>
<div>
Change My Color: <input type="color" />
</div>
<div>
Check Me:<input type="checkbox" />
</div>
<div>
Change My Date:<input type="date" />
</div>
<div>
Change My Number: <input type="number" />
</div>
</div>
<div class="move-mouse-here">Move mouse here!</div>
<div class="click-here">Click here!</div>
<div class="scroll-here">Scroll here!</div>
</div>
<script>
var mus = new Mus();
mus.setPlaybackSpeed(mus.speed.SLOW);
var setTimePoint = function() {
releaseMus();
mus.setTimePoint(!mus.isTimePoint());
if (mus.isTimePoint()) {
document.getElementById("timePoint").innerHTML = "Disable time point";
} else {
document.getElementById("timePoint").innerHTML = "Enable time point";
}
};
var setConsoleData = function() {
var textarea = document.getElementById("console");
textarea.innerHTML = JSON.stringify(mus.getData());
textarea.scrollTop = textarea.scrollHeight;
};
var releaseMus = function() {
mus.release();
setConsoleData();
};
var toggleRecord = function() {
if (mus.isPlaying()) return;
if (!mus.isRecording()) {
document.getElementById("status").innerHTML = "Recording";
document.getElementById("recording").innerHTML = "Stop recording";
mus.record(setConsoleData);
} else {
document.getElementById("status").innerHTML = "Stand by";
document.getElementById("recording").innerHTML = "Start recording";
mus.stop();
setConsoleData();
}
};
var play = function() {
if (mus.isRecording()) return;
if (mus.isPlaying()) {
document.getElementById("play").innerHTML = "Play";
document.getElementById("status").innerHTML = "Stand by";
mus.pause();
} else {
document.getElementById("play").innerHTML = "Pause";
document.getElementById("status").innerHTML = "Playing";
mus.play(function() {
document.getElementById("play").innerHTML = "Play";
document.getElementById("status").innerHTML = "Stand by";
});
}
};
var setSpeed = function(speed) {
mus.setPlaybackSpeed(speed);
if (speed == mus.speed.SLOW) {
document.getElementById("speed").innerHTML = "Slow";
} else if (speed == mus.speed.NORMAL) {
document.getElementById("speed").innerHTML = "Normal";
} else {
document.getElementById("speed").innerHTML = "Fast";
}
};
setConsoleData();
</script>
</body>
</html>