diff --git a/webgui/main.js b/webgui/main.js
index 6cb053539..1d85cef79 100644
--- a/webgui/main.js
+++ b/webgui/main.js
@@ -52,7 +52,6 @@ require([
// send subscriptions when the socket is open
var c = self.openCache;
delete self.openCache;
- console.log(c);
c.forEach(function(e) {
self.addListener(e.prop, e.koObservable);
});
@@ -77,7 +76,6 @@ require([
self.addListener = function(alias, koObservable) {
if (self.openCache) {
// socket not yet open, just cache the request
- console.log("caching listener request");
self.openCache.push({
"prop" : alias,
"koObservable" : koObservable
@@ -97,7 +95,6 @@ require([
self.listeners[path] = koObservable;
- console.log("subscribing to " + alias);
self.ws.send(JSON.stringify({
command : 'addListener',
node : path
@@ -332,6 +329,10 @@ require([
require : 'widgets/efis'
});
+ ko.components.register('stopwatch', {
+ require : 'widgets/Stopwatch'
+ });
+
ko.applyBindings(new PhiViewModel());
});
diff --git a/webgui/topics/Tools.js b/webgui/topics/Tools.js
index 5dee409eb..001accc1f 100644
--- a/webgui/topics/Tools.js
+++ b/webgui/topics/Tools.js
@@ -2,6 +2,10 @@ define([
'knockout', 'text!./Tools.html'
], function(ko, htmlString) {
+ ko.components.register('Tools/Stopwatch', {
+ require : 'topics/Tools/Stopwatch'
+ });
+
function ViewModel(params) {
var self = this;
diff --git a/webgui/topics/Tools/Stopwatch.html b/webgui/topics/Tools/Stopwatch.html
new file mode 100644
index 000000000..99985aba6
--- /dev/null
+++ b/webgui/topics/Tools/Stopwatch.html
@@ -0,0 +1,4 @@
+
+
diff --git a/webgui/topics/Tools/Stopwatch.js b/webgui/topics/Tools/Stopwatch.js
new file mode 100644
index 000000000..055dbdf6e
--- /dev/null
+++ b/webgui/topics/Tools/Stopwatch.js
@@ -0,0 +1,23 @@
+define([
+ 'jquery', 'knockout', 'text!./Stopwatch.html', 'kojqui/button'
+], function(jquery, ko, htmlString) {
+
+ function ViewModel(params) {
+ var self = this;
+
+ self.watches = ko.observableArray([]);
+
+ self.addWatch = function() {
+ self.watches.push(self.watches().length);
+ }
+ }
+
+ ViewModel.prototype.dispose = function() {
+ }
+
+ // Return component definition
+ return {
+ viewModel : ViewModel,
+ template : htmlString
+ };
+});
diff --git a/webgui/widgets/Stopwatch.html b/webgui/widgets/Stopwatch.html
new file mode 100644
index 000000000..09c64cd4f
--- /dev/null
+++ b/webgui/widgets/Stopwatch.html
@@ -0,0 +1,14 @@
+
+
\ No newline at end of file
diff --git a/webgui/widgets/Stopwatch.js b/webgui/widgets/Stopwatch.js
new file mode 100644
index 000000000..3c314018d
--- /dev/null
+++ b/webgui/widgets/Stopwatch.js
@@ -0,0 +1,100 @@
+define([
+ 'jquery', 'knockout', 'text!./Stopwatch.html', 'kojqui/button'
+], function(jquery, ko, htmlString) {
+
+ function ViewModel(params) {
+ var self = this;
+
+ self.MODE = {
+ STOPPED : 0,
+ PAUSED : 1,
+ RUNNING : 2,
+ };
+
+ self.mode = ko.observable(self.MODE.STOPPED);
+ self.elapsedTime = ko.observable(0);
+ self.elapsedTimeSeconds = ko.pureComputed(function() {
+ return (self.elapsedTime() / 1000).toFixed(0);
+ });
+
+ self.startLabel = ko.pureComputed(function() {
+ return self.mode() == self.MODE.RUNNING ? "Pause" : "Start";
+ });
+
+ self.startIcons = ko.pureComputed(function() {
+ return self.mode() == self.MODE.RUNNING ? {
+ primary : 'ui-icon-pause'
+ } : {
+ primary : 'ui-icon-play'
+ };
+ });
+
+ function twoDigits(n) {
+ if (n >= 10)
+ return n.toString();
+ else
+ return '0' + n.toString();
+ }
+
+ self.hoursDisplay = ko.pureComputed(function() {
+ return twoDigits(Math.floor(self.elapsedTimeSeconds() / 3600));
+ });
+
+ self.minutesDisplay = ko.pureComputed(function() {
+ return twoDigits(Math.floor(self.elapsedTimeSeconds() / 60) % 60);
+ });
+
+ self.secondsDisplay = ko.pureComputed(function() {
+ return twoDigits(self.elapsedTimeSeconds() % 60);
+ });
+
+ self.startTime = 0;
+ self.runTime = 0;
+ self.cumulatedTime = 50;
+
+ self.startStopPause = function() {
+ switch (self.mode()) {
+ case self.MODE.STOPPED:
+ case self.MODE.PAUSED:
+ self.mode(self.MODE.RUNNING);
+ break;
+ case self.MODE.RUNNING:
+ self.mode(self.MODE.PAUSED);
+ self.cumulatedTime = self.elapsedTime();
+ break;
+
+ }
+
+ if (self.mode() == self.MODE.RUNNING) {
+ self.startTime = new Date();
+ self.update();
+ }
+ }
+
+ self.update = function() {
+ if (self.mode() != self.MODE.RUNNING)
+ return;
+
+ var now = new Date();
+ self.elapsedTime(self.cumulatedTime + (now - self.startTime));
+ setTimeout(function() {
+ self.update();
+ }, 100);
+ }
+
+ self.clear = function() {
+ self.cumulatedTime = 0;
+ self.startTime = new Date();
+ self.elapsedTime(0);
+ }
+ }
+
+ ViewModel.prototype.dispose = function() {
+ }
+
+ // Return component definition
+ return {
+ viewModel : ViewModel,
+ template : htmlString
+ };
+});