const uniqueCellsCount = json.data.reduce((acc, c) => acc.add(c.cell), new Set()).size;
const watch = document.querySelector("#watch");
let milliseconds = 0;
let timer;
function millisToHuman(milliseconds) {
return new Date(milliseconds).toISOString().slice(11, 22);
}
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();
});
function newLapTime() {
const lap = document.querySelector('.lapContainer');
lap.innerHTML += `<br/><div> ${millisToHuman(milliseconds)} </div>`;
milliseconds = 0;
}
const throttledAddComment = throttle(addCommentFn, 5000);
sendButton.click((e) =>{
e.preventDefault();
throttledAddComment();
});
function func(data) {
if (data instanceof Event) {
var id = data.target.id;
} else {
var id = data;
}
}
detail
в объекте событияfunction func(event) {
const id = event.detail ? event.detail.id : event.target.id;
}
domElement.dispatchEvent(new CustomEvent('event-name', { detail: { id: 'id-42' } }));
const canvas = document.getElementById('canvas');
function loadImage(src) {
return new Promise((resolve, reject) => {
const image = new Image();
image.src = src;
if (image.complete) {
resolve(image);
return;
}
image.onload = () => resolve(image);
image.onerror = (e) => reject(e);
});
}
class Character {
constructor(options) {
this.ctx = options.ctx;
this.image = options.image;
this.width = options.width;
this.height = options.height;
this.render();
}
load() {}
render() {
this.ctx.drawImage(this.image, 0, 0, this.width / 7, this.height, 0, 0, this.width / 7, this.height);
}
}
(async function main() {
const spriteImage = await loadImage('./img/sprite.png');
const character = new Character({
ctx: canvas.getContext('2d'),
image: spriteImage,
width: 448,
height: 60,
});
})();
#navigation-top:checked ~ .show-experience {
transform: translateZ(-150px) rotateX(-90deg);
}
#navigation-middle:checked ~ .show-experience {
transform: translateZ(-150px) rotateX(0deg);
}
#navigation-bottom:checked ~ .show-experience {
transform: translateZ(-150px) rotateX(90deg);
}