mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 09:17:56 +01:00
Remove inheritance logic, use FormPanel instead
This commit is contained in:
parent
1394a28c18
commit
05e49a54ff
@ -18,19 +18,21 @@ function FormPanel() {
|
|||||||
// ui elements
|
// ui elements
|
||||||
var _element;
|
var _element;
|
||||||
|
|
||||||
var _self;
|
var _self = this;
|
||||||
|
|
||||||
|
this.init = function(wifiboxURL,wifiboxCGIBinURL,panelElement) {
|
||||||
|
|
||||||
FormPanel.prototype.init = function(wifiboxURL,wifiboxCGIBinURL,panelElement) {
|
|
||||||
// make _self the scope of which init was called?
|
// make _self the scope of which init was called?
|
||||||
// needed to have the subclass instance access the same counter
|
// needed to have the subclass instance access the same counter
|
||||||
_self = this;
|
//_self = this;
|
||||||
//console.log("FormPanel:init");
|
//console.log(" _element: ",_element);
|
||||||
_element = panelElement;
|
_element = panelElement;
|
||||||
|
//console.log(" >_element: ",_element);
|
||||||
_configAPI.init(wifiboxURL,wifiboxCGIBinURL);
|
_configAPI.init(wifiboxURL,wifiboxCGIBinURL);
|
||||||
};
|
};
|
||||||
|
|
||||||
//this.readForm = function(form) {
|
//this.readForm = function(form) {
|
||||||
FormPanel.prototype.readForm = function(form) {
|
this.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");
|
||||||
@ -69,11 +71,13 @@ function FormPanel() {
|
|||||||
return settings;
|
return settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
FormPanel.prototype.fill = 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(" form: ",form);
|
//console.log(" form: ",form);
|
||||||
|
|
||||||
|
clearValidationErrors();
|
||||||
|
|
||||||
//fill form with loaded settings
|
//fill form with loaded settings
|
||||||
var selects = form.find("select");
|
var selects = form.find("select");
|
||||||
selects.each( function(index,element) {
|
selects.each( function(index,element) {
|
||||||
@ -102,7 +106,7 @@ function FormPanel() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
FormPanel.prototype.saveSettings = function(newSettings,complete) {
|
this.saveSettings = function(newSettings,complete) {
|
||||||
//console.log(" newSettings: ",newSettings);
|
//console.log(" newSettings: ",newSettings);
|
||||||
_configAPI.save(newSettings,function(data) {
|
_configAPI.save(newSettings,function(data) {
|
||||||
var validation = data.validation;
|
var validation = data.validation;
|
||||||
|
@ -6,9 +6,6 @@
|
|||||||
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// prototype inheritance
|
|
||||||
// http://robertnyman.com/2008/10/06/javascript-inheritance-how-and-why/
|
|
||||||
NetworkPanel.prototype = new FormPanel();
|
|
||||||
function NetworkPanel() {
|
function NetworkPanel() {
|
||||||
|
|
||||||
var NOT_CONNECTED = "not connected"; // used as first item in networks list
|
var NOT_CONNECTED = "not connected"; // used as first item in networks list
|
||||||
@ -22,6 +19,7 @@ function NetworkPanel() {
|
|||||||
var _networkMode = NetworkPanel.NETWORK_MODE.NEITHER;
|
var _networkMode = NetworkPanel.NETWORK_MODE.NEITHER;
|
||||||
var _networkModeChangedHandler;
|
var _networkModeChangedHandler;
|
||||||
|
|
||||||
|
var _form = new FormPanel();
|
||||||
var _api = new NetworkAPI();
|
var _api = new NetworkAPI();
|
||||||
var _networks = {};
|
var _networks = {};
|
||||||
var _currentNetwork; // the ssid of the network the box is on
|
var _currentNetwork; // the ssid of the network the box is on
|
||||||
@ -56,8 +54,8 @@ function NetworkPanel() {
|
|||||||
|
|
||||||
this.init = function(wifiboxURL,wifiboxCGIBinURL,panelElement) {
|
this.init = function(wifiboxURL,wifiboxCGIBinURL,panelElement) {
|
||||||
//console.log("NetworkPanel:init");
|
//console.log("NetworkPanel:init");
|
||||||
// super call:
|
|
||||||
_self.constructor.prototype.init.call(_self,wifiboxURL,wifiboxCGIBinURL,panelElement);
|
_form.init(wifiboxURL,wifiboxCGIBinURL,panelElement)
|
||||||
|
|
||||||
_api.init(wifiboxURL,wifiboxCGIBinURL);
|
_api.init(wifiboxURL,wifiboxCGIBinURL);
|
||||||
|
|
||||||
@ -302,7 +300,7 @@ function NetworkPanel() {
|
|||||||
//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) {
|
_form.saveSettings(_form.readForm(),function(validated) {
|
||||||
if(!validated) return;
|
if(!validated) return;
|
||||||
updateClientModeUI(NetworkAPI.STATUS.CONNECTING,"");
|
updateClientModeUI(NetworkAPI.STATUS.CONNECTING,"");
|
||||||
_api.associate(_selectedNetwork,_passwordField.val(),true);
|
_api.associate(_selectedNetwork,_passwordField.val(),true);
|
||||||
@ -317,7 +315,7 @@ function NetworkPanel() {
|
|||||||
this.createAP = function() {
|
this.createAP = function() {
|
||||||
//console.log("createAP");
|
//console.log("createAP");
|
||||||
// save network related settings and on complete, create access point
|
// save network related settings and on complete, create access point
|
||||||
_self.saveSettings(_self.readForm(),function(success) {
|
_form.saveSettings(_form.readForm(),function(success) {
|
||||||
if(!success) return;
|
if(!success) return;
|
||||||
updateAPModeUI(NetworkAPI.STATUS.CREATING,"");
|
updateAPModeUI(NetworkAPI.STATUS.CREATING,"");
|
||||||
_api.openAP();
|
_api.openAP();
|
||||||
|
@ -6,12 +6,10 @@
|
|||||||
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// prototype inheritance
|
|
||||||
// http://robertnyman.com/2008/10/06/javascript-inheritance-how-and-why/
|
|
||||||
PrinterPanel.prototype = new FormPanel();
|
|
||||||
function PrinterPanel() {
|
function PrinterPanel() {
|
||||||
|
|
||||||
this.printerType;
|
this.printerType;
|
||||||
|
var _form = new FormPanel();
|
||||||
|
|
||||||
// ui elements
|
// ui elements
|
||||||
var _element;
|
var _element;
|
||||||
@ -22,9 +20,7 @@ function PrinterPanel() {
|
|||||||
|
|
||||||
this.init = function(wifiboxURL,wifiboxCGIBinURL,panelElement) {
|
this.init = function(wifiboxURL,wifiboxCGIBinURL,panelElement) {
|
||||||
|
|
||||||
// super call:
|
_form.init(wifiboxURL,wifiboxCGIBinURL,panelElement)
|
||||||
_self.constructor.prototype.init.call(_self,wifiboxURL,wifiboxCGIBinURL,panelElement);
|
|
||||||
|
|
||||||
_element = panelElement;
|
_element = panelElement;
|
||||||
|
|
||||||
_printerSelector = _element.find("#printerType");
|
_printerSelector = _element.find("#printerType");
|
||||||
@ -32,7 +28,7 @@ function PrinterPanel() {
|
|||||||
|
|
||||||
// we use readForm to get all the settings we need to
|
// we use readForm to get all the settings we need to
|
||||||
// reload after changing printer type
|
// reload after changing printer type
|
||||||
_printerSettings = _self.readForm();
|
_printerSettings = _form.readForm();
|
||||||
|
|
||||||
var gcodePanel = _element.find("#gcodePanel");
|
var gcodePanel = _element.find("#gcodePanel");
|
||||||
gcodePanel.coolfieldset({collapsed:true});
|
gcodePanel.coolfieldset({collapsed:true});
|
||||||
@ -42,10 +38,10 @@ function PrinterPanel() {
|
|||||||
var settings = {};
|
var settings = {};
|
||||||
settings[_printerSelector.attr("name")] = _self.printerType;
|
settings[_printerSelector.attr("name")] = _self.printerType;
|
||||||
|
|
||||||
_self.saveSettings(settings,function(validated) {
|
_form.saveSettings(settings,function(validated) {
|
||||||
if(!validated) return;
|
if(!validated) return;
|
||||||
_self.loadSettings(_printerSettings,function(settings) {
|
_form.loadSettings(_printerSettings,function(settings) {
|
||||||
_self.fill(settings);
|
_form.fillForm(settings);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user