Page 535 - Nodejs 교과서 개정2판
P. 535

views/main.html
           {%	extends	'layout.html'	%}


           {%	block	content	%}
           <h1>GIF	채팅방</h1>
           <fieldset>
           		<legend>채팅방	목록</legend>
           		<table>
           				<thead>
           				<tr>
           						<th>방	제목</th>
           						<th>종류</th>
           						<th>허용	인원</th>
           						<th>방장</th>
           				</tr>
           				</thead>
           				<tbody>
           				{%	for	room	in	rooms	%}
           						<tr	data-id="{{room._id}}">
           								<td>{{room.title}}</td>
           								<td>{{'비밀방'	if	room.password	else	'공개방'}}</td>
           								<td>{{room.max}}</td>
           								<td	style="color:	{{room.owner}}">{{room.owner}}</td>
           								<td>
           										<button
           												data-password="{{'true'	if	room.password	else	'false'}}"
           												data-id="{{room._id}}"
           												class="join-btn"
           										>입장
           										</button>
           								</td>
           						</tr>
           				{%	endfor	%}
           				</tbody>
           		</table>
           		<div	class="error-message">{{error}}</div>
           		<a	href="/room">채팅방	생성</a>
           </fieldset>
           <script	src="/socket.io/socket.io.js"></script>
           <script>
           		const	socket	=	io.connect('http://localhost:8005/room',	{	//	네임스페이스
           				path:	'/socket.io',
           		});
   530   531   532   533   534   535   536   537   538   539   540