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;
} const socket = io("https://server-domain.com");
localhost:3000
const io = require('socket.io');
let players = {};
io.on('connection', function(socket) {
socket.on('new player', function() {
players[socket.id] = {
x: 300,
y: 300
};
});
socket.on('movement', function(data) {
var player = players[socket.id] || {};
if (data.left) {
player.x -= 5;
}
if (data.up) {
player.y -= 5;
}
if (data.right) {
player.x += 5;
}
if (data.down) {
player.y += 5;
}
});
});
setInterval(function() {
io.sockets.emit('state', players);
}, 1000 / 60); const replacePhone = (phone) => phone.split('').map((el, i) => i === 1 || i === 4 || i === 7 || i === 9 ? el+' ' : el).join('');
console.log(replacePhone('+79031002020'));