productsDetail.ejs
5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<% include ../includes/header.ejs %>
<div class="panel panel-default">
<div class="panel-heading">
<h2 style="padding-left: 30px;"><%=product.title%></h2>
<div style="padding-bottom: 10px;">
작성일 :
<%=product.getDate.year%> -
<%=product.getDate.month%> -
<%=product.getDate.day%>
</div>
<div style="padding-left: 30px">
설명 : <%=product.description%>
</div>
<hr/>
</div>
<div>
<% var count=0; %>
<% if (items.length != 0) { %>
<ul class="list-group" style="padding-left: 30px; padding-bottom: 30px;">
<li class="list-group-item list-group-item-info" aria-current="true">보유중인 영상</li>
<% for (var i in items[0]) { %>
<li class="list-group-item"><%=items[0][i].title%> <a href="/categori/products/detail/delete/<%=items[0][i].id%>" style="position: absolute; right: 1%;" class="btn btn-danger btn-sm" onclick="return confirm('삭제하시겠습니까?')">삭제</a></li>
<%count++;};%>
</ul>
<%};%>
</div>
<button style="margin-left: 30px; margin-bottom: 10px;" class="btn btn-outline-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseExample"
aria-expanded="false" aria-controls="collapseExample">
영상 추가하기
</button>
<div class="collapse show" id="collapseExample" style="padding-left: 30px;">
<div class="card card-body">
<form method="get" action="">
<div class="input-group" style="padding-left: 10px;">
<input type="text" class="form-control" placeholder="검색 키워드를 입력하세요!" name="keyword" autocomplete='off'>
<span class="input-group-btn">
<button class="btn btn-secondary" type="submit">찾기</button>
</span>
</div>
</form>
<form method="post" action="">
<% for (var i in videos) { %>
<div style="float:left;
padding: 15px;
">
<input type="checkbox" name="videoNum" style="
position: absolute;
margin-top: 5px;
margin-left: 5px;
z-index: 4;
zoom:3.0;
"
value="<%=videos[i].id + '///' + videos[i].title +'///'+ videos[i].categori +'///'+ videos[i].video_id +'///'+ videos[i].urls%>" />
<div id="<%=videos[i].id%>" vid="<%=videos[i].video_id%>">
</div>
</div>
<%};%>
<button class="btn btn-primary" style="margin-top: 10px; margin-left: 10px;">영상담기</button>
</form>
</div>
</div>
<div class="panel-body">
<div>
<hr />
</div>
</div>
</div>
<div style="padding-bottom: 30px;">
<a href="/categori/products" class="btn btn-dark">목록으로</a>
<a href="/categori/products/edit/<%=product._id%>" class="btn btn-primary">수정</a>
</div>
<% include ../includes/footer.ejs %>
<script>
(function(){
// 영상 메모 구현 파트(아직 미구현)
$(document).ready(function() {
$('#commentForm').submit(function(){
var $contentVal = $(this).children('textarea[name=content]').val();
if($contentVal){
$.ajax({
url: '/admin/products/ajax_comment/insert',
type: 'POST',
data: $(this).serialize(),
})
.done(function(args) {
if(args.message==="success"){
$('#comment_area').append(
'<div>' + args.content +
" ( <a class='comment_delete' comment_id='"+ args._id +"'>삭제</a> ) </div>"
);
$('#commentForm textarea[name=content]').val("");
}
})
.fail(function(args) {
console.log(args);
});
}else{
alert('댓글 내용을 입력해주세요.')
}
return false;
});
});
})();
</script>
<script>
$(document).on('click' , '.comment_delete' , function(){
if(confirm('삭제하시겠습니까?')){ //확인창 예 눌렀을 시만 진행
var $self = $(this);
$.ajax({
url: '/admin/products/ajax_comment/delete',
type: 'POST',
data: { comment_id : $self.attr('comment_id') },
})
.done(function() {
$self.parent().remove();
alert("삭제가 완료되었습니다.");
})
.fail(function(args) {
console.log(args);
});
}
});
</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: {
}
});
}
}
</script>