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

Disable settings button if printer is busy or no control access.

This commit is contained in:
Wouter R 2013-10-23 18:42:47 +02:00
parent cc2bcf962c
commit 98e0418eb8
3 changed files with 101 additions and 64 deletions

View File

@ -26,6 +26,11 @@ var settings = {
} }
//wrapper to prevent scoping issues in showSettings()
function openSettingsWindow() {
settingsWindow.showSettings();
}
function SettingsWindow() { function SettingsWindow() {
this.wifiboxURL; this.wifiboxURL;
this.wifiboxCGIBinURL this.wifiboxCGIBinURL

View File

@ -160,11 +160,8 @@ function initButtonBehavior() {
loadSettings(); loadSettings();
}); });
}*/ }*/
btnSettings.bind('touchstart mousedown',function () { enableButton(btnSettings, openSettingsWindow);
//e.preventDefault();
//console.log("btnSettings clicked");
settingsWindow.showSettings();
});
// btnSettings.on('touchend', function(e) { // btnSettings.on('touchend', function(e) {
// e.preventDefault(); // e.preventDefault();
// console.log("btnSettings touchend"); // console.log("btnSettings touchend");
@ -350,9 +347,9 @@ function setState(newState,newHasControl) {
// thermometer // thermometer
switch(newState) { switch(newState) {
case Printer.IDLE_STATE: case Printer.IDLE_STATE: /* fall-through */
case Printer.BUFFERING_STATE: case Printer.BUFFERING_STATE: /* fall-through */
case Printer.PRINTING_STATE: case Printer.PRINTING_STATE: /* fall-through */
case Printer.STOPPING_STATE: case Printer.STOPPING_STATE:
thermometer.show(); thermometer.show();
break; break;
@ -371,6 +368,22 @@ function setState(newState,newHasControl) {
break; break;
} }
/* settings button */
switch(newState) {
case Printer.IDLE_STATE:
enableButton(btnSettings, openSettingsWindow);
break;
case Printer.WIFIBOX_DISCONNECTED_STATE: /* fall-through */
case Printer.BUFFERING_STATE: /* fall-through */
case Printer.PRINTING_STATE: /* fall-through */
case Printer.STOPPING_STATE:
disableButton(btnSettings);
break;
default:
enableButton(btnSettings, openSettingsWindow);
break;
}
if(newState == Printer.WIFIBOX_DISCONNECTED_STATE) { if(newState == Printer.WIFIBOX_DISCONNECTED_STATE) {
message.set("Lost connection to WiFi box",Message.ERROR); message.set("Lost connection to WiFi box",Message.ERROR);
} else if(prevState == Printer.WIFIBOX_DISCONNECTED_STATE) { } else if(prevState == Printer.WIFIBOX_DISCONNECTED_STATE) {
@ -380,6 +393,12 @@ function setState(newState,newHasControl) {
} else if(prevState == Printer.DISCONNECTED_STATE && newState == Printer.IDLE_STATE || } else if(prevState == Printer.DISCONNECTED_STATE && newState == Printer.IDLE_STATE ||
prevState == Printer.UNKNOWN_STATE && newState == Printer.IDLE_STATE) { prevState == Printer.UNKNOWN_STATE && newState == Printer.IDLE_STATE) {
message.set("Printer connected",Message.INFO,true); message.set("Printer connected",Message.INFO,true);
} else if(prevState == Printer.PRINTING_STATE && newState == Printer.STOPPING_STATE) {
console.log("stopmsg show");
message.set("Printer stopping",Message.INFO,false);
} else if(prevState == Printer.STOPPING_STATE && newState == Printer.IDLE_STATE) {
console.log("stopmsg hide");
message.hide();
} }
state = newState; state = newState;

View File

@ -107,6 +107,19 @@ $(function() {
} }
}); });
function enableButton(elem, handler) {
//var elem = $('#'+domId);
elem.removeClass("disabled");
elem.unbind('touchstart mousedown');
elem.bind('touchstart mousedown', handler);
}
function disableButton(elem) {
//var elem = $('#'+domId);
elem.addClass("disabled");
elem.unbind('touchstart mousedown');
}
function showOrHideThermo() { function showOrHideThermo() {
console.log("f:showOrHideThermo()"); console.log("f:showOrHideThermo()");
if (showOrHide) { if (showOrHide) {