-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloset.html
227 lines (210 loc) · 10.5 KB
/
closet.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard | Closet.io</title>
<link rel = "stylesheet" href = "style.css">
<link rel = "icon" href="images/logo.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
</head>
<body>
<div class="containers">
<div class="navbar">
<div class="logos">
Closet.io
</div>
<div class="nav">
<a class = "nb p" href = "dashboard.html">Home</a>
<a class = "nb q" href = "closet.html">Closet</a>
<a class = "nb r" href = "">Lookbook</a>
<a class = "nb s" href = "https://www.myntra.com/">Shop</a>
<a class = "nb t" href = "about.html">About</a>
</div>
</div>
<div class="content">
<div class="head1">Your <span class ="hn"><span class ="as">Closet</span></span></div>
<div class="content1">
<script>
let queuedImagesArray=[],
savedForm = document.querySelector("#saved-form"),
queuedForm = document.querySelector("#queued-form"),
savedDiv = document.querySelector(".saved-div"),
queuedDiv = document.querySelector(".queued-div"),
inputDiv= document.querySelector(".input-div"),
input = document.querySelector(".input-div input"),
serverMessage = document.querySelector(".server-message"),
deleteImages=[];
//Saved in Server Images
//Preview Images
input.addEventListener("change",() =>{
const files = input.files
for(let i =0;i< files.length; i++){
queuedImagesArray.push(files[i])
}
queuedForm.reset()
displayQueuedImages()
})
inputDiv.addEventListener("drop",(e) =>{
e.preventDefault()
const files = e.dataTransfer.files
for(let i = 0; i<files.length; i++){
if(!files[i].type.match("image")) continue
if(queuedImagesArray.every(image => image.name !== files[i].name))
queuedImagesArray.push(files[i])
}
displayQueuedImages()
})
function displayQueuedImages(){
let images = ""
queuedImagesArray.forEach((image, index) => {
images += `<div class="image">
<img src="${URL.createObjectURL(image)}" alt="image">
<span onclick ="deleteQueuedImage(${index})">×</span>
</div>`
})
queuedDiv.innerHTML = images
}
function deleteQueuedImage(index){
queuedImagesArray.splice(index, 1)
displayQueuedImages()
}
queuedForm.addEventListener("submit", (e) =>{
e.preventDefault()
sendQueuedImagesToServer()
})
function sendQueuedImagesToServer(){
const formData = new FormData(queuedForm)
queuedImagesArray.forEach((image, index) =>{
formData.append(`file[${index}]`,image)
})
fetch("upload", {
method: "POST",
body: formData
})
.then(response => {
if(response.status !== 200) throw Error(response.statusText)
location.reload()
})
.catch(error =>{
serverMessage.innerHTML = error
serverMessage.style.cssText = "background-color: #f8d7da; color: #b71c1c"
})
}
</script>
<div class="aisle">
<div class="headings"><h3>Topwear</h3></div>
<main class ="app">
<div class="header">
<h3>Upload Topwear</h3>
<div class="server-message"></div>
</div>
<div class="input-div">
<p>Drag & Drop your Topwear or <span class="browse">Browse</span></p>
<input type="file" class ="file" multiple="multiple" accept="image/png, image/jpeg, image/webp, image/jpg" onchange="previewImage(event)">
</div>
<form id="saved-form">
<div class="header">
<h3>Topwear</h3>
<button type="submit">Delete</button>
</div>
<div class="saved-div"></div>
</form>
<form id="queued-form">
<div class="header">
<h3>Preview</h3>
<button type="submit">Upload</button>
</div>
<div class="queued-div"></div>
</form>
</main>
</div>
<div class="aisle">
<div class="headings"><h3>Bottomwear</h3></div>
<main class ="app">
<div class="header">
<h3>Upload Bottomwear</h3>
<div class="server-message"></div>
</div>
<div class="input-div">
<p>Drag & Drop your Bottomwear or <span class="browse">Browse</span></p>
<input type="file" class ="file" multiple="multiple" accept="image/png, image/jpeg, image/webp, image/jpg" onchange="previewImage(event)">
</div>
<form id="saved-form">
<div class="header">
<h3>Bottomwear</h3>
<button type="submit">Delete</button>
</div>
<div class="saved-div"></div>
</form>
<form id="queued-form">
<div class="header">
<h3>Preview</h3>
<button type="submit">Upload</button>
</div>
<div class="queued-div"></div>
</form>
</main>
</div>
<div class="aisle">
<div class="headings"><h3>Footwear</h3></div>
<main class ="app">
<div class="header">
<h3>Upload Footwear</h3>
<div class="server-message"></div>
</div>
<div class="input-div">
<p>Drag & Drop your Footwear or <span class="browse">Browse</span></p>
<input type="file" class ="file" multiple="multiple" accept="image/png, image/jpeg, image/webp, image/jpg" onchange="previewImage(event)">
</div>
<form id="saved-form">
<div class="header">
<h3>Footwear</h3>
<button type="submit">Delete</button>
</div>
<div class="saved-div"></div>
</form>
<form id="queued-form">
<div class="header">
<h3>Preview</h3>
<button type="submit">Upload</button>
</div>
<div class="queued-div"></div>
</form>
</main>
</div>
<div class="aisle">
<div class="headings"><h3>Accessories</h3></div>
<main class ="app">
<div class="header">
<h3>Upload Clothes</h3>
<div class="server-message"></div>
</div>
<div class="input-div">
<p>Drag & Drop your Accessories or <span class="browse">Browse</span></p>
<input type="file" class ="file" multiple="multiple" accept="image/png, image/jpeg, image/webp, image/jpg" onchange="previewImage(event)">
</div>
<form id="saved-form">
<div class="header">
<h3>Accessories</h3>
<button type="submit">Delete</button>
</div>
<div class="saved-div"></div>
</form>
<form id="queued-form">
<div class="header">
<h3>Preview</h3>
<button type="submit">Upload</button>
</div>
<div class="queued-div"></div>
</form>
</main>
</div>
</div>
</div>
</div>
</body>
</html>