掲示板に書き込む前に必ず この ”注意書き”を お読み下さい.
|
<Number>: [00000A5A]
<Date>: 2021/07/17 00:01:06
<Title>:
<Name>: amanojaku@管理人
|
|
|
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<!--
↑metaタグでcharsetをUTF-8に設定しています。
必ずcharsetに設定されているキャラクターセット(エンコード)でセーブして下さい。
キャラクターセット(エンコード)が違うと全角文字が文字化けします。
-->
<body>
<button type="button" id="idStopWatch_Start" onclick="SWatch_Start()">Start</button>
<button type="button" id="idStopWatch_Stop" onclick="SWatch_Stop()">Stop</button>
<button type="button" id="idStopWatch_Reset" onclick="SWatch_Reset()">Reset</button>
<div id="idStopWatch_Display"></div>
</body>
<script>
let elSWStart = document.getElementById("idStopWatch_Start");
let elSWStop = document.getElementById("idStopWatch_Stop");
let elSWReset = document.getElementById("idStopWatch_Reset");
let elSWDisplay = document.getElementById("idStopWatch_Display");
let nSWatch_Start = -1;
let nSWatch_Stop = -1;
let nSWatch_Accum = 0;
let oSWatch_Interval;
function SWatch_Start(){
let nTimeMS, nTimeSec, nTimeMinutes, nTimeHours;
nSWatch_Stop = Date.now();
if(nSWatch_Start<0){
nSWatch_Start = nSWatch_Stop;
}
SWatch_Display();
if( ! oSWatch_Interval){
oSWatch_Interval = setInterval(SWatch_Interval, 50); // ms
}
}
function SWatch_Stop(){
let nTimeMS, nTimeSec, nTimeMinutes, nTimeHours;
// nSWatch_Stop = Date.now();
if(0<=nSWatch_Start){
SWatch_Display();
nSWatch_Accum += nSWatch_Stop-nSWatch_Start;
}
nSWatch_Start = -1;
nSWatch_Stop = -1;
if(oSWatch_Interval){
clearInterval(oSWatch_Interval);
}
oSWatch_Interval = null;
}
function SWatch_Reset(){
nSWatch_Start = -1;
nSWatch_Accum = 0;
elSWDisplay.innerText = "";
if(oSWatch_Interval){
clearInterval(oSWatch_Interval);
}
oSWatch_Interval = null;
}
function SWatch_Display(){
nTimeMS = nSWatch_Accum+nSWatch_Stop-nSWatch_Start;
nTimeSec = Math.floor(nTimeMS / 1000);
nTimeMS = nTimeMS % 1000;
nTimeMinutes = Math.floor(nTimeSec / 60);
nTimeSec = nTimeSec % 60;
nTimeHours = Math.floor(nTimeMinutes / 60);
nTimeMinutes = nTimeMinutes % 60;
elSWDisplay.innerText =
nTimeHours + ":" + nTimeMinutes + ":" + nTimeSec+" "+nTimeMS;
}
function SWatch_Interval(){
let nTimeMS, nTimeSec, nTimeMinutes, nTimeHours;
nSWatch_Stop = Date.now();
SWatch_Display();
}
</script>
</html>
|
|
|
|
|
SMT Version 8.022(+A) Release M6.
Author : amanojaku.