First try at webcam support
This commit is contained in:
1 parent
a85ea69fb0
commit
e1d541a6e4
5 files changed
+119
-2
No files matched your search
@@ -93,3 +93,16 @@ table th.gcode_files_action, table td.gcode_files_action {
|
||||
#offline_overlay_wrapper .container {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#webcam_container {
|
||||
height: 440px;
|
||||
background-color: #000000;
|
||||
}
|
||||
|
||||
#webcam_placeholder {
|
||||
height: 440px;
|
||||
line-height: 440px;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
//~~ View models
|
||||
|
||||
function ConnectionViewModel() {
|
||||
var self = this;
|
||||
|
||||
@@ -436,6 +438,32 @@ function DataUpdater(connectionViewModel, printerStateViewModel, temperatureView
|
||||
}
|
||||
var dataUpdater = new DataUpdater(connectionViewModel, printerStateViewModel, temperatureViewModel, speedViewModel, terminalViewModel);
|
||||
|
||||
function WebcamViewModel() {
|
||||
var self = this;
|
||||
|
||||
self.webcamUpdateInterval = 5000;
|
||||
self.offlineUrl = "/static/img/webcam-offline.png";
|
||||
|
||||
self.url = ko.observable(undefined);
|
||||
self.enabled = ko.observable(undefined);
|
||||
|
||||
self.enabled.subscribe(function(newValue) {
|
||||
if (newValue) {
|
||||
self.requestData();
|
||||
} else {
|
||||
$("#webcam_image")
|
||||
}
|
||||
});
|
||||
|
||||
self.requestData = function() {
|
||||
if (!self.enabled())
|
||||
return;
|
||||
self.url(AJAX_BASEURL + "webcam/image?" + (new Date()).getTime());
|
||||
setTimeout(self.requestData, self.webcamUpdateInterval);
|
||||
}
|
||||
}
|
||||
var webcamViewModel = new WebcamViewModel();
|
||||
|
||||
$(function() {
|
||||
|
||||
//~~ Print job control
|
||||
@@ -575,6 +603,7 @@ $(function() {
|
||||
ko.applyBindings(printerStateViewModel, document.getElementById("jog"));
|
||||
ko.applyBindings(terminalViewModel, document.getElementById("term"));
|
||||
ko.applyBindings(speedViewModel, document.getElementById("speed"));
|
||||
ko.applyBindings(webcamViewModel, document.getElementById("webcam"));
|
||||
|
||||
//~~ startup commands
|
||||
|
||||
|
||||
Reference in new issue
Block a user