2015-03-04 08:40:25 +00:00
|
|
|
define([
|
|
|
|
'jquery', 'knockout', 'text!./Screenshot.html', 'kojqui/spinner'
|
2015-03-20 11:02:12 +00:00
|
|
|
], function(jquery, ko, htmlString ) {
|
2015-03-04 08:40:25 +00:00
|
|
|
|
|
|
|
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());
|
|
|
|
setTimeout( function() { self.update(id); }, self.updateInterval()*1000);
|
|
|
|
};
|
2015-03-20 11:02:12 +00:00
|
|
|
|
2015-03-04 08:40:25 +00:00
|
|
|
self.update(++self.updateId);
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewModel.prototype.dispose = function() {
|
|
|
|
++self.updateId;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return component definition
|
|
|
|
return {
|
|
|
|
viewModel : ViewModel,
|
|
|
|
template : htmlString
|
|
|
|
};
|
|
|
|
});
|