-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbin.html
More file actions
73 lines (68 loc) · 2.39 KB
/
bin.html
File metadata and controls
73 lines (68 loc) · 2.39 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
---
layout: generator
title: "Binary File Generator"
subtitle: "Generate binary file with custom configuration"
tab_id: "BIN"
generator_script: "/js/generators/binary.js"
redirect_from:
- /bin.html
---
<h2 class="text-2xl font-bold mb-4">Binary File Generator</h2>
<form id="form-bin" class="space-y-4">
<div class="form-control">
<label class="label">
<span class="label-text">File Size</span>
</label>
<div class="flex flex-col sm:flex-row gap-2">
<input
type="number"
name="size"
value="1"
min="0.01"
step="0.01"
class="input input-bordered"
required
/>
<select name="sizeUnit" class="select select-bordered">
<option value="KB">KB</option>
<option value="MB">MB</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-primary w-full">
Generate & Download
</button>
</form>
<script>
document
.getElementById("form-bin")
.addEventListener("submit", async (e) => {
e.preventDefault();
const formData = new FormData(e.target);
const config = {
size: parseFloat(formData.get("size")),
sizeUnit: formData.get("sizeUnit"),
};
try {
const blob = await generateBinary(config);
logToUI("Preparing file...");
const shareTitle = `Binary file ${config.size} ${config.sizeUnit}`;
const filename = `Binary_file_${config.size}_${config.sizeUnit}.bin`;
const result = await downloadOrShareFile(blob, filename, "binary", shareTitle);
if (result.method === 'download') {
logToUI("✓ Download complete!");
}
// Track in Google Analytics
gtag("event", "generate_bin", {
event_category: "file_generation",
event_label: "binary",
size: config.size,
size_unit: config.sizeUnit,
});
} catch (error) {
logToUI(`❌ Error: ${error.message}`);
showError("Binary generation failed: " + error.message);
hideProgress();
}
});
</script>