-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
80 lines (68 loc) · 2.1 KB
/
index.html
File metadata and controls
80 lines (68 loc) · 2.1 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
<!DOCTYPE html>
<head>
<title>steg webgpu test</title>
<style>
video {
max-width: 320px;
border: 1px solid #000000;
}
canvas {
max-width: 320px;
border: 1px solid #000000;
}
</style>
</head>
<body>
<div>
<div>
<input id="file" type="file" name="file">
</div>
<div>
<button id="save">Save</button>
</div>
<div>
<textarea disabled id="hex" rows="30" cols="48">
raw hex
</textarea>
<textarea disabled id="ascii" rows="30" cols="48">
ascii
</textarea>
</div>
<div id="stats"></div>
</div>
<div></div>
<div></div>
<div>
<script type="module">
import {decodeVideo} from "./index.js";
import {saveDataToFileFirefox} from "./index.js";
function processDecodedResults(result) {
document.querySelector("#save").addEventListener('click', saveWrapper(result));
const hexElem = document.getElementById("hex");
const asciiElem = document.getElementById("ascii");
let hex = ""
let ascii = "";
result.forEach((byte) => {
hex += byte.toString(16).padStart(2, "0") + " ";
ascii += String.fromCharCode(byte);
})
hexElem.value = hex;
asciiElem.value = ascii;
}
async function handleFileChange(event) {
if(event.target.files.length === 0) return;
const startTime = Date.now();
const blob = event.target.files[0];
let results = await decodeVideo(blob);
const decodeEndTime = Date.now();
processDecodedResults(results);
const statsElem = document.getElementById("stats");
statsElem.textContent = `Decode time: ${decodeEndTime - startTime}ms`;
}
document.querySelector("#file").addEventListener('change', handleFileChange);
function saveWrapper(decodedFrames) {
return () => saveDataToFileFirefox(decodedFrames)
}
</script>
</div>
</body>