0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-22 09:17:56 +01:00

Leave warning while sending

This commit is contained in:
peteruithoven 2013-10-18 16:38:20 +02:00
parent 5ceabf41ba
commit 46d2ae4bfc

View File

@ -19,6 +19,8 @@ function Printer() {
Printer.PRINTING_STATE = "printing"; Printer.PRINTING_STATE = "printing";
Printer.STOPPING_STATE = "stopping"; // when you stop (abort) a print it prints the endcode Printer.STOPPING_STATE = "stopping"; // when you stop (abort) a print it prints the endcode
Printer.ON_BEFORE_UNLOAD_MESSAGE = "You're doodle is still being send to the printer, leaving will result in a incomplete 3D print";
this.temperature = 0; this.temperature = 0;
this.targetTemperature = 0; this.targetTemperature = 0;
this.currentLine = 0; this.currentLine = 0;
@ -95,6 +97,8 @@ function Printer() {
console.log("Printer:print"); console.log("Printer:print");
console.log(" gcode total # of lines: " + gcode.length); console.log(" gcode total # of lines: " + gcode.length);
self.addLeaveWarning();
/*for (i = 0; i < gcode.length; i++) { /*for (i = 0; i < gcode.length; i++) {
gcode[i] += " (" + i + ")"; gcode[i] += " (" + i + ")";
}*/ }*/
@ -152,6 +156,7 @@ function Printer() {
console.log("Printer:sendPrintPart:gcode sending completed"); console.log("Printer:sendPrintPart:gcode sending completed");
this.gcode = []; this.gcode = [];
btnStop.css("display","block"); // hack btnStop.css("display","block"); // hack
self.removeLeaveWarning();
//self.targetTemperature = settings["printer.temperature"]; // slight hack //self.targetTemperature = settings["printer.temperature"]; // slight hack
} else { } else {
// only if the state hasn't bin changed (by for example pressing stop) we send more gcode // only if the state hasn't bin changed (by for example pressing stop) we send more gcode
@ -302,4 +307,13 @@ function Printer() {
this.stopStatusCheckInterval(); this.stopStatusCheckInterval();
} }
this.removeLeaveWarning = function() {
window.onbeforeunload = null;
}
this.addLeaveWarning = function() {
window.onbeforeunload = function() {
return Printer.ON_BEFORE_UNLOAD_MESSAGE;
};
}
} }