create monitor.js page for Monitor.cshtml page
This commit is contained in:
parent
3d3a552664
commit
c985b35bb5
28
RaceLapTimer/RaceLapTimer/www/js/monitor.js
Normal file
28
RaceLapTimer/RaceLapTimer/www/js/monitor.js
Normal file
@ -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());
|
||||||
Loading…
Reference in New Issue
Block a user