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

Reenabled commented parts and small fixes

This commit is contained in:
peteruithoven 2014-02-04 14:18:50 +01:00
parent 59c26a6713
commit 219bd190c0
3 changed files with 57 additions and 65 deletions

View File

@ -22,20 +22,13 @@ function FormPanel() {
// needed to have the subclass instance access the same counter // needed to have the subclass instance access the same counter
_self = this; _self = this;
_element = panelElement; _element = panelElement;
//_configAPI.init(wifiboxURL,wifiboxCGIBinURL); _configAPI.init(wifiboxURL,wifiboxCGIBinURL);
console.log(" calling _self.readForm from FormPanel:init");
_self.readForm();
//console.log(" calling this.readForm from FormPanel:init");
//this.readForm();
//console.log(" calling _self2.readForm from FormPanel:init");
//_self2.readForm();
}; };
//this.readForm = function(form) { //this.readForm = function(form) {
FormPanel.prototype.readForm = function(form) { FormPanel.prototype.readForm = function(form) {
console.log("FormPanel:readForm"); console.log("FormPanel:readForm");
/*if(!form) form = _element; // if no form specified, read whole panel form if(!form) form = _element; // if no form specified, read whole panel form
//console.log("FormPanel"); //console.log("FormPanel");
var settings = {}; var settings = {};
// Read all selects // Read all selects
@ -70,10 +63,10 @@ function FormPanel() {
settings[elem.attr('name')] = elem.val(); settings[elem.attr('name')] = elem.val();
}); });
console.log(" settings: ",settings); console.log(" settings: ",settings);
return settings;*/ return settings;
}; };
/*this.fillForm = function(settings,form) { this.fillForm = function(settings,form) {
console.log("FormPanel:fillForm"); console.log("FormPanel:fillForm");
if(!form) form = _element; // if no form specified, fill whole panel form if(!form) form = _element; // if no form specified, fill whole panel form
console.log(" settings: ",settings); console.log(" settings: ",settings);
@ -109,7 +102,6 @@ function FormPanel() {
this.saveSettings = function(newSettings,complete) { this.saveSettings = function(newSettings,complete) {
console.log("FormPanel:saveSettings"); console.log("FormPanel:saveSettings");
console.log(" newSettings: ",newSettings); console.log(" newSettings: ",newSettings);
console.log(" form: ",form);
_configAPI.save(newSettings,function(data) { _configAPI.save(newSettings,function(data) {
var validation = data.validation; var validation = data.validation;
console.log(" validation: ",validation); console.log(" validation: ",validation);
@ -139,5 +131,5 @@ function FormPanel() {
function clearValidationErrors() { function clearValidationErrors() {
_element.find(".errorMsg").remove(); _element.find(".errorMsg").remove();
_element.find(".error").removeClass("error"); _element.find(".error").removeClass("error");
};*/ };
} }

View File

