-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
151 lines (140 loc) · 5.59 KB
/
index.html
File metadata and controls
151 lines (140 loc) · 5.59 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>H2K Anonymizer Web - StepWin</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link rel="stylesheet" type="text/css" media="screen" href="main.css" /> -->
<script src="jszip.min.js"></script>
<script src="saveas.js"></script>
<script src="cleaner.js"></script>
<style>
* {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
box-sizing: border-box;
text-align: center;
}
html, body {
margin: 0;
width: 100%;
height: 100%;
background-color: rgb(73, 121, 209);
}
a, a:visited {
color: white;
}
.container {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.innerContainer {
max-width: 450px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 10px;
border-radius: 8px;
background-color: rgba(0, 0, 0, 0.411);
color: wheat;
}
</style>
</head>
<body>
<div class="container" ondrop="handleDrop(event);" ondragover="prevent(event);" ondrag="this.style.backgroundColor='choclate'">
<div class="innerContainer">
<h1>HOT2000 Anonymizer</h1>
<br>
<p class="message">Drag and Drop your files anywhere on this page.</p>
<br>
<br>
<p>For a large number of files, a minimum of 2GB free RAM, and Chrome browser are recommended.
The processed files may be downloaded in multiple batches.
You can use "Extract All" zip option to unzip them in one location.
</p>
<br>
<br>
<p>The process is completely offline. Files will not leave your computer.</p>
<br>
<p>Visit repository for <a target="_blank" href="https://github.com/StepWin/h2kAnonymizer-Web">more info and source code</a>.
<br>
File any <a target="_blank" href="https://github.com/StepWin/h2kAnonymizer-Web/issues">issues here.</a></p>
<a class="download"></a>
</div>
</div>
<script>
var batch_size = 2000 //this can be tweaked
function prevent(ev) {
ev.preventDefault();
}
var message_el = document.querySelector('p.message');
var files = [];
var file_count;
var processed = 0;
var lock = false;
function handleDrop(ev) {
// Mostly copied from MDN, merges the two file reading APIs
// Prevent default behavior (Prevent file from being opened)
ev.preventDefault();
if(lock) {
alert('please wait for the existing conversion to finish.')
return
}
lock = true;
message_el.innerHTML = 'Processing...'
if (ev.dataTransfer.items) {
file_count = ev.dataTransfer.items.length;
for (var i = 0; i < file_count; i++) {
if (ev.dataTransfer.items[i].kind === 'file') {
var file = ev.dataTransfer.items[i].getAsFile();
files.push(file);
if( i === file_count -1 ) batchFiles(); //start the first file batch
}
}
} else {
file_count = ev.dataTransfer.files.length
for (var i = 0; i < file_count; i++) {
var file = ev.dataTransfer.files[i]
files.push(file);
if( i === file_count -1 ) batchFiles(); //start the first file batch
}
}
}
function batchFiles() { //splits the files and sends the first batch one-by-one to the 'readfile'
var zip = new JSZip();
var progress = file_count - files.length;
var batch = files.splice(0, batch_size);
batch.forEach( function (b) {
readFile(b, zip, batch.length, progress);
})
}
function readFile(file, zip, batch_count, progress) { // reads all the files in batch, once done, sends to 'packfiles'
let reader = new FileReader();
reader.onerror = function (err) {
console.log(err);
}
reader.onload = function (event) {
zip.file( 'a_' + file.name, cleanH2K(event.target.result, file.name) );
var processed = Object.keys(zip.files).length;
message_el.innerHTML = 'Processing ' + (progress + processed) + ' of ' + file_count + '...';
if ( processed === batch_count ) packFiles(zip, batch_count);
};
reader.readAsText(file);
}
function packFiles(zip, batch_count) { //packs the files, once downloaded looks for the next batch
message_el.innerHTML = 'Packaging a batch...';
zip.generateAsync({type:"blob"}).then(function(content) {
saveAs(content, "anonymized.zip");
if ( batch_count < batch_size) { //must be final
message_el.innerHTML = 'Drag more files here'
lock = false;
} else batchFiles();
});
}
</script>
</body>
</html>