MCPcopy Create free account
hub / github.com/Eltaurus-Lt/CourseDump2022 / updScanProgress

Function updScanProgress

progressbars.js:82–117  ·  view source on GitHub ↗
(threadN, cidd, levels_done, levels_todo, label = undefined)

Source from the content-addressed store, hash-verified

80
81//progress updates (glue)
82function updScanProgress(threadN, cidd, levels_done, levels_todo, label = undefined) {
83 //text progress (console)
84 const done_str = levels_todo !== "" ? `${levels_done}/${levels_todo}` : "";
85 if (levels_done === 0) {
86 if (levels_todo || label) {
87 console.log(`thread: ${threadN} | Start scanning ${cidd['cid']}`);
88 } else {
89 console.log(`thread: ${threadN} | Fetching metadata for ${cidd['cid']}`);
90 }
91 } else {
92 console.log(`thread: ${threadN} | cid: ${cidd['cid']} | scan progress: ${done_str}`);
93 }
94
95 const progress_bar = scanProgressBar(threadN);
96 if (!progress_bar) return;
97
98 //GUI progress
99 if (label !== undefined) {
100 progress_bar.setAttribute("progress-label", label);
101 }
102 progress_bar.setAttribute("progress-ratio", done_str);
103
104 if (levels_todo || label) {
105 if (!isNaN(parseInt(levels_todo, 10))) {
106 progress_bar.style.backgroundPosition = (100 * (1. - levels_done/levels_todo)).toFixed(2)+"%";
107 } else {
108 progress_bar.style.backgroundPosition = "42%";
109 }
110 } else {
111 progress_bar.classList.add('resetting');
112 progress_bar.style.backgroundPosition = "100%";
113 setTimeout(() => {
114 progress_bar.classList.remove('resetting');
115 }, 500);
116 }
117}
118
119function updBatchProgress(batch_done = 0, batch_size = 1, cidd = "") {
120 const done_str = `${batch_done}/${batch_size}`;

Callers 1

scanCourseFunction · 0.85

Calls 1

scanProgressBarFunction · 0.85

Tested by

no test coverage detected