@ -12,7 +12,7 @@ NetworkPanel.prototype = new FormPanel();
function NetworkPanel() { function NetworkPanel() {
// network client mode states // network client mode states
/*var CLIENT_MODE_STATE = { var CLIENT_MODE_STATE = {
NOT_CONNECTED: "not connected", // also used as first item in networks list NOT_CONNECTED: "not connected", // also used as first item in networks list
CONNECTED: "connected", CONNECTED: "connected",
CONNECTING: "connecting", CONNECTING: "connecting",
@ -63,7 +63,7 @@ function NetworkPanel() {
var _passwordField; var _passwordField;
var _passwordLabel; var _passwordLabel;
var _clientStateDisplay; var _clientStateDisplay;
var _apModeStateDisplay;*/ var _apModeStateDisplay;
var _self = this; var _self = this;
@ -72,10 +72,7 @@ function NetworkPanel() {
// super call: // super call:
_self.constructor.prototype.init.call(_self,wifiboxURL,wifiboxCGIBinURL,panelElement); _self.constructor.prototype.init.call(_self,wifiboxURL,wifiboxCGIBinURL,panelElement);
console.log(" calling readForm from NetworkPanel:init"); _api.init(wifiboxURL,wifiboxCGIBinURL);
_self.readForm();
/*_api.init(wifiboxURL,wifiboxCGIBinURL);
_element = panelElement; _element = panelElement;
_apRadioButton = _element.find("#ap"); _apRadioButton = _element.find("#ap");
@ -96,12 +93,12 @@ function NetworkPanel() {
_btnRefresh.on('touchstart mousedown',onRefreshClick); _btnRefresh.on('touchstart mousedown',onRefreshClick);
_btnConnect.on('touchstart mousedown',_self.connectToNetwork); _btnConnect.on('touchstart mousedown',_self.connectToNetwork);
_btnCreate.on('touchstart mousedown',_self.createAP); _btnCreate.on('touchstart mousedown',_self.createAP);
_networkSelector.change(networkSelectorChanged);*/ _networkSelector.change(networkSelectorChanged);
} }
/* /*
* Handlers * Handlers
*/ */
/*
function showAPSettings() { function showAPSettings() {
_apFieldSet.show(); _apFieldSet.show();
_clientFieldSet.hide(); _clientFieldSet.hide();
@ -124,7 +121,7 @@ function NetworkPanel() {
this.update = function() { this.update = function() {
console.log("NetworkPanel:update"); console.log("NetworkPanel:update");
_self.refreshNetworks(); _self.refreshNetworks();
_self.retrieveStatus(false); _self.retrieveNetworkStatus(false);
} }
this.refreshNetworks = function(completeHandler) { this.refreshNetworks = function(completeHandler) {
console.log("NetworkPanel:refreshNetworks"); console.log("NetworkPanel:refreshNetworks");
@ -154,8 +151,8 @@ function NetworkPanel() {
}); });
}; };
this.retrieveStatus = function(connecting) { this.retrieveNetworkStatus = function(connecting) {
//console.log("NetworkPanel:retrieveStatus"); //console.log("NetworkPanel:retrieveNetworkStatus");
_api.status(function(data) { _api.status(function(data) {
if(typeof data.status === 'string') { if(typeof data.status === 'string') {
data.status = parseInt(data.status); data.status = parseInt(data.status);
@ -172,7 +169,7 @@ function NetworkPanel() {
case NetworkAPI.STATUS.CONNECTED: case NetworkAPI.STATUS.CONNECTED:
setNetworkMode(NETWORK_MODE.CLIENT); setNetworkMode(NETWORK_MODE.CLIENT);
if(data.status == SettingsWindow.API_CONNECTED) { if(data.status == NetworkAPI.STATUS.CONNECTED) {
_networkSelector.val(data.ssid); _networkSelector.val(data.ssid);
_currentNetwork = data.ssid; _currentNetwork = data.ssid;
@ -190,7 +187,7 @@ function NetworkPanel() {
_self.selectNetwork(CLIENT_MODE_STATE.NOT_CONNECTED); _self.selectNetwork(CLIENT_MODE_STATE.NOT_CONNECTED);
_networkSelector.val(CLIENT_MODE_STATE.NOT_CONNECTED); _networkSelector.val(CLIENT_MODE_STATE.NOT_CONNECTED);
if(data.ssid && data.status == SettingsWindow.API_CREATED) { if(data.ssid && data.status == NetworkAPI.STATUS.CREATED) {
_currentAP = data.ssid; _currentAP = data.ssid;
} }
break; break;
@ -230,18 +227,18 @@ function NetworkPanel() {
case NetworkAPI.STATUS.CONNECTING: case NetworkAPI.STATUS.CONNECTING:
case NetworkAPI.STATUS.CREATING: case NetworkAPI.STATUS.CREATING:
clearTimeout(_retryRetrieveStatusDelay); clearTimeout(_retryRetrieveStatusDelay);
_retryRetrieveStatusDelay = setTimeout(function() { _self.retrieveStatus(connecting); },_retryRetrieveStatusDelayTime); // retry after delay _retryRetrieveStatusDelay = setTimeout(function() { _self.retrieveNetworkStatus(connecting); },_retryRetrieveStatusDelayTime); // retry after delay
break; break;
} }
} }
}, function() { }, function() {
console.log("NetworkPanel:retrieveStatus failed"); console.log("NetworkPanel:retrieveStatus failed");
clearTimeout(_retryRetrieveStatusDelay); clearTimeout(_retryRetrieveStatusDelay);
_retryRetrieveStatusDelay = setTimeout(function() { _self.retrieveStatus(connecting); }, _retryRetrieveStatusDelayTime); // retry after delay _retryRetrieveStatusDelay = setTimeout(function() { _self.retrieveNetworkStatus(connecting); }, _retryRetrieveStatusDelayTime); // retry after delay
}); });
}; };
function setNetworkMode(mode) { function setNetworkMode(mode) {
//console.log("NetworkPanel:setNetworkMode: ",mode); console.log("NetworkPanel:setNetworkMode: ",_networkMode,">",mode);
if(mode == _networkMode) return; if(mode == _networkMode) return;
switch(mode) { switch(mode) {
case NETWORK_MODE.NEITHER: case NETWORK_MODE.NEITHER:
@ -265,9 +262,8 @@ function NetworkPanel() {
} }
this.selectNetwork = function(ssid) { this.selectNetwork = function(ssid) {
console.log("select network: ",ssid); console.log("NetworkPanel:selectNetwork: ",ssid);
if(ssid == "") return; if(ssid == "") return;
//console.log(" checked");
_selectedNetwork = ssid; _selectedNetwork = ssid;
if(_networks == undefined || ssid == CLIENT_MODE_STATE.NOT_CONNECTED) { if(_networks == undefined || ssid == CLIENT_MODE_STATE.NOT_CONNECTED) {
hideWiFiPassword(); hideWiFiPassword();
@ -291,49 +287,58 @@ function NetworkPanel() {
}; };
function setClientModeState(state,statusMessage) { function setClientModeState(state,statusMessage) {
console.log("NetworkPanel:setClientModeState ",state,statusMessage);
//console.log(" CLIENT_MODE_STATE.CONNECTING: ",CLIENT_MODE_STATE.CONNECTING);
var msg = ""; var msg = "";
switch(state) { switch(state) {
case SettingsWindow.NOT_CONNECTED: case CLIENT_MODE_STATE.NOT_CONNECTED:
_btnConnect.removeAttr("disabled"); //console.log("CLIENT_MODE_STATE.NOT_CONNECTED");
msg = "Not connected"; _btnConnect.removeAttr("disabled");
break; msg = "Not connected";
case SettingsWindow.CONNECTED: break;
_btnConnect.removeAttr("disabled"); case CLIENT_MODE_STATE.CONNECTED:
//console.log("CLIENT_MODE_STATE.CONNECTED");
msg = "Connected to: <b>"+_currentNetwork+"</b>."; _btnConnect.removeAttr("disabled");
if(_currentLocalIP != undefined && _currentLocalIP != "") {
var a = "<a href='http://"+_currentLocalIP+"' target='_black'>"+_currentLocalIP+"</a>"; msg = "Connected to: <b>"+_currentNetwork+"</b>.";
msg += " (IP: "+a+")"; if(_currentLocalIP != undefined && _currentLocalIP != "") {
} var a = "<a href='http://"+_currentLocalIP+"' target='_black'>"+_currentLocalIP+"</a>";
break; msg += " (IP: "+a+")";
case SettingsWindow.CONNECTING: }
_btnConnect.attr("disabled", true); break;
msg = "Connecting... Reconnect by connecting your device to <b>"+_selectedNetwork+"</b> and going to <a href='http://connect.doodle3d.com'>connect.doodle3d.com</a>"; case CLIENT_MODE_STATE.CONNECTING:
break; //console.log("CLIENT_MODE_STATE.CONNECTING");
case SettingsWindow.CONNECTING_FAILED: _btnConnect.attr("disabled", true);
_btnConnect.removeAttr("disabled"); msg = "Connecting... Reconnect by connecting your device to <b>"+_selectedNetwork+"</b> and going to <a href='http://connect.doodle3d.com'>connect.doodle3d.com</a>";
msg = statusMessage; break;
break; case CLIENT_MODE_STATE.CONNECTING_FAILED:
//console.log("CLIENT_MODE_STATE.CONNECTING_FAILED");
_btnConnect.removeAttr("disabled");
msg = statusMessage;
break;
} }
console.log(" msg: ",msg);
_clientStateDisplay.html(msg); _clientStateDisplay.html(msg);
_clientModeState = state; _clientModeState = state;
}; };
function setAPModeState(state,statusMessage) { function setAPModeState(state,statusMessage) {
//console.log("NetworkPanel:setAPModeState ",state,statusMessage);
var msg = ""; var msg = "";
switch(state) { switch(state) {
case SettingsWindow.NO_AP: case AP_MODE_STATE.NO_AP:
_btnCreate.removeAttr("disabled"); _btnCreate.removeAttr("disabled");
msg = "Not currently a access point"; msg = "Not currently a access point";
break; break;
case SettingsWindow.AP: case AP_MODE_STATE.AP:
_btnCreate.removeAttr("disabled"); _btnCreate.removeAttr("disabled");
msg = "Is access point: <b>"+_currentAP+"</b>"; msg = "Is access point: <b>"+_currentAP+"</b>";
break; break;
case SettingsWindow.CREATING_AP: case AP_MODE_STATE.CREATING_AP:
_btnCreate.attr("disabled", true); _btnCreate.attr("disabled", true);
msg = "Creating access point... Reconnect by connecting your device to <b>"+settings.substituted_ssid+"</b> and going to <a href='http://draw.doodle3d.com'>draw.doodle3d.com</a>"; msg = "Creating access point... Reconnect by connecting your device to <b>"+settings.substituted_ssid+"</b> and going to <a href='http://draw.doodle3d.com'>draw.doodle3d.com</a>";
break; break;
} }
//console.log(" msg: ",msg);
_apModeStateDisplay.html(msg); _apModeStateDisplay.html(msg);
_apModeState = state; _apModeState = state;
}; };
@ -341,7 +346,6 @@ function NetworkPanel() {
this.connectToNetwork = function() { this.connectToNetwork = function() {
console.log("NetworkPanel:connectToNetwork"); console.log("NetworkPanel:connectToNetwork");
if(_selectedNetwork == undefined) return; if(_selectedNetwork == undefined) return;
// save network related settings and on complete, connect to network // save network related settings and on complete, connect to network
_self.saveSettings(_self.readForm(),function(validated) { _self.saveSettings(_self.readForm(),function(validated) {
if(!validated) return; if(!validated) return;

View File

@ -45,11 +45,6 @@ function SettingsWindow() {
this.init = function(wifiboxURL,wifiboxCGIBinURL) { this.init = function(wifiboxURL,wifiboxCGIBinURL) {
console.log("EARLY initialize network panel");
//var _networkPanel = new NetworkPanel();
_networkPanel.init(wifiboxURL,wifiboxCGIBinURL);
this.wifiboxURL = wifiboxURL; this.wifiboxURL = wifiboxURL;
this.wifiboxCGIBinURL = wifiboxCGIBinURL; this.wifiboxCGIBinURL = wifiboxCGIBinURL;
@ -63,7 +58,7 @@ function SettingsWindow() {
$("#popupSettings").bind("onPopupCancel", function() { settingsPopup.close(); } ); $("#popupSettings").bind("onPopupCancel", function() { settingsPopup.close(); } );
$("#popupSettings").bind("onPopupCommit", self.submitwindow); $("#popupSettings").bind("onPopupCommit", self.submitwindow);
//this.window.find("#settingsContainer").load("settings.html", function() { this.window.find("#settingsContainer").load("settings.html", function() {
console.log("Settings:finished loading settings.html, now loading settings..."); console.log("Settings:finished loading settings.html, now loading settings...");
self.form = self.window.find("form"); self.form = self.window.find("form");
@ -75,7 +70,7 @@ function SettingsWindow() {
timeout: self.timeoutTime, timeout: self.timeoutTime,
success: function(response) { success: function(response) {
console.log("Settings:printer/listall response: ",response.data.printers); console.log("Settings:printer/listall response: ",response.data.printers);
console.log(" this: ",this); //console.log(" this: ",this);
// network panel // network panel
console.log("initialize network panel"); console.log("initialize network panel");
var $networkPanelElement = self.form.find("#networkPanel"); var $networkPanelElement = self.form.find("#networkPanel");
@ -106,7 +101,7 @@ function SettingsWindow() {
}).fail(function() { }).fail(function() {
console.log("FATAL ERROR: Settings:printer/listall failed"); console.log("FATAL ERROR: Settings:printer/listall failed");
}); });
//}); //this.window.find }); //this.window.find
}; //this.init }; //this.init
@ -360,6 +355,7 @@ function SettingsWindow() {
* FROM DOODLE3D.INI * FROM DOODLE3D.INI
* *
*/ */
//TODO: find all references to these variables, replace them and finally remove these. //TODO: find all references to these variables, replace them and finally remove these.
var objectHeight = 20; var objectHeight = 20;
var layerHeight = .2; var layerHeight = .2;
@ -406,4 +402,4 @@ var windowcenter = true;
var windowfullscreen = false; var windowfullscreen = false;
var autoWarmUpCommand = "M104 S230"; var autoWarmUpCommand = "M104 S230";
//var checkTemperatureInterval = 3; //var checkTemperatureInterval = 3;
var autoWarmUpDelay = 3; var autoWarmUpDelay = 3;