이승윤

chore: 불필요한 내용 수정/삭제

var express = require('express');
var router = express.Router();
router.get('/', function(req,res){
if(!req.isAuthenticated()){
res.send('<script>alert("로그인이 필요한 서비스입니다.");location.href="/accounts/login";</script>');
}else{
res.render('chat/index');
}
});
module.exports = router;
\ No newline at end of file
var express = require('express');
var router = express.Router();
var ProductsModel = require('../models/ProductsModel');
/* GET home page. */
router.get('/', function(req,res){
ProductsModel.find( function(err,products){ //첫번째 인자는 err, 두번째는 받을 변수명
res.render( 'home' ,
{ products : products } // DB에서 받은 products를 products변수명으로 내보냄
);
});
});
module.exports = router;
\ No newline at end of file
<% include ../includes/header.ejs %>
<div class="row">
<div class="col-sm-10">
<div class="panel panel-default" id="chatWrap">
<div class="panel-heading">대화내용</div>
<div class="panel-body">
<ul id="chatBody"></ul>
</div>
</div>
</div>
<div class="col-sm-2">
<div class="panel panel-default" id="userWrap">
<div class="panel-heading">User</div>
<div class="panel-body">
<ul id="userList"></ul>
</div>
</div>
</div>
</div>
<div>
<form action="" method="post" id="sendForm">
<div class="input-group">
<input type="hidden" name="socketId">
<input type="text" name="message" class="form-control" placeholder="대화내용을 입력해주세요.">
<span class="input-group-btn">
<button class="btn btn-primary">작성하기</button>
</span>
</div><!-- /input-group -->
</form>
</div>
<style type="text/css">
.panel-default ul { padding-left:0px; }
.panel-default ul li { list-style:none; padding-left:0px;}
.panel-default .panel-body {min-height:350px; max-height:350px; overflow-y:scroll; }
#chatWrap ul li strong::after { content: " : "; }
@media (max-width: 768px) {
#userWrap { display:none; }
#chatWrap .panel-body { min-height:250px; }
}
</style>
<script src="/socket.io/socket.io.js"></script>
<script>
(function(){
var socket = io();
function updateUserList(userList){
$('#userList').html("");
for(var key in userList){
$('#userList').append('<li>' + userList[key] + '</li>');
}
}
socket.on('join', function(data){
updateUserList(data);
});
socket.on('server message', function(data){
$('#chatBody').append('<li><strong>'+ data.displayname +'</strong>' + data.message + '</li>');
});
socket.on('leave', function(data){
updateUserList(data);
});
$(document).ready(function() {
$('#sendForm').submit(function(){
var $massage = $('#sendForm input[name=message]');
socket.emit('client message', { message : $massage.val()});
$massage.val('');
return false;
});
});
})();
</script>
<% include ../includes/footer.ejs %>
<% include ./includes/header.ejs %>
<div class="container" id="masonry_container">
<% products.forEach(function(product){ %>
<div class="masonry-grid">
<%if(product.thumbnail){%>
<img src="/uploads/<%=product.thumbnail%>">
<%}%>
<p>
<%=product.title%><br />
by <%=product.username%>(
<%=product.getDate.year%>.
<%=product.getDate.month%>.
<%=product.getDate.day%>
)
</p>
<% for (var i in videos) { %>
<div id="<%=videos[i].id%>" vid="<%=videos[i].video_id%>">
</div>
<%});%>
<%};%>
</div>
<style type="text/css">
.masonry-grid img { max-width: 260px; }
</style>
......@@ -30,4 +20,40 @@
});
});
</script>
<script>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
var players = [];
var videoIds = [];
for (var i = 0;i<10;i++) {
players.push(String(i));
videoIds.push($('#'+i).attr('vid'));
}
function onYouTubeIframeAPIReady() {
for (var i = 0; i < videoIds.length; i++) {
player = new YT.Player(players[i], {
height: '360',
width: '640',
videoId: videoIds[i],
events: {
// 'onReady': onPlayerReady,
// 'onStateChange': onPlayerStateChange
}
});
}
}
// function onPlayerReady(event) {
// }
// function onPlayerStateChange(event) {
// }
// function stopVideo() {
// }
</script>
<% include ./includes/footer.ejs %>
\ No newline at end of file
......
......@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Node.js 예제</title>
<title>MYCOOK</title>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
......@@ -26,19 +26,18 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="/" class="navbar-brand">Nodejs</a>
<a href="/" class="navbar-brand">MyCookBook</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9">
<ul class="nav navbar-nav">
<li class="active">
<a href="/">Home</a>
</li>
<li><a href="/admin/products">ADMIN</a></li>
<li><a href="/chat">CHAT</a></li>
<li><a href="/admin/products">Categori</a></li>
<% if(isLogin){%>
<li><a href="/accounts/logout" onclick="return confirm('로그아웃 하시겠습니까?')">LOGOUT</a></li>
<%}else{%>
<li><a href="/accounts/join">JOIN</a></li>
<li><a href="/accounts/join">SignUp</a></li>
<li><a href="/accounts/login">LOGIN</a></li>
<%}%>
</ul>
......