diff --git a/webgui/topics/Simulator.js b/webgui/topics/Simulator.js index 9d2ae3559..685e3e569 100644 --- a/webgui/topics/Simulator.js +++ b/webgui/topics/Simulator.js @@ -1,6 +1,10 @@ define([ 'knockout', 'text!./Simulator.html' ], function(ko, htmlString) { + ko.components.register('Simulator/Screenshot', { + require : 'topics/Simulator/Screenshot' + }); + ko.components.register('Simulator/Properties', { require : 'topics/Simulator/Properties' }); @@ -21,7 +25,7 @@ define([ var self = this; self.topics = [ - 'Properties', 'Config', 'Reset', 'Exit' + 'Screenshot', 'Properties', 'Config', 'Reset', 'Exit' ]; self.selectedTopic = ko.observable(); diff --git a/webgui/topics/Simulator/Screenshot.html b/webgui/topics/Simulator/Screenshot.html new file mode 100644 index 000000000..17958a938 --- /dev/null +++ b/webgui/topics/Simulator/Screenshot.html @@ -0,0 +1,9 @@ +
+
+ Refresh image every + + seconds +
+ + +
\ No newline at end of file diff --git a/webgui/topics/Simulator/Screenshot.js b/webgui/topics/Simulator/Screenshot.js new file mode 100644 index 000000000..bc5345e11 --- /dev/null +++ b/webgui/topics/Simulator/Screenshot.js @@ -0,0 +1,38 @@ +define([ + 'jquery', 'knockout', 'text!./Screenshot.html', 'kojqui/spinner' +], function(jquery, ko, htmlString, fgcommand ) { + + function ViewModel(params) { + var self = this; + + self.imageUrl = ko.observable(""); + self.updateInterval = ko.observable(5); + self.spinUpdateInterval = function(evt, ui) { + $(evt.target).spinner("value",ui.value); + return true; + } + + self.updateId = 0; + + self.update = function( id ) { + if( id != self.updateId ) + return; + self.imageUrl("/screenshot?type=jpg&t=" + Date.now()); + console.log(self.updateInterval(), self.imageUrl()); + + setTimeout( function() { self.update(id); }, self.updateInterval()*1000); + }; + + self.update(++self.updateId); + } + + ViewModel.prototype.dispose = function() { + ++self.updateId; + } + + // Return component definition + return { + viewModel : ViewModel, + template : htmlString + }; +});