forked from bonkscientist/weBonk.in
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drag_submit.html
336 lines (304 loc) · 10 KB
/
drag_submit.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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
<title>weBONK</title>
<!-- Favicon -->
<link rel="shortcut icon" type="image/jpg" href="img/weBONK_Favicon.png"/>
<!-- CSS -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-S6VJPCLSZD"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-S6VJPCLSZD');
</script>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5JL3HC5');</script>
<!-- End Google Tag Manager -->
</head>
<body class="black white-text">
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5JL3HC5"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<header>
<!-- Navigation Bar -->
<div class="navbar-fixed text-orange">
<!-- Dropdown Structure -->
<ul id="navbar-dropdown" class="dropdown-content">
<li><a href="https://dogebonk.com">DogeBonk.com</a></li>
<li><a href="https://bonkswap.com">BonkSwap.com</a></li>
<li class="divider"></li>
<li><a href="https://www.dextools.io/app/bsc/pair-explorer/0xbe80839a3be4d3953d5588a60a11aeaed286b593#utm_source=dogebonk.com">
DexTools
</a></li>
<li><a href="https://poocoin.app/tokens/0xae2df9f730c54400934c06a17462c41c08a06ed8">PooCoin</a></li>
<li><a href="https://charts.bogged.finance/0xAe2DF9F730c54400934c06a17462c41C08a06ED8">BOGCharts</a></li>
</ul>
<nav class="grey darken-5" role="navigation">
<div class="nav-wrapper">
<a id="logo-container" href="index.php" class="brand-logo">
<img class="left-align align-text-top" src="img/weBONK_Logo-Transparent.png" alt="weBonk logo">
</a>
<!-- Normal Nav Bar -->
<ul class="main-nav right hide-on-med-and-down">
<li class="waves-effect"><a href="index.php">HOME</a></li>
<li class="waves-effect"><a class="active" href="#">SUBMIT</a></li>
<li class="waves-effect"><a href="featured.html">
FEATURED
</a></li>
<!-- Dropdown Trigger -->
<li><a class="dropdown-trigger" href="#!" data-target="navbar-dropdown">DOGEBONK<i class="material-icons dropdown-arrow right">arrow_drop_down</i></a></li>
</ul>
<!-- Mobile Menu Trigger -->
<a href="#" data-target="nav-mobile" class="sidenav-trigger right">
<i class="material-icons">menu</i>
</a>
</div>
</nav>
</div>
<!-- Mobile Nav Bar -->
<ul id="nav-mobile" class="sidenav right-align">
<li><a href="index.php">Home</a></li>
<li><a class="active" href="#!">Submit</a></li>
<li><a class="active" href="featured.html">Featured</a></li>
<li><div class="divider"></div></li>
<li><a href="https://dogebonk.com">DogeBonk.com</a></li>
<li><a href="https://bonkswap.com">BonkSwap.com</a></li>
<li class="divider"></li>
<li><a href="https://www.dextools.io/app/bsc/pair-explorer/0xbe80839a3be4d3953d5588a60a11aeaed286b593#utm_source=dogebonk.com">
DexTools
</a></li>
<li><a href="https://poocoin.app/tokens/0xae2df9f730c54400934c06a17462c41c08a06ed8">PooCoin</a></li>
<li><a href="https://charts.bogged.finance/0xAe2DF9F730c54400934c06a17462c41C08a06ED8">BOGCharts</a></li>
</ul>
</header>
<main>
<div id="drop-area">
<form class="my-form">
<p>
Upload multiple files with the file dialog or by dragging and dropping
images onto the dashed region
</p>
<input
type="file"
id="fileElem"
multiple
accept="image/*"
onchange="handleFiles(this.files)"
/>
<label class="button" for="fileElem">Select some files</label>
</form>
</div>
<label>
Name
<input />
</label>
<div id="images-container"></div>
</main>
</body>
<style>
#drop-area {
border: 2px dashed #ccc;
border-radius: 20px;
width: 480px;
font-family: sans-serif;
margin: 100px auto;
padding: 20px;
}
#drop-area.highlight {
border-color: purple;
}
p {
margin-top: 0;
}
.my-form {
margin-bottom: 10px;
}
#gallery {
margin-top: 10px;
}
#gallery img {
width: 150px;
margin-bottom: 10px;
margin-right: 10px;
vertical-align: middle;
}
.button {
display: inline-block;
padding: 10px;
background: #ccc;
cursor: pointer;
border-radius: 5px;
border: 1px solid #ccc;
}
.button:hover {
background: #ddd;
}
#fileElem {
display: none;
}
#images-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
grid-template-rows: repeat(6, 200px);
grid-gap: 5px;
grid-auto-flow: dense;
}
#images-container .img-rel {
position: relative;
height: 100%;
width: 100%;
}
#images-container .img-abs {
position: absolute;
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: #ccc;
}
#images-container .hover-card {
position: absolute;
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: black;
display: none;
}
#images-container img {
max-height: 100%;
max-width: 100%;
height: auto;
width: auto;
}
</style>
<script>
let dropArea = document.getElementById("drop-area");
function handleImageHover(e) {
// display the editing info on specific card
// opacity
console.log(this.parentNode.style.background = 'red')
console.log('hover card sel',this.parentNode)
const hoverCard = this.parentNode.parentNode.querySelector('.hover-card');
hoverCard.style.display = "block"
}
function handleImageMouseOut(e) {
//
console.log(this)
this.style.display = "none"
}
function imageComponent(imgInstance) {
const hoverCard = document.createElement("div");
hoverCard.classList.add("hover-card");
const rel = document.createElement("div");
rel.classList.add("img-rel");
const abs = document.createElement("div");
abs.classList.add("img-abs");
const img = document.createElement("img");
img.src = imgInstance.url;
img.onmouseover = handleImageHover
hoverCard.onmouseout = handleImageMouseOut
abs.appendChild(img);
rel.appendChild(abs);
rel.appendChild(hoverCard);
return rel;
}
class Image {
constructor(file) {
this.file = file;
this.name = file.name;
this.type = file.type;
this.createUrl(file);
}
createUrl(file) {
if (file) {
this.url = URL.createObjectURL(file);
}
}
}
class ImageHolder {
constructor(imgEl) {
this.imageContainerEl = imgEl;
this.uploadedImages = [];
}
addImage(image) {
this.uploadedImages.push(image);
}
appendImages() {
this.imageContainerEl.innerHTML = "";
this.uploadedImages.forEach((img) => {
console.log("img", img);
const im = imageComponent(img);
this.imageContainerEl.appendChild(im);
});
}
}
const imageHolder = new ImageHolder(
document.getElementById("images-container")
);
["dragenter", "dragover", "dragleave", "drop"].forEach((eventName) => {
dropArea.addEventListener(eventName, preventDefaults, false);
});
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
["dragenter", "dragover"].forEach((eventName) => {
dropArea.addEventListener(eventName, highlight, false);
});
["dragleave", "drop"].forEach((eventName) => {
dropArea.addEventListener(eventName, unhighlight, false);
});
function highlight(e) {
dropArea.classList.add("highlight");
}
function unhighlight(e) {
dropArea.classList.remove("highlight");
}
dropArea.addEventListener("drop", handleDrop, false);
function setImagesToBeUploaded(imageArray) {
imageArray.forEach((imageInstance) => {
// appendImage(imageInstance)
// if(imageInstance.name === ) {
// }
imageHolder.addImage(new Image(imageInstance));
// console.log(imageInstance)
});
imageHolder.appendImages();
// imageHolder.imageContainerEl.innerHtml = imageComponent();
}
function handleDrop(e) {
let dt = e.dataTransfer;
console.log(dt);
let files = dt.files;
console.log("files", files);
const fyles = Array.from(files);
console.log("fyles", fyles);
setImagesToBeUploaded(fyles);
// handleFiles(files);
}
function handleFiles(files) {
console.log(files);
[...files].forEach(uploadFile);
}
function uploadFile(file) {
let url = "YOUR URL HERE";
let formData = new FormData();
formData.append("file", file);
}
</script>
</html>