Author: jruchaud Date: 2015-04-28 13:27:18 +0000 (Tue, 28 Apr 2015) New Revision: 1282 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1282 Log: Add global timer Modified: wit/js/components/ActionsBar.js wit/js/components/Time.js wit/js/services/TimerService.js wit/package.json Modified: wit/js/components/ActionsBar.js =================================================================== --- wit/js/components/ActionsBar.js 2015-04-28 13:06:53 UTC (rev 1281) +++ wit/js/components/ActionsBar.js 2015-04-28 13:27:18 UTC (rev 1282) @@ -27,18 +27,12 @@ <button type="button" className="btn btn-primary btn-lg" onClick={this.prevHistory}> <span className="glyphicon glyphicon-step-backward" aria-hidden="true"></span> </button> - <button type="button" className="btn btn-primary btn-lg"> - <span className="glyphicon glyphicon-backward" aria-hidden="true"></span> - </button> <button type="button" className="btn btn-primary btn-lg" onClick={this.onPlay}> <span className="glyphicon glyphicon-play" aria-hidden="true"></span> </button> <button type="button" className="btn btn-primary btn-lg" onClick={this.onStop}> <span className="glyphicon glyphicon-stop" aria-hidden="true"></span> </button> - <button type="button" className="btn btn-primary btn-lg"> - <span className="glyphicon glyphicon-forward" aria-hidden="true"></span> - </button> <button type="button" className="btn btn-primary btn-lg" onClick={this.nextHistory}> <span className="glyphicon glyphicon-step-forward" aria-hidden="true"></span> </button> Modified: wit/js/components/Time.js =================================================================== --- wit/js/components/Time.js 2015-04-28 13:06:53 UTC (rev 1281) +++ wit/js/components/Time.js 2015-04-28 13:27:18 UTC (rev 1282) @@ -17,9 +17,14 @@ render: function() { return ( - <h1 className="digit"> - {this.state.getTime() ? this.state.getTime() : "00:00:00"} - </h1> + <div> + <h1 className="digit"> + {this.state.getTime() ? this.state.getTime() : "00:00:00"} + </h1> + <h5 className="digit"> + {this.state.getDayTime() ? this.state.getDayTime() : "00:00:00"} + </h5> + </div> ); } }); Modified: wit/js/services/TimerService.js =================================================================== --- wit/js/services/TimerService.js 2015-04-28 13:06:53 UTC (rev 1281) +++ wit/js/services/TimerService.js 2015-04-28 13:27:18 UTC (rev 1282) @@ -9,6 +9,7 @@ var tags = ["wit", "js", "dev"]; var time = null; var idleTime = null; +var dayTime = 0; var historyIndex = -1; @@ -32,6 +33,11 @@ }); }; +var insertLog = function(tags, start, end) { + dayTime += moment(end).diff(moment(start)); + db.insertLog(tags, start, end); +}; + exports.start = function() { time = idleTime || new Date(); idleTime = null; @@ -49,7 +55,7 @@ } if (time && !idleTime) { - db.insertLog(tags, time, new Date()); + insertLog(tags, time, new Date()); time = null; timeChange(); } @@ -119,7 +125,7 @@ }; exports.removeIdle = function() { - db.insertLog(tags, time, idleTime); + insertLog(tags, time, idleTime); time = null; idleTime = null; @@ -128,7 +134,7 @@ }; exports.reassignIdle = function() { - db.insertLog(tags, time, idleTime); + insertLog(tags, time, idleTime); time = idleTime; clearTimeout(timeChangeTimer); @@ -169,3 +175,14 @@ exports.getLastTags = function() { return db.getLastTags(); }; + +exports.getDayTime = function() { + var diff = dayTime; + if (time) { + var now = moment(); + diff += now.diff(time); + } + + var value = moment(diff).utcOffset(0); + return value.format("HH:mm:ss"); +}; Modified: wit/package.json =================================================================== --- wit/package.json 2015-04-28 13:06:53 UTC (rev 1281) +++ wit/package.json 2015-04-28 13:27:18 UTC (rev 1282) @@ -4,9 +4,9 @@ "version": "1.0.0", "window": { "width": 480, - "height": 490, + "height": 520, "min_width": 480, - "min_height": 490, + "min_height": 520, "toolbar": true, "frame": true, "transparent": false