r1435 - in wit: . js js/components js/services
Author: jruchaud Date: 2015-05-22 14:01:07 +0000 (Fri, 22 May 2015) New Revision: 1435 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1435 Log: Add scope variable for the services Modified: wit/.eslintrc wit/activityChange.html wit/idle.html wit/js/components/ActionsBar.js wit/js/components/InputTag.js wit/js/components/LogsTable.js wit/js/components/Tags.js wit/js/components/Time.js wit/js/components/Timeline.js wit/js/main.js wit/js/services/TimerService.js wit/js/services/UserActivityService.js Modified: wit/.eslintrc =================================================================== --- wit/.eslintrc 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/.eslintrc 2015-05-22 14:01:07 UTC (rev 1435) @@ -4,7 +4,8 @@ }, "globals": { "console": false, - "React": false + "React": false, + "scope": false }, "env": { "browser": true, Modified: wit/activityChange.html =================================================================== --- wit/activityChange.html 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/activityChange.html 2015-05-22 14:01:07 UTC (rev 1435) @@ -12,7 +12,7 @@ <script> var gui = require('nw.gui'); var window = gui.Window.get(); - var timer = global.timer; + var timer = global.scope.timer; var user = global.user; var keepTiming = function() { Modified: wit/idle.html =================================================================== --- wit/idle.html 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/idle.html 2015-05-22 14:01:07 UTC (rev 1435) @@ -12,7 +12,7 @@ <script> var gui = require('nw.gui'); var window = gui.Window.get(); - var timer = global.timer; + var timer = global.scope.timer; var keepIdle = function() { timer.keepIdle(); Modified: wit/js/components/ActionsBar.js =================================================================== --- wit/js/components/ActionsBar.js 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/js/components/ActionsBar.js 2015-05-22 14:01:07 UTC (rev 1435) @@ -3,21 +3,21 @@ var ActionsBar = React.createClass({ onPlay: function() { - timer.start(); + scope.timer.start(); }, onStop: function() { - timer.stop(true); + scope.timer.stop(true); }, prevHistory: function() { - timer.stop(); - timer.prevHistory(); + scope.timer.stop(); + scope.timer.prevHistory(); }, nextHistory: function() { - timer.stop(); - timer.nextHistory(); + scope.timer.stop(); + scope.timer.nextHistory(); }, render: function() { Modified: wit/js/components/InputTag.js =================================================================== --- wit/js/components/InputTag.js 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/js/components/InputTag.js 2015-05-22 14:01:07 UTC (rev 1435) @@ -8,7 +8,7 @@ getTags: function() { var setState = self.setState; - timer.getLastTags().then(function(tags) { + scope.timer.getLastTags().then(function(tags) { setState({options: tags, value: ""}); }); }, @@ -20,8 +20,8 @@ if (e.keyCode === 13 && value !== "") { // On enter this.setState({options: this.state.options, value: ""}); - timer.stop(); - timer.addTag(value); + scope.timer.stop(); + scope.timer.addTag(value); } }, Modified: wit/js/components/LogsTable.js =================================================================== --- wit/js/components/LogsTable.js 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/js/components/LogsTable.js 2015-05-22 14:01:07 UTC (rev 1435) @@ -5,7 +5,7 @@ onDelete: function(e) { var logId = e.target.dataset.id; if (logId) { - timer.deleteLog(logId); + scope.timer.deleteLog(logId); var index = parseInt(e.target.dataset.index, 10); this.props.data.splice(index, 1); Modified: wit/js/components/Tags.js =================================================================== --- wit/js/components/Tags.js 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/js/components/Tags.js 2015-05-22 14:01:07 UTC (rev 1435) @@ -3,30 +3,30 @@ var Tags = React.createClass({ getInitialState: function() { - return timer; + return scope.timer; }, componentDidMount: function() { this.forceUpdateBound = this.forceUpdate.bind(this); - timer.subscribeTagsChanged(this.forceUpdateBound); + scope.timer.subscribeTagsChanged(this.forceUpdateBound); }, componentWillUnmount: function() { - timer.unsubscribeTagsChanged(this.forceUpdateBound); + scope.timer.unsubscribeTagsChanged(this.forceUpdateBound); }, onRemove: function(e) { var target = e.target; var index = target.dataset.index; - timer.stop(); - timer.removeTag(index); + scope.timer.stop(); + scope.timer.removeTag(index); }, render: function() { var onRemove = this.onRemove; - var tags = timer.getTags(); + var tags = scope.timer.getTags(); var rows = []; for (var i = 0; i < 5; i++) { Modified: wit/js/components/Time.js =================================================================== --- wit/js/components/Time.js 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/js/components/Time.js 2015-05-22 14:01:07 UTC (rev 1435) @@ -3,16 +3,16 @@ var Time = React.createClass({ getInitialState: function() { - return timer; + return scope.timer; }, componentDidMount: function() { this.forceUpdateBound = this.forceUpdate.bind(this); - timer.subscribeTimeChanged(this.forceUpdateBound); + scope.timer.subscribeTimeChanged(this.forceUpdateBound); }, componentWillUnmount: function() { - timer.unsubscribeTimeChanged(this.forceUpdateBound); + scope.timer.unsubscribeTimeChanged(this.forceUpdateBound); }, onEdit: function() { @@ -20,7 +20,7 @@ this.refs.editInput.getDOMNode().classList.toggle("hidden"); this.refs.timeValue.getDOMNode().classList.toggle("hidden"); - var time = timer.getTime() || "00:00:00"; + var time = scope.timer.getTime() || "00:00:00"; var editInputTime = this.refs.editInputTime.getDOMNode(); editInputTime.value = time; editInputTime.max = time; @@ -32,7 +32,7 @@ this.refs.timeValue.getDOMNode().classList.toggle("hidden"); var editInputTime = this.refs.editInputTime.getDOMNode(); - timer.editTime(editInputTime.value); + scope.timer.editTime(editInputTime.value); }, render: function() { Modified: wit/js/components/Timeline.js =================================================================== --- wit/js/components/Timeline.js 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/js/components/Timeline.js 2015-05-22 14:01:07 UTC (rev 1435) @@ -24,7 +24,7 @@ if (startDate && endDate) { var setState = this.setState.bind(this); - user.getSessions(startDate, endDate, true) + scope.user.getSessions(startDate, endDate, true) .then(function(sessions) { setState({ sessions: sessions Modified: wit/js/main.js =================================================================== --- wit/js/main.js 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/js/main.js 2015-05-22 14:01:07 UTC (rev 1435) @@ -11,11 +11,13 @@ global.navigator = window.navigator; global.localStorage = window.localStorage; +global.scope = window.scope = {}; + var timer = require("./js/services/TimerService.js"); -global.timer = timer; +scope.timer = timer; var user = require("./js/services/UserActivityService.js"); -global.user = user; +scope.user = user; var config = require("./js/services/ConfigurationService.js"); @@ -107,7 +109,7 @@ var current = gui.Window.get(); current.hide(); - user.suspendActivityDetection(); + scope.user.suspendActivityDetection(); var window = gui.Window.open(file, { position: "center", @@ -134,5 +136,5 @@ // Subscriptions to services -timer.subscribeIdle(openWindow.bind(null, "idle.html")); -user.subscribeActivityChange(openWindow.bind(null, "activityChange.html")); +scope.timer.subscribeIdle(openWindow.bind(null, "idle.html")); +scope.user.subscribeActivityChange(openWindow.bind(null, "activityChange.html")); Modified: wit/js/services/TimerService.js =================================================================== --- wit/js/services/TimerService.js 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/js/services/TimerService.js 2015-05-22 14:01:07 UTC (rev 1435) @@ -79,7 +79,7 @@ timeChange(); - user.resumeActivityDetection(); + scope.user.resumeActivityDetection(); }; exports.stop = function(force) { @@ -145,7 +145,7 @@ }; exports.keepIdle = function() { - user.resumeActivityDetection(); + scope.user.resumeActivityDetection(); idleTime = null; }; Modified: wit/js/services/UserActivityService.js =================================================================== --- wit/js/services/UserActivityService.js 2015-05-22 13:54:56 UTC (rev 1434) +++ wit/js/services/UserActivityService.js 2015-05-22 14:01:07 UTC (rev 1435) @@ -306,8 +306,8 @@ * If timer change occured while activity change detection is on going, * stop activity change detection process (means the user has handled it) */ -timer.subscribeTimeChanged(function() { - if (!timer.getTime()) { +scope.timer.subscribeTimeChanged(function() { + if (!scope.timer.getTime()) { clearTimeout(activityChangeTimer); } });
participants (1)
-
jruchaud@users.nuiton.org