私はDOMとHTMLとPHPの新機能をかなり使い慣れているので、これを行う方法に関するいくつかの情報を探しています。私が今まで持っているものは、JavaScriptです。今、私はこのスクリプトを表示するためにDOMを使いたい/しなければなりません。 (参考:私はMoodleのために何かを実装していますが、これはこのようにしています)DOMを使ってcountdowntimerスクリプトを表示
私がDOMについて知ったことは、異なるノードの値を変更できることです。私が見つけた問題は、私が見つけたすべての例が似ていることです。ボタンをクリックすると何かが起こります。それは大丈夫ですが、スクリプトを毎秒実行したいので、必要な人が時間が経過していることがわかります。
私はあなたに十分な情報を提供し、私があなたを助けてくれることを願っています。私を助けてくれてありがとう。
var running = false
var endTime = null
var timerID = null
// totalMinutes the amount of minutes is put into
var totalMinutes = 3;
function startTimer() {
// running is being started and the current time is put into the variable
running = true
now = new Date()
now = now.getTime()
// Variable endTime gets the time plus the maximum time
endTime = now + (1000 * 60 * totalMinutes);
showCountDown()
}
function showCountDown() {
// same as startTimer, time is saved in variable now
var now = new Date()
now = now.getTime()
if (endTime - now <= 0) {
// Variable timerID gets clearTimeout -->http://de.selfhtml.org/javascript/objekte/window.htm#clear_timeout
clearTimeout(timerID)
// boolean running set to false
running = false
alert("Ihr Resultat wird nun ausgewertet!")
} else {
// delta is being calculated
var delta = new Date(endTime - now)
var theMin = delta.getMinutes()
var theSec = delta.getSeconds()
var theTime = theMin
// show seconds and minutes
theTime += ((theSec < 10) ? ":0" : ":") + theSec
document.getElementById('CheckResults').innerHTML = " (Übung in " + theTime + " Minuten abgelaufen)"
if (running) {
timerID = setTimeout("showCountDown()",900)
}
}
}
</script>
うわー...私が期待していたよりもうまくいってくれてありがとう。どうもありがとうございます。私はこの道をたどります。 –