|
1 | 1 | export function initBandwidthTool(container) { |
| 2 | + if (!container) return; |
| 3 | + |
2 | 4 | container.innerHTML = ` |
3 | | - <div class="grid grid-cols-1 lg:grid-cols-2 gap-6"> |
4 | | - <div class="space-y-4"> |
5 | | - <div> |
6 | | - <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">File Size</label> |
7 | | - <div class="flex gap-2"> |
8 | | - <input id="bw-size" type="number" placeholder="100" class="flex-1 bg-black border border-border-dark rounded px-3 py-2 text-sm mono-data text-white placeholder-slate-700 focus:border-primary transition-colors"> |
9 | | - <select id="bw-size-unit" class="bg-black border border-border-dark rounded px-3 py-2 text-sm mono-data text-white cursor-pointer"> |
10 | | - <option value="1">Bytes</option> |
11 | | - <option value="1024" selected>KB</option> |
12 | | - <option value="1048576">MB</option> |
13 | | - <option value="1073741824">GB</option> |
14 | | - </select> |
15 | | - </div> |
16 | | - </div> |
17 | | - <div> |
18 | | - <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Transfer Speed</label> |
19 | | - <div class="flex gap-2"> |
20 | | - <input id="bw-speed" type="number" placeholder="50" class="flex-1 bg-black border border-border-dark rounded px-3 py-2 text-sm mono-data text-white placeholder-slate-700 focus:border-primary transition-colors"> |
21 | | - <select id="bw-speed-unit" class="bg-black border border-border-dark rounded px-3 py-2 text-sm mono-data text-white cursor-pointer"> |
22 | | - <option value="1">bps</option> |
23 | | - <option value="1000">Kbps</option> |
24 | | - <option value="1000000" selected>Mbps</option> |
25 | | - <option value="1000000000">Gbps</option> |
26 | | - </select> |
27 | | - </div> |
| 5 | + <div class="max-w-xl mx-auto space-y-6"> |
| 6 | + <div class="bg-surface-dark cyber-border rounded p-6"> |
| 7 | + <h4 class="text-xs font-bold text-slate-500 uppercase tracking-widest mb-4">Bandwidth Calculator</h4> |
| 8 | + <div class="space-y-4"> |
| 9 | + <div class="grid grid-cols-3 gap-2"> |
| 10 | + <div class="col-span-2"> |
| 11 | + <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">File Size</label> |
| 12 | + <input id="bw-size" type="number" step="any" placeholder="100" class="w-full bg-black border border-border-dark rounded px-3 py-2 text-sm mono-data text-white focus:border-primary transition-colors"> |
| 13 | + </div> |
| 14 | + <div> |
| 15 | + <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Unit</label> |
| 16 | + <select id="bw-size-unit" class="w-full bg-black border border-border-dark rounded px-3 py-2 text-sm mono-data text-white cursor-pointer focus:border-primary transition-colors"> |
| 17 | + <option value="KB">KB</option> |
| 18 | + <option value="MB" selected>MB</option> |
| 19 | + <option value="GB">GB</option> |
| 20 | + <option value="TB">TB</option> |
| 21 | + </select> |
| 22 | + </div> |
| 23 | + </div> |
| 24 | + <div class="grid grid-cols-3 gap-2"> |
| 25 | + <div class="col-span-2"> |
| 26 | + <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Network Speed</label> |
| 27 | + <input id="bw-speed" type="number" step="any" placeholder="10" class="w-full bg-black border border-border-dark rounded px-3 py-2 text-sm mono-data text-white focus:border-primary transition-colors"> |
| 28 | + </div> |
| 29 | + <div> |
| 30 | + <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Unit</label> |
| 31 | + <select id="bw-speed-unit" class="w-full bg-black border border-border-dark rounded px-3 py-2 text-sm mono-data text-white cursor-pointer focus:border-primary transition-colors"> |
| 32 | + <option value="Kbps">Kbps</option> |
| 33 | + <option value="Mbps" selected>Mbps</option> |
| 34 | + <option value="Gbps">Gbps</option> |
| 35 | + </select> |
| 36 | + </div> |
| 37 | + </div> |
| 38 | + <button id="btn-bw-calc" class="w-full bg-primary hover:bg-primary/80 text-white text-xs font-bold uppercase tracking-widest py-3 rounded transition-colors shadow-lg shadow-primary/20 mt-2"> |
| 39 | + Calculate Time |
| 40 | + </button> |
| 41 | + </div> |
28 | 42 | </div> |
29 | | - <button id="btn-bw-calc" class="bg-primary hover:bg-primary/80 text-white text-xs font-bold uppercase tracking-widest px-4 py-2 rounded transition-colors">Calculate</button> |
30 | | - </div> |
31 | | - <div id="bw-results" class="bg-surface-dark cyber-border rounded p-4 text-slate-400 text-sm"> |
32 | | - Enter a file size and speed to calculate transfer time. |
33 | | - </div> |
| 43 | + |
| 44 | + <div id="bw-results"></div> |
34 | 45 | </div> |
35 | 46 | `; |
36 | 47 |
|
37 | | - const sizeInput = document.getElementById("bw-size"); |
38 | | - const sizeUnit = document.getElementById("bw-size-unit"); |
39 | | - const speedInput = document.getElementById("bw-speed"); |
40 | | - const speedUnit = document.getElementById("bw-speed-unit"); |
41 | | - const btnCalc = document.getElementById("btn-bw-calc"); |
42 | | - const resultContainer = document.getElementById("bw-results"); |
| 48 | + const sizeInput = container.querySelector("#bw-size"); |
| 49 | + const sizeUnit = container.querySelector("#bw-size-unit"); |
| 50 | + const speedInput = container.querySelector("#bw-speed"); |
| 51 | + const speedUnit = container.querySelector("#bw-speed-unit"); |
| 52 | + const btnCalc = container.querySelector("#btn-bw-calc"); |
| 53 | + const resultContainer = container.querySelector("#bw-results"); |
43 | 54 |
|
44 | 55 | if (!sizeInput || !resultContainer) return; |
45 | 56 |
|
|
0 commit comments