Skip to content

Commit

Permalink
Add hours option
Browse files Browse the repository at this point in the history
  • Loading branch information
ejb committed Nov 23, 2016
1 parent 0954b9c commit 408ecf6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ A lightweight JavaScript library that creates customisable progress bars for HTM

## Changelog

### v1.1.0

- Add `hours` option

### v1.0.1

- Bugfix: work as a global
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "progressor.js",
"description": "Lightweight, customisable progress bars for HTML5 video & audio",
"version": "1.0.1",
"version": "1.1.0",
"homepage": "https://github.com/ejb/progressor.js",
"author": "Elliot Bentley <[email protected]> (http://ejb.github.io)",
"keywords": [
Expand Down
17 changes: 14 additions & 3 deletions progressor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
this._bar = options.bar;
this._text = options.text;
this._time = options.time;
this._hours = options.hours;
this.initProgressBar();
this.initMedia();
};
Expand Down Expand Up @@ -52,9 +53,19 @@
};

Progressor.prototype.formatTime = function ( time ) {
var minutes = Math.floor(time / 60);
var seconds = ("0" + Math.round( time - minutes * 60 ) ).slice(-2);
return minutes+":"+seconds;
var hours = Math.floor(time / 3600).toString();
if (this._hours) {
var minutes = ("0" + Math.floor(time / 60) % 60).slice(-2);
var seconds = ("0" + Math.floor( time % 60 )).slice(-2);
if (hours !== '0') {
return hours + ":" + minutes + ":" + seconds;
}
return minutes + ":" + seconds;
} else {
var minutes = Math.floor(time / 60);
var seconds = ("0" + Math.round( time - minutes * 60 ) ).slice(-2);
return minutes+":"+seconds;
}
}

Progressor.prototype.updateTimeCount = function(){
Expand Down

0 comments on commit 408ecf6

Please sign in to comment.