AOS.init();
const watch = document.querySelector("#watch");
let milliseconds = 0;
let timer;
function ImgForJs() {
window.open("https://website-about.neocities.org/main-page.html", "_blank")
}
function h1ForJs() {
window.open("https://website-about.neocities.org/main-page.html", "_blank")
}
function millisToHuman(milliseconds) {
return new Date(milliseconds).toISOString().slice(11, 23);
}
const startWatch = () => {
watch.classList.remove("paused");
clearInterval(timer);
timer = setInterval(() => {
milliseconds += 10;
const timeStr = millisToHuman(milliseconds);
result.innerHTML = timeStr;
watch.innerHTML = timeStr;
}, 10);
};
const pauseWatch = () => {
watch.classList.add("paused");
clearInterval(timer);
};
const resetWatch = () => {
watch.classList.remove("paused");
clearInterval(timer);
// milliseconds = 0;
watch.innerHTML = "00:00:00:00";
result.innerHTML = "00:00:00:00";
};
document.addEventListener("click", (e) => {
const element = e.target;
if (element.id === "start") startWatch();
if (element.id === "pause") pauseWatch();
if (element.id === "reset") resetWatch();
});
const laps = [];
function newLapTime() {
if(laps.length < 6) {
laps.push(`
<br/>
<div>
${millisToHuman(milliseconds)}
</div>`
); document.querySelector('.lapContainer').innerHTML = laps.join('');
}
// milliseconds = 0;
}