blob: cbd75b5216525fa5c2074b9b41e3d879c042b41e (
plain)
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
|
const utils = {
parseQuery: queryString => {
if (queryString.indexOf("?") === -1) return {};
queryString = queryString.split("?")[1];
const query = {};
for (let part of queryString.split("&")) {
const keyValue = part.split("=");
query[keyValue[0]] = keyValue[1] ? keyValue[1] : null;
}
return query;
},
percent: (count, total) => {
const percent = Math.floor((count / total) * 10000) / 100;
if (!percent) {
return 0;
}
return percent;
},
saveBlobAsFile: (blob, filename) => {
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.style.display = "none";
document.body.appendChild(a);
a.href = url;
a.download = filename;
a.click();
document.body.removeChild(a);
},
millisToTimeString(totalMilliseconds) {
let milliseconds = (totalMilliseconds % 1000) + "";
milliseconds = milliseconds.padStart(3, "0");
let seconds = (Math.floor(totalMilliseconds / 1000) % 60) + "";
seconds = seconds.padStart(2, "0");
let minutes = (Math.floor(totalMilliseconds / 60000) % 60) + "";
minutes = minutes.padStart(2, "0");
let hours = Math.floor(totalMilliseconds / 3600000) + "";
hours = hours.padStart(2, "0");
return `${hours}:${minutes}:${seconds}`;
}
};
|