-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjpeg-thumbnail-reader.html
398 lines (309 loc) · 8.7 KB
/
jpeg-thumbnail-reader.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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<!-- Copyright: Vitali Fedulov ([email protected]) 2015-2023 -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>JPEG embedded thumbnail reader</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto">
<link rel="icon" type="image/png" href="images/favicon.png">
<link rel="stylesheet" type="text/css" href="css/clustering.css">
</head>
<body>
<div class="flex-container-select-files">
<div class="flex-center-horizontally">
<div>
<h2 class="text-centered clustering-title">JPEG Embedded Thumbnail Reader</h2>
</div>
<div id="terms-of-service">
<p class="terms-of-service-header text-centered">Terms of service and data protection</p>
<div id="terms"></div>
</div>
<div>
<p id="messages" class="hidden">Messages</p>
<div id="ok-button" class="text-centered">
<div class="button">OK</div>
</div>
<div id="file-selector" class="text-centered">
<input class="hidden" type="file" id="filesSelected" webkitdirectory multiple accept="image/*" onchange="v30(this.files)" onclick="v8()">
<a class="button">Select a folder with images</a>
</div>
<div class="link-block text-centered">
<a class="home-cancel-link" id="cancel-link" onclick="v28()">Cancel</a>
<a class="home-cancel-link" href="/similar.pictures/index.html">Home</a>
</div>
</div>
</div>
</div>
<div class="fixed-top hidden">
<div class="fixed-top-gray">
<a href = "index.html" class="logo-href"><span class="logo">JPEG Embedded Thumbnail Reader</a>
<div class="button button-new-search">New read</div>
</div>
<div class="fixed-white-1">
<div class="progress">
<div id="progress-bar"></div>
</div>
<div class="progress-text"></div>
</div>
<div class="fixed-white-2 hidden">
<span class="found-clusters"></span> <span> (</span><span class="view-list">show/hide as list</span><span>)</span>
<textarea class="textarea"></textarea>
<p class="explanation">
<small class="small">Scroll down to view all thumbnails.</small>
</p>
</div>
</div>
<div id="clusters" class="clusters"></div>
<script>
function load(url, element) {
fetch(url)
.then(response => response.text())
.then(data => {
element.innerHTML = data;
})
.catch(error => {
console.error('Error:', error);
});
}
window.addEventListener('DOMContentLoaded', () => {
load("tos_en.html", document.querySelector("#terms"));
document.querySelector("#ok-button").style.display = 'none';
document.querySelector("#cancel-link").style.display = 'none';
document.querySelector(".button-new-search").addEventListener('click', (e) => {
v35();
});
document.querySelector("#ok-button").addEventListener('click', (e) => {
v35();
});
window.scrollTo({top: 0});
});
var v45 = {
v32 : 80000, v7 : 50*1024*1024, v44 : 0, v39 : 0, v14 : Date.now(),
v29 : 0,
v25 : [], v47 : "image/jpeg",
v46 : "",
v23 : (function () {
var v11 = new Uint32Array(10); window.crypto.getRandomValues(v11);
var v24 = "";
for (var i = 0; i < v11.length; i++) {
v24 += v11[i].toString(36); }
return v24
}) (),
v60 : null,
v41 : 0,
v1 : 1000,
v0 : null,
v22 : '\n',
v13 : 0,
v10 : false,
v5 : 0,
};
function v4() { return Math.floor((Date.now() - v45.v14) / 1000);
}
function v28() {
v35();
}
function v35() {
location.reload();
window.scrollTo({top: 0});
}
var v26 = document.getElementById('file-selector');
v26.addEventListener('click', v19);
function v19() {
var v62 = document.getElementById('filesSelected');
if (!!v62.webkitdirectory == false) {
alert('This browser does not support folder selection. Please try latest Chrome, Firefox or Edge.');
return;
}
v62.click();
}
function v27(v59, v55, v48) {
var v56 = new FileReader();
v56.readAsArrayBuffer(v45.v60[v55].slice(0, v45.v32));
v56.onload = function (v58) {
var v61 = new Uint8Array(v58.target.result),
v57, v68;
for (var v70 = 2; v70 < v61.length; v70++) {
if (v61[v70] == 0xFF) {
if (!v57) {
if (v61[v70 + 1] == 0xD8) {
v57 = v70;
}
} else {
if (v61[v70 + 1] == 0xD9) {
v68 = v70 + 2; break;
}
}
}
}
if (v57 && v68) {
v48(new Blob([v61.subarray(v57, v68)], {type:v45.v47}));
} else {
v48(null);
}
};
v56.onerror = function() {
v48(null);
};
}
function v15(v55) {
if (v45.v13 == 0) {
document.querySelector(".fixed-top").style.display = 'none';
document.querySelector(".flex-container-select-files").style.display = 'block';
document.querySelector("#messages").textContent = "No images with embedded thumbnails found. Please select a different folder.";
document.querySelector("#messages").style.display = 'block';
document.querySelector("#file-selector").style.display = 'none';
document.querySelector("#cancel-link").style.display = 'none';
document.querySelector("#ok-button").style.display = 'block';
return;
}
document.querySelector(".progress").parentNode.removeChild( document.querySelector(".progress"));
var v71 = "s";
if (v55 + 1 == 1) {
v71 = "";
}
v9(".progress-text", "Successfully scanned ".concat(v45.v60.length, " file", v71, "."));
if (v45.v29 == 0) {
v9(".progress-text", "Zero thumbnails found from the successfully scanned ".concat(v45.v60.length, " file", v71, "."));
}
return;
}
function v9(v17, v66) {
document.querySelector(v17).textContent = v66;
}
function v3() {
var v71 = "s";
if (v45.v29 == 1) {
v71 = "";
}
v9(".found-clusters", "Found ".concat(v45.v29, ' embedded thumbnail', v71));
}
var v33 = document.querySelector("#progress-bar");
function v2(v55) {
if (v55 + 1 == v45.v41) {
return;
}
v9(".progress-text", "Please wait... Reading ".concat(v55, ' from ', v45.v41, ' selected files.'));
var v52 = Math.floor(100 * (v55 + 1) / v45.v41);
if (v52 < 5) {
v52 = 5;
}
v33.style.width = "".concat(v52, "%");
}
function v51(v31, v20) {
var v65 = document.createElement("div");
v65.className = v31;
v20.appendChild(v65);
return v65;
}
var v34 = document.getElementById("clusters");
function v6(v43) {
var v40 = v51("cluster", v34);
var v42 = v51("cluster-num", v40);
v42.textContent = v43;
var v18 = v51("cluster-content", v40);
v51("cluster-imgs", v18);
v51("cluster-paths", v18);
}
function v12(v43, v59, v69) {
var v53 = document.querySelectorAll( ".cluster-imgs" )[v43];
var v54 = v51("cluster-img-div", v53);
v69.classList.add("cluster-img");
v54.appendChild(v69);
var v36 = v51("image-size", v54);
v36.textContent = "".concat(v69.width, "×", v69.height);
var v16 = document.querySelectorAll( ".cluster-paths" )[v43];
var v38 = v51("img-path", v16);
var v63 = v45.v60[v45.v25[v59]];
v38.textContent = v63.webkitRelativePath;
v45.v5++;
}
function v37() {
var v64 = "";
var v49 = document.querySelectorAll(".img-path");
for (v72 = 0; v72 < v49.length; v72++) {
var v50 = v49[v72].textContent;
v64 = v64.concat(v50, v45.v22);
}
v64 = v64.slice(0, -1); document.querySelector(".textarea").value = v64;
document.querySelector(".textarea").classList.toggle("textareaon");
}
function v8() {
document.querySelector("#terms-of-service").style.display = 'none';
v45.v0 = setTimeout(function() {
document.querySelector("#messages").textContent = 'Please wait if you selected a very large number of images: it may take tens of seconds before the clustering starts.';
document.querySelector("#messages").style.display = 'block';
document.querySelector("#file-selector").style.display = 'none';
document.querySelector("#cancel-link").style.display = 'block';
}, v45.v1);
}
function v30(v60) {
v45.v5 = 0;
clearTimeout(v45.v0);
document.querySelector("#file-selector").style.display = 'none';
v45.v60 = v60;
v45.v46 = v60[0].webkitRelativePath.split("/")[0];
v45.v41 = v60.length;
var v55 = 0; var v59 = 0;
document.querySelector(".flex-container-select-files").style.display = 'none';
document.querySelector(".fixed-top").style.display = 'block';
document.querySelector(".view-list").addEventListener('click', (e) => {
v37();
});
document.querySelector(".fixed-white-2").style.display = 'block';
v3();
v21(v55, v59);
}
function v21(v55, v59) {
if (v55 >= v45.v41) {
v15(v55);
return;
}
if (v55 < 5 || v55 % 5 === 0) {
v2(v55);
}
if (!v45.v47 == v45.v60[v55].type || v45.v60[v55].size > v45.v7) {
v55++;
v21(v55, v59);
return;
}
v45.v44 = v59 + 1;
v27(v59, v55, function(v67) {
if (v67 == null) {
v55++;
v59++;
v21(v55, v59);
return;
} else {
var v69 = new Image();
v69.onload = function() {
v45.v13++;
v45.v25[v59] = v55;
v45.v39 = v55 + 1;
v45.v29++;
v6(v45.v29);
v12(v45.v29 - 1, v59, v69);
v55++;
v59++;
if (!v45.v10) {
v45.v10 = true;
}
URL.revokeObjectURL(v69.src); v3();
v21(v55, v59);
return;
};
v69.onerror = function() {
URL.revokeObjectURL(v69.src); v55++;
v59++;
v21(v55, v59);
return;
};
v69.src = URL.createObjectURL(v67);
return;
}
});
}
</script>
</body>
</html>