我从朋友那里得到了一些帮助,他写了一个信标计时器:My timer
如果我们将它与此Not my timer进行比较,它就会停止运行insync 那一个仍然是不相干的。我不知道我忘了添加到我的代码中。 两个网站都抓住了当地时间,所以即使我的电脑时钟不同步,这两个页面也应该是不同步的。
var elements = [
["4U1UN", "New York"],
["VE8AT", "Canada"],
["W6WX", "California"],
["KH6WO", "Hawaii"],
["ZL6B", "New Zealand"],
["VK6RBP", "Australia"],
["JA2IGY", "Japan"],
["RR9O", "Novosibirsk"],
["VR2B", "Hong Kong"],
["4S7B", "Sri Lanka"],
["ZS6DN", "South Africa"],
["5Z4B", "Kenya"],
["4X6TU", "Israel"],
["OH2B", "Finland"],
["CS3B", "Madeira"],
["LU4AA", "Argentina"],
["OA4B", "Peru"],
["YV5B", "Venezuela"]
];
var initial = ["28200", "24930", "21150", "18110", "14100"];
var timing = 10; //seconds per element of array
window.setInterval(function () {
var d = new Date();
var second = (d.getMinutes() * 60) + d.getSeconds();
var test = Math.floor(((second +1.1) % (elements.length * timing)) / timing);
document.getElementById("wat").innerHTML = "";
for(var i = 0; i < elements.length; i++)
{
var index = (i + test) % elements.length;
document.getElementById("wat").innerHTML += "<tr><td>" +
( i < initial.length ? initial[i] : "") +
"</td><td>" +
elements[index][0] +
"</td><td>" +
elements[index][1] +
"</td></tr>";
}
}, 1000);