-
Notifications
You must be signed in to change notification settings - Fork 1
/
mygallery.html
307 lines (276 loc) · 9.3 KB
/
mygallery.html
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<!DOCTYPE html>
<html lang="zxx">
<head>
<title>365 Gallery</title>
<meta charset="UTF-8">
<meta name="description" content="Boto Photo Studio HTML Template">
<meta name="keywords" content="photo, html">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Stylesheets -->
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<link rel="stylesheet" href="css/font-awesome.min.css"/>
<link rel="stylesheet" href="css/slicknav.min.css"/>
<link rel="stylesheet" href="css/fresco.css"/>
<!-- Main Stylesheets -->
<link rel="stylesheet" href="css/style.css"/>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Page Preloder -->
<div id="preloder">
<div class="loader"></div>
</div>
<!-- Header Section -->
<header class="header">
<div class="container-fluid">
<div class="row">
<div class="col-sm-4 col-md-3 order-2 order-sm-1">
</div>
<div class="col-sm-4 col-md-6 order-1 order-md-2 text-center">
<a href="./index.html" class="site-logo">
<img src="img/logo.png" alt="">
</a>
</div>
<div class="col-sm-4 col-md-3 order-3 order-sm-3">
</div>
</div>
<nav class="main__menu">
<ul class="nav__menu">
<li><a href="./index.html" class="menu--active">Home</a></li>
<li><a href="#" onclick="setChildValue(0)">Exhibition</a>
<ul class="sub__menu">
<li><a href="#" onclick="setChildValue(0)">Romanticism</a>
<ul class="sub2__menu">
<li><a href="#" onclick="setChildValue(0)">William Turner</a></li>
</ul></li>
<li><a href="#" onclick="setChildValue(2)">Impressionism</a>
<ul class="sub2__menu">
<!--
<li><a href="#" onclick="setChildValue(1)">Van Gogh</a></li>
-->
<li><a href="#" onclick="setChildValue(2)">Seurat</a></li>
<li><a href="#" onclick="setChildValue(3)">Claude Monet</a></li>
<li><a href="#" onclick="setChildValue(4)">Leonid Afremov</a></li>
<li><a href="#" onclick="setChildValue(5)">Katsushika Hokusai</a></li>
</ul></li>
<li><a href="#" onclick="setChildValue(6)">Fauvism</a>
<ul class="sub2__menu">
<li><a href="#" onclick="setChildValue(6)">Henri Matisse</a></li>
<li><a href="#" onclick="setChildValue(7)">Andre Derain</a></li>
</ul></li>
<li><a href="#" onclick="setChildValue(8)">Cubism</a>
<ul class="sub2__menu">
<li><a href="#" onclick="setChildValue(8)">Pablo Picasso</a></li>
<li><a href="#" onclick="setChildValue(9)">Fernand Leger</a></li>
<li><a href="#" onclick="setChildValue(10)">Francis Picabia</a></li>
</ul></li>
<li><a href="#" onclick="setChildValue(11)">Abstractionism</a>
<ul class="sub2__menu">
<li><a href="#" onclick="setChildValue(11)">Robert Delaunay</a></li>
<li><a href="#" onclick="setChildValue(12)">Pieter Mondrian</a></li>
</ul></li>
<li><a href="#" onclick="setChildValue(13)">Expressionism</a>
<ul class="sub2__menu">
<li><a href="#" onclick="setChildValue(13)">Edvard Munch</a></li>
<li><a href="#" onclick="setChildValue(14)">Gustav Klimt</a></li>
</ul></li>
<li><a href="#" onclick="setChildValue(15)">Futurism</a>
<ul class="sub2__menu">
<li><a href="#" onclick="setChildValue(15)">Umberto Boccioni</a></li>
<li><a href="#" onclick="setChildValue(16)">Giacomo Balla</a></li>
</ul></li>
<li><a href="#" onclick="setChildValue(17)">Surrealism</a>
<ul class="sub2__menu">
<li><a href="#" onclick="setChildValue(17)">Joan Miro</a></li>
<li><a href="#" onclick="setChildValue(18)">Marc Chagall</a></li>
</ul></li>
<li><a href="#" onclick="setChildValue(19)">Pop Art</a>
<ul class="sub2__menu">
<li><a href="#" onclick="setChildValue(19)">Roy Lichtenstein</a></li>
<li><a href="#" onclick="setChildValue(20)">Keith Haring</a></li>
</ul></li>
</ul></li>
<li><a href="./mygallery.html">My Gallery</a></li>
</ul>
</nav>
</div>
</header>
<!-- Header Section end -->
<!-- About Page -->
<div class="gallery__page">
<div class="gallery__warp">
<div class="filebox" style="display:none;">
<form method="POST" enctype="multipart/form-data" id="uploadForm">
<input class="upload-name" value="선택된 파일 없음" disabled="disabled" >
<label for="ex_filename">파일 선택</label>
<input type="file" id="ex_filename" class="upload-hidden" accept="image/*"/>
<button id='btnUpload'>추가</button>
</form>
</div>
<div class='editbox'>
<button id='btnDel' onclick='imgdelete();' style="display:none;">삭제</button>
<button id='btnEdit' onclick='editmode()'>편집</button>
</div>
<div class="gallerybox">
<div class="row">
<div class="imgGrid1">
</div>
<div class="imgGrid2">
</div>
<div class="imgGrid3">
</div>
<div class="imgGrid4">
</div>
</div>
</div>
</div>
</div>
<!-- About Page end -->
<!-- Search Begin -->
<div class="search-model">
<div class="h-100 d-flex align-items-center justify-content-center">
<div class="search-close-switch">+</div>
<form class="search-model-form">
<input type="text" id="search-input" placeholder="Search here.....">
</form>
</div>
</div>
<!-- Search End -->
<!--====== Javascripts & Jquery ======-->
<script src="js/vendor/jquery-3.2.1.min.js"></script>
<script src="js/jquery.slicknav.min.js"></script>
<script src="js/slick.min.js"></script>
<script src="js/fresco.min.js"></script>
<script src="js/main.js"></script>
<!-- Script: Gallery script-->
<script>
// gallery: add
$('#btnUpload').on('click', function(event) {
event.preventDefault();
var form = $('#uploadForm')[0][1].files[0];
var data = new FormData();
data.append('file', form, form.name);
var serverURL = "http://34.64.152.92:8000/api/v1/gallery/";
$.ajax({
type: "POST",
enctype: 'multipart/form-data',
url: serverURL,
data: data,
processData: false,
contentType: false,
cache: false,
timeout: 10000,
success: function(){
location.reload();
},
error: function() {
alert("Upload failed");
}
});
});
// gallery: delete
function imgdelete(){
var checkObj = document.getElementsByName("images");
var num = checkObj.length;
var delURL;
for (i = 0; i < num; i++){
if (checkObj[i].checked == true){
delURL = "http://34.64.152.92:8000/api/v1/gallery/" + checkObj[i].value + "/";
$.ajax({
url: delURL,
method: "DELETE",
success: function() {
location.reload();
},
error: function() {
alert("Delete failed");
}
})
}
}
}
// gallery: img load
function galleryLoad(){
$.getJSON("http://34.64.152.92:8000/api/v1/gallery/", function(result) {
var i = 0;
while (result['data'][i]){
var gridName;
if (i % 4 == 0)
gridName = '.imgGrid1';
else if (i % 4 == 1)
gridName = '.imgGrid2';
else if (i % 4 == 2)
gridName = '.imgGrid3';
else if (i % 4 == 3)
gridName = '.imgGrid4';
var prepend_data = '<input type="checkbox" class="imgCheck" name="images" value=' + result.data[i].pk + ' " style="display: none;"/><article class="image_list"><div class="galleryImg"> <a href="#" onclick="toCommentPage(' + result.data[i].pk + ')"><img src=' + result.data[i].file + ' alt=""></a></div><a class="image_tag" onclick="toCommentPage(' + result.data[i].pk + ')" id="image_tag_' + result.data[i].pk + '" href="#" >';
if (result.data[i].tag != null)
prepend_data += result.data[i].tag.name;
else
prepend_data += "Upload by User";
prepend_data = prepend_data + '</a></article>';
$(gridName).prepend(prepend_data);
if (result.data[i].tag != null){
var rgb = result.data[i].tag.color;
var r = rgb[0] + rgb[1];
r = parseInt(r, 16);
var g = rgb[2] + rgb[3];
g = parseInt(g, 16);
var b = rgb[4] + rgb[5];
b = parseInt(b, 16);
var myrgba = 'rgba('+r+','+g+','+b+',0.4)';
document.getElementById("image_tag_" + result.data[i].pk).style.backgroundColor = myrgba;
}
i++;
}
});
}
// gallery: mode change
function editmode(){
const btnElement = document.getElementById('btnEdit');
var html;
if (btnElement.innerHTML == '편집'){
html = '완료';
$('#btnDel').show();
$('.imgCheck').show();
$('.filebox').show();
}
else {
html = '편집';
$('#btnDel').hide();
$('.imgCheck').hide();
$('.filebox').hide();
}
btnElement.innerHTML = html;
}
// gallery: exhibition menu parameter
function setChildValue(index) {
window.location.href = "exhibition_pic.html?index=" + index;
}
// gallery: move to comment page
function toCommentPage(pk){
window.location.href = "comment.html?pk=" + pk;
}
var sel_file;
// ready function
$(document).ready(function(){
var fileTarget = $('.filebox .upload-hidden');
// file name connecting
fileTarget.on('change', function(){
if (window.FileReader){
var filename = $(this)[0].files[0].name;
}
else {
var filename = $(this).val().split('/').pop().split('\\').pop();
}
$(this).siblings('.upload-name').val(filename);
});
// gallery data load
galleryLoad();
});
</script>
</body>
</html>