質問編集履歴
1
追記:setTimeoutとボタンを追加した文になります。
test
CHANGED
File without changes
|
test
CHANGED
@@ -69,3 +69,109 @@
|
|
69
69
|
|
70
70
|
|
71
71
|
よろしくお願いします。
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
---追記---
|
80
|
+
|
81
|
+
setTimeoutを使用してボタンを追加し文を変更いたしました。
|
82
|
+
|
83
|
+
よろしければこちらの方もよろしくお願いします。
|
84
|
+
|
85
|
+
```ここに言語を入力
|
86
|
+
|
87
|
+
clickButton: function(event) {;
|
88
|
+
|
89
|
+
this.i = this.i+1
|
90
|
+
|
91
|
+
//ボタンを押された時間から終了予定時刻までの差を計算
|
92
|
+
|
93
|
+
var now = new Date();
|
94
|
+
|
95
|
+
var hournow = now.getHours();
|
96
|
+
|
97
|
+
var minutesnow = now.getMinutes();
|
98
|
+
|
99
|
+
//時間を取り出して数値にする
|
100
|
+
|
101
|
+
var hourend = this.today_schedule[i].end.substr(0,2);
|
102
|
+
|
103
|
+
hourend = Number( hourend );
|
104
|
+
|
105
|
+
//分を取り出して数値にする
|
106
|
+
|
107
|
+
var minutesend = this.today_schedule[i].end.substr(3,2);
|
108
|
+
|
109
|
+
minutesend = Number( minutesend );
|
110
|
+
|
111
|
+
//計算する
|
112
|
+
|
113
|
+
var hour = ( hourend - hournow );
|
114
|
+
|
115
|
+
hour = ( hour * 60 * 60 );//秒
|
116
|
+
|
117
|
+
var minutes = ( minutesend - minutesnow );
|
118
|
+
|
119
|
+
if( minutes < 0 ){
|
120
|
+
|
121
|
+
minutes = ( 60 + (minutes) ) ;
|
122
|
+
|
123
|
+
minutes = ( minutes * 60 );
|
124
|
+
|
125
|
+
var second = ( hour + (minutes) );
|
126
|
+
|
127
|
+
var msecond = ( second * 1000 );
|
128
|
+
|
129
|
+
var mago = ( msecond - 600000 );
|
130
|
+
|
131
|
+
}else{
|
132
|
+
|
133
|
+
minutes = ( minutes * 60 );//秒
|
134
|
+
|
135
|
+
second = ( hour + ( minutes ));
|
136
|
+
|
137
|
+
msecond = ( second * 1000 );//終了まで(ミリ秒)
|
138
|
+
|
139
|
+
mago = ( msecond - 600000 );//10分前
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
//10分前通知
|
144
|
+
|
145
|
+
var speak = new SpeechSynthesisUtterance();
|
146
|
+
|
147
|
+
speak.text = '終了10分前です。';
|
148
|
+
|
149
|
+
speak.lang = 'ja-jp';
|
150
|
+
|
151
|
+
speak = speechSynthesis.speak(speak);
|
152
|
+
|
153
|
+
setTimeout(speak, mago);
|
154
|
+
|
155
|
+
/*var time = setTimeout(speechSynthesis.speak(speak), mago);
|
156
|
+
|
157
|
+
clearTimeout(time);*/
|
158
|
+
|
159
|
+
//終了通知
|
160
|
+
|
161
|
+
var endspeak = new SpeechSynthesisUtterance();
|
162
|
+
|
163
|
+
endspeak.text = '終了時刻となりました。';
|
164
|
+
|
165
|
+
endspeak.lang = 'ja-jp';
|
166
|
+
|
167
|
+
speak = speechSynthesis.speak(speak);
|
168
|
+
|
169
|
+
setTimeout(speak, msecond);
|
170
|
+
|
171
|
+
/*time = setTimeout(speechSynthesis.speak(endspeak), msecond);
|
172
|
+
|
173
|
+
clearTimeout(time);*/
|
174
|
+
|
175
|
+
},
|
176
|
+
|
177
|
+
```
|