Source code of Mrcomputer1's Post Count Progress Bar version 2 (see master-1.x for version 1 in PHP).
const done = 50;
const goal = 100;
const bar = new progressBar();
bar.setProgress(done, goal)
.setUnit("posts")
.use(new progressBar.themes.default())
.use(new progressBar.generators.CanvasBigGenerator("#canvas"));
// Generate the bar into the canvas with
bar.generate();
bar.download(url => window.open(url));
Note: new progressBar
will work the same as new progressBar.ProgressBar
Extensions will be run before the generator.
Generators are used when generate()
is called.
Themes are used by the generator.
Runs the generater.
Generates a download link and returns it in the callback function.
Returns the extension of the download file, with a .
.
For example, the canvas generators return .png
and the text generators return .txt
Called when ran.
super();
// Your constructor should set the following to colours in hex format (#rrggbb).
this.background
this.incomplete
this.complete
this.text
super(element); // This will set `this.element`.
Called when ran
The exact size of the generated progress bar or null if no exact size.
Generates a download link for the progress bar.
Returns the extension of the download.
The constructor is not required. But if you do use it you must include super(element);
at the top.
Called when ran
The needed size of the canvas
done/goal posts (100 lines) percent%
element
must be either a div element (which will be emptied and a canvas created inside) or a canvas.
done/goal posts (bar) percent%
element
must be either a div element (which will be emptied and a canvas created inside) or a canvas.
Background is progress bar
Posts count is on top
element
must be either a div element (which will be emptied and a canvas created inside) or a canvas.
Background is progress bar
Percent is on top
element
must be either a div element (which will be emptied and a canvas created inside) or a canvas.
done/goal posts (bar) percent%.
Background and text colour are ignored for the text generator.
Black background, white text, green complete lines, red incomplete lines
White background, black text, green complete lines, red incomplete lines
Blue background, white text, green complete lines, red incomplete lines
Values should be hex colour codes. (#rrggbb
)
Clear the canvas before generating. Only for use when generating to a canvas.
Deprecation Reason: Canvas generators draw a background, which makes clearing the canvas pointless.
Set the canvas size before generating. Only for use when generating to a canvas.