Page 585 - Nodejs 교과서 개정2판
P. 585
const server = new Date(parseInt(e.data, 10));
end.setDate(end.getDate() + 1); // 경매 종료 시간
if (server >= end) { // 경매가 종료되었으면
return time.textContent = '00:00:00';
} else {
const t = end - server;
const seconds = ('0' + Math.floor((t / 1000) % 60)).slice(-2);
const minutes = ('0' + Math.floor((t / 1000 / 60) % 60)).slice(-2);
const hours = ('0' + Math.floor((t / (1000 * 60 * 60)) % 24)).slice(-2);
return time.textContent = hours + ':' + minutes + ':' + seconds;
}
};
const socket = io.connect('http://localhost:8010', {
path: '/socket.io'
});
socket.on('bid', (data) => { // 누군가가 입찰했을 때
const div = document.createElement('div');
let span = document.createElement('span');
span.textContent = data.nick + '님: ';
const strong = document.createElement('strong');
strong.textContent = data.bid + '원에 입찰하셨습니다.';
div.appendChild(span);
div.appendChild(strong);
if (data.msg) {
span = document.createElement('span');
span.textContent = `(${data.msg})`;
div.appendChild(span);
}
document.querySelector('#bid').appendChild(div);
});
</script>
<script>
window.onload = () => {
if (new URL(location.href).searchParams.get('auctionError')) {
alert(new URL(location.href).searchParams.get('auctionError'));
}
};
</script>
{% endblock %}
झ݀ ٘о ࢚ ӡ݅ ߹ ղਊ হणפ ݢ BYJPT &WFOU4PVSDF ಫܻҗ 4PDLFU *0 ۄ
झ݀ܳ ֍णפ ֎ ߣ૩ झ݀ కӒח ੑ द POST /good/:id/bid۽ ਃਸ ࠁղח Ѫ ࢲߡࣃ
߮ ؘఠ۽ ࢲߡ दрਸ ߉ই ೞח Ѫ ܲ ࢎۈ ੑ೮ਸ ٸ 4PDLFU *0۽ ੑ ࠁܳ ۪