-
Notifications
You must be signed in to change notification settings - Fork 0
/
progressBar.js
67 lines (55 loc) · 1.81 KB
/
progressBar.js
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
function CreateProgressBar(){
//Create the wrapper
let progressBar = document.createElement("div");
progressBar.classList.add("download_progress_bar");
progressBar.style.position = "fixed";
progressBar.style.bottom = "0";
progressBar.style.background = "#222";
progressBar.style.padding = "5px";
progressBar.style.margin = "6px";
progressBar.textContent= "Downloading....";
progressBar.style.color = "white";
progressBar.style.fontSize = "12";
progressBar.style.borderRadius = "5px";
//Create the innerbar to fill the progress
let innerBar = document.createElement("div");
innerBar.classList.add("inner-bar")
innerBar.style.position = "absolute";
innerBar.style.left = "0";
innerBar.style.right = "100%";
innerBar.style.background = "linear-gradient(120deg, #fc1163 0%, #ee8027 100%)";
innerBar.style.top = "0";
innerBar.style.bottom = "0";
innerBar.style.transition = ".56s ease all";
innerBar.style.borderRadius = progressBar.style.borderRadius;
//Append innerbar
progressBar.appendChild(innerBar);
//Append to document boddy if there is no progress bar
document.body.append(progressBar);
}
/**
* Updates the progress bar
* @param {*} progress
*/
function UpdateProgressBar(progress) {
if(document.querySelector(".inner-bar")){
let depreciatingProgress = 100 - progress;
let innerProgressBar = document.querySelector(".inner-bar");
innerProgressBar.style.right = depreciatingProgress.toString() + "%"
}
}
/**
* Remove the progress bar.
* Hoisting
*/
function RemoveProgressBar(){
if(document.querySelector(".download_progress_bar")){
let ProgressBarWrapper = document.querySelector(".download_progress_bar");
document.body.removeChild(ProgressBarWrapper);
}
}
module.exports = {
CreateProgressBar,
UpdateProgressBar,
RemoveProgressBar
}