diff --git a/RaceLapTimer/RaceLapTimer/www/js/monitor.js b/RaceLapTimer/RaceLapTimer/www/js/monitor.js new file mode 100644 index 0000000..241c9b7 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/www/js/monitor.js @@ -0,0 +1,28 @@ +function ViewModel() { + "use strict"; + var self = this; + self.raceSessions = ko.observable(); + + $.get("/api/monitor", {}, self.raceSessions); + self.tmrHandle = setTimeout(function () { + self.getData(); + }, 2000); + + self.getData = function () { + $.get("/api/monitor", {}, self.raceSessions) + .done(function() { + console.log("done"); + }) + .always(function() { + self.tmrHandle = setTimeout(self.getData, 2000); + }); + }; +}; + +ViewModel.prototype.dispose = function () { + "use strict"; + window.clearInterval(self.tmrHandle); + console.log("disposed of timer"); +}; + +ko.applyBindings(new ViewModel()); \ No newline at end of file