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۽ ੑ଴ ੿ࠁܳ ۪
   580   581   582   583   584   585   586   587   588   589   590