MCPcopy
hub / github.com/copy/v86 / show_progress

Function show_progress

src/browser/main.js:44–87  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

42 let progress_ticks = 0;
43
44 function show_progress(e)
45 {
46 const el = $("loading");
47 el.style.display = "block";
48
49 if(e.file_name.endsWith(".wasm"))
50 {
51 const parts = e.file_name.split("/");
52 el.textContent = "Fetching " + parts[parts.length - 1] + " ...";
53 return;
54 }
55
56 if(e.file_index === e.file_count - 1 && e.loaded >= e.total - 2048)
57 {
58 // last file is (almost) loaded
59 el.textContent = "Done downloading. Starting now ...";
60 return;
61 }
62
63 let line = "Downloading images ";
64
65 if(typeof e.file_index === "number" && e.file_count)
66 {
67 line += "[" + (e.file_index + 1) + "/" + e.file_count + "] ";
68 }
69
70 if(e.total && typeof e.loaded === "number")
71 {
72 var per100 = Math.floor(e.loaded / e.total * 100);
73 per100 = Math.min(100, Math.max(0, per100));
74
75 var per50 = Math.floor(per100 / 2);
76
77 line += per100 + "% [";
78 line += "#".repeat(per50);
79 line += " ".repeat(50 - per50) + "]";
80 }
81 else
82 {
83 line += ".".repeat(progress_ticks++ % 50);
84 }
85
86 el.textContent = line;
87 }
88
89 function $(id)
90 {

Callers 1

start_emulationFunction · 0.85

Calls 1

$Function · 0.85

Tested by

no test coverage detected