我找到了以下用于简单倒数计时器的 javascript 代码,但我需要根据文件 /run/Aquarium/Active.run 中的值在页面上显示 9 个计时器。该文件包含 10 个整数,范围从 0 到 7200,以空格分隔。最后 9 个值中的每一个都代表每个计时器应该倒计时到零的秒数。我对 javascript 的了解不够,无法将其扩展为 9 计时器功能。这是我已经拥有的:div.Main { position: fixed; top: 26; left: 180; width: 300px; font: bold 24px Arial; color: black;}div.Relay1 { position: fixed; top: 120; left: 60; width: 300px; font: bold 24px Arial; color: black;}div.Relay2 { position: fixed; top: 150; left: 60; width: 300px; font: bold 24px Arial; color: black;}...div.Relay8 { position: fixed; top: 330; left: 60; width: 300px; font: bold 24px Arial; color: black;}</style><script type="text/javascript">function startTimer(duration, display) { var timer = duration, minutes, seconds; setInterval(function () { minutes = parseInt(timer / 60, 10); seconds = parseInt(timer % 60, 10); minutes = minutes < 10 ? "0" + minutes : minutes; seconds = seconds < 10 ? "0" + seconds : seconds; display.textContent = minutes + ":" + seconds; if (--timer < 0) { timer = duration; } }, 1000);}window.onload = function () { display = document.querySelector('#time'); startTimer(TMinutes, display);};</script></HEAD><BODY style="background-color:#00EE66"><h1>Aquarium Equipment Status</h1><?php$file = fopen("/run/Aquarium/Active.run","r");$Times = fgetcsv($file,64,' ');fclose($file);?><div class="Main"><script type="text/javascript">var TMinutes = 0TMinutes = <?php echo $Times[1] ?>;</script><span id="time">000:00</span></div><div class="Relay1"><script type="text/javascript">????
1 回答
- 1 回答
- 0 关注
- 156 浏览
添加回答
举报
0/150
提交
取消