mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 17:27:57 +01:00
Formatting of SettingsWindow.js.
This commit is contained in:
parent
5eb129d2a2
commit
74b9149175
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//these settings are defined in the firmware (conf_defaults.lua) and will be initialized in loadSettings()
|
//these settings are defined in the firmware (conf_defaults.lua) and will be initialized in loadSettings()
|
||||||
var settings = { }
|
var settings = {};
|
||||||
var settingsPopup;
|
var settingsPopup;
|
||||||
//wrapper to prevent scoping issues in showSettings()
|
//wrapper to prevent scoping issues in showSettings()
|
||||||
function openSettingsWindow() {
|
function openSettingsWindow() {
|
||||||
@ -18,7 +18,7 @@ function openSettingsWindow() {
|
|||||||
|
|
||||||
function SettingsWindow() {
|
function SettingsWindow() {
|
||||||
this.wifiboxURL;
|
this.wifiboxURL;
|
||||||
this.wifiboxCGIBinURL
|
this.wifiboxCGIBinURL;
|
||||||
this.window;
|
this.window;
|
||||||
this.btnOK;
|
this.btnOK;
|
||||||
this.form;
|
this.form;
|
||||||
@ -29,7 +29,7 @@ function SettingsWindow() {
|
|||||||
|
|
||||||
this.retryLoadSettingsDelay; // retry setTimout instance
|
this.retryLoadSettingsDelay; // retry setTimout instance
|
||||||
this.retrySaveSettingsDelay; // retry setTimout instance
|
this.retrySaveSettingsDelay; // retry setTimout instance
|
||||||
this.retryResetSettingsDelay // retry setTimout instance
|
this.retryResetSettingsDelay; // retry setTimout instance
|
||||||
this.retryRetrieveNetworkStatusDelay;// retry setTimout instance
|
this.retryRetrieveNetworkStatusDelay;// retry setTimout instance
|
||||||
|
|
||||||
this.apFieldSet;
|
this.apFieldSet;
|
||||||
@ -45,37 +45,37 @@ function SettingsWindow() {
|
|||||||
|
|
||||||
// after switching wifi network or creating a access point we delay the status retrieval
|
// after switching wifi network or creating a access point we delay the status retrieval
|
||||||
// because the webserver needs time to switch
|
// because the webserver needs time to switch
|
||||||
this.retrieveNetworkStatusDelay; // setTimout delay
|
this.retrieveNetworkStatusDelay; // setTimout delay
|
||||||
this.retrieveNetworkStatusDelayTime = 1000;
|
this.retrieveNetworkStatusDelayTime = 1000;
|
||||||
|
|
||||||
this.restoredStateHideDelayTime = 3000;
|
this.restoredStateHideDelayTime = 3000;
|
||||||
this.restoredStateHideDelay // setTimout instance
|
this.restoredStateHideDelay; // setTimout instance
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
SettingsWindow.SETTINGS_LOADED = "settingsLoaded";
|
SettingsWindow.SETTINGS_LOADED = "settingsLoaded";
|
||||||
|
|
||||||
// network client mode states
|
// network client mode states
|
||||||
SettingsWindow.NOT_CONNECTED = "not connected"; // also used as first item in networks list
|
SettingsWindow.NOT_CONNECTED = "not connected"; // also used as first item in networks list
|
||||||
SettingsWindow.CONNECTED = "connected";
|
SettingsWindow.CONNECTED = "connected";
|
||||||
SettingsWindow.CONNECTING = "connecting";
|
SettingsWindow.CONNECTING = "connecting";
|
||||||
SettingsWindow.CONNECTING_FAILED = "connecting failed"
|
SettingsWindow.CONNECTING_FAILED = "connecting failed";
|
||||||
|
|
||||||
// network access point mode states
|
// network access point mode states
|
||||||
SettingsWindow.NO_AP = "no ap";
|
SettingsWindow.NO_AP = "no ap";
|
||||||
SettingsWindow.AP = "ap";
|
SettingsWindow.AP = "ap";
|
||||||
SettingsWindow.CREATING_AP = "creating ap";
|
SettingsWindow.CREATING_AP = "creating ap";
|
||||||
|
|
||||||
SettingsWindow.API_CONNECTING_FAILED = -1
|
SettingsWindow.API_CONNECTING_FAILED = -1;
|
||||||
SettingsWindow.API_NOT_CONNECTED = 0
|
SettingsWindow.API_NOT_CONNECTED = 0;
|
||||||
SettingsWindow.API_CONNECTING = 1
|
SettingsWindow.API_CONNECTING = 1;
|
||||||
SettingsWindow.API_CONNECTED = 2
|
SettingsWindow.API_CONNECTED = 2;
|
||||||
SettingsWindow.API_CREATING = 3
|
SettingsWindow.API_CREATING = 3;
|
||||||
SettingsWindow.API_CREATED = 4
|
SettingsWindow.API_CREATED = 4;
|
||||||
|
|
||||||
// network mode
|
// network mode
|
||||||
SettingsWindow.NETWORK_MODE_NEITHER = "neither";
|
SettingsWindow.NETWORK_MODE_NEITHER = "neither";
|
||||||
SettingsWindow.NETWORK_MODE_CLIENT = "clientMode";
|
SettingsWindow.NETWORK_MODE_CLIENT = "clientMode";
|
||||||
SettingsWindow.NETWORK_MODE_ACCESS_POINT = "accessPointMode";
|
SettingsWindow.NETWORK_MODE_ACCESS_POINT = "accessPointMode";
|
||||||
|
|
||||||
this.networkMode = SettingsWindow.NETWORK_MODE_NEITHER;
|
this.networkMode = SettingsWindow.NETWORK_MODE_NEITHER;
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ function SettingsWindow() {
|
|||||||
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");
|
||||||
self.form.submit(function (e) { self.submitwindow(e) });
|
self.form.submit(function (e) { self.submitwindow(e); });
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: self.wifiboxURL + "/printer/listall",
|
url: self.wifiboxURL + "/printer/listall",
|
||||||
@ -108,22 +108,22 @@ function SettingsWindow() {
|
|||||||
console.log("Settings:printer/listall response: ",response.data.printers);
|
console.log("Settings:printer/listall response: ",response.data.printers);
|
||||||
|
|
||||||
$.each(response.data.printers, function(key, value) {
|
$.each(response.data.printers, function(key, value) {
|
||||||
// console.log(key,value);
|
// console.log(key,value);
|
||||||
$('#printerType').append($('<option>').text(value).attr('value', key));
|
$('#printerType').append($('<option>').text(value).attr('value', key));
|
||||||
});
|
});
|
||||||
|
|
||||||
self.loadSettings();
|
self.loadSettings();
|
||||||
|
|
||||||
var btnAP = self.form.find("label[for='ap']");
|
var btnAP = self.form.find("label[for='ap']");
|
||||||
var btnClient = self.form.find("label[for='client']");
|
var btnClient = self.form.find("label[for='client']");
|
||||||
var btnRefresh = self.form.find("#refreshNetworks");
|
var btnRefresh = self.form.find("#refreshNetworks");
|
||||||
var btnConnect = self.form.find("#connectToNetwork");
|
var btnConnect = self.form.find("#connectToNetwork");
|
||||||
var btnCreate = self.form.find("#createAP");
|
var btnCreate = self.form.find("#createAP");
|
||||||
var networkSelector = self.form.find("#network");
|
var networkSelector = self.form.find("#network");
|
||||||
self.apFieldSet = self.form.find("#apSettings");
|
self.apFieldSet = self.form.find("#apSettings");
|
||||||
self.clientFieldSet = self.form.find("#clientSettings");
|
self.clientFieldSet = self.form.find("#clientSettings");
|
||||||
self.btnRestoreSettings = self.form.find("#restoreSettings");
|
self.btnRestoreSettings = self.form.find("#restoreSettings");
|
||||||
self.restoreStateField = self.form.find("#restoreState");
|
self.restoreStateField = self.form.find("#restoreState");
|
||||||
|
|
||||||
btnAP.on('touchstart mousedown',self.showAPSettings);
|
btnAP.on('touchstart mousedown',self.showAPSettings);
|
||||||
btnClient.on('touchstart mousedown',self.showClientSettings);
|
btnClient.on('touchstart mousedown',self.showClientSettings);
|
||||||
@ -147,130 +147,134 @@ function SettingsWindow() {
|
|||||||
});
|
});
|
||||||
}); //this.window.find
|
}); //this.window.find
|
||||||
|
|
||||||
} //this.init
|
}; //this.init
|
||||||
|
|
||||||
this.openSettings = function() {
|
this.openSettings = function() {
|
||||||
self.loadSettings(function() { // reload settings
|
self.loadSettings(function() { // reload settings
|
||||||
settingsPopup.open();
|
settingsPopup.open();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
this.closeSettings = function(complete) {
|
this.closeSettings = function(complete) {
|
||||||
settingsPopup.close(complete);
|
settingsPopup.close(complete);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.submitwindow = function(e) {
|
this.submitwindow = function(e) {
|
||||||
disableButton(self.btnOK,self.submitwindow);
|
disableButton(self.btnOK,self.submitwindow);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
self.saveSettings(self.readForm(),function(success){
|
self.saveSettings(self.readForm(),function(success){
|
||||||
if(success) {
|
if(success) {
|
||||||
self.closeSettings(function() {
|
self.closeSettings(function() {
|
||||||
enableButton(self.btnOK,self.submitwindow);
|
enableButton(self.btnOK,self.submitwindow);
|
||||||
});
|
});
|
||||||
self.signin();
|
self.signin();
|
||||||
} else {
|
} else {
|
||||||
enableButton(self.btnOK,self.submitwindow);
|
enableButton(self.btnOK,self.submitwindow);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
clearTimeout(self.retryRetrieveNetworkStatusDelay);
|
clearTimeout(self.retryRetrieveNetworkStatusDelay);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.loadSettings = function(complete) {
|
this.loadSettings = function(complete) {
|
||||||
if (!communicateWithWifibox) {
|
if (!communicateWithWifibox) {
|
||||||
console.log(" communicateWithWifibox is false: settings aren't being loaded from wifibox...")
|
console.log(" communicateWithWifibox is false: settings aren't being loaded from wifibox...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("Settings:loadSettings() >> getting new data...");
|
console.log("Settings:loadSettings() >> getting new data...");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.wifiboxURL + "/config/all",
|
url: this.wifiboxURL + "/config/all",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: this.timeoutTime,
|
timeout: this.timeoutTime,
|
||||||
success: function(response){
|
success: function(response){
|
||||||
console.log("Settings:loadSettings response: ",response);
|
console.log("Settings:loadSettings response: ",response);
|
||||||
settings = response.data;
|
settings = response.data;
|
||||||
console.log(" settings: ",settings);
|
console.log(" settings: ",settings);
|
||||||
self.fillForm(settings);
|
self.fillForm(settings);
|
||||||
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
|
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
|
||||||
if(complete) complete();
|
if(complete) complete();
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log("Settings:loadSettings: failed");
|
console.log("Settings:loadSettings: failed");
|
||||||
clearTimeout(self.retryLoadSettingsDelay);
|
clearTimeout(self.retryLoadSettingsDelay);
|
||||||
self.retryLoadSettingsDelay = setTimeout(function() { self.loadSettings() },self.retryDelay); // retry after delay
|
self.retryLoadSettingsDelay = setTimeout(function() { self.loadSettings(); },self.retryDelay); // retry after delay
|
||||||
});
|
});
|
||||||
|
|
||||||
this.refreshNetworks();
|
this.refreshNetworks();
|
||||||
this.retrieveNetworkStatus(false);
|
this.retrieveNetworkStatus(false);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.fillForm = function(settings,form) {
|
this.fillForm = function(settings,form) {
|
||||||
if(!form) form = this.form; // if no form specified, fill whole form
|
if(!form) form = this.form; // if no form specified, fill whole form
|
||||||
|
|
||||||
//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) {
|
||||||
var element = $(element);
|
var elem = $(element);
|
||||||
element.val(settings[element.attr('name')]);
|
elem.val(settings[elem.attr('name')]);
|
||||||
});
|
});
|
||||||
var inputs = form.find("input");
|
var inputs = form.find("input");
|
||||||
inputs.each( function(index,element) {
|
inputs.each( function(index,element) {
|
||||||
var element = $(element);
|
var elem = $(element);
|
||||||
//console.log("printer setting input: ",index,element.attr("type"),element.attr('name')); //,element);
|
//console.log("printer setting input: ",index,element.attr("type"),element.attr('name')); //,element);
|
||||||
switch(element.attr("type")) {
|
switch(elem.attr("type")) {
|
||||||
case "text":
|
case "text":
|
||||||
case "number":
|
case "number":
|
||||||
element.val(settings[element.attr('name')]);
|
elem.val(settings[elem.attr('name')]);
|
||||||
break;
|
break;
|
||||||
case "checkbox":
|
case "checkbox":
|
||||||
element.prop('checked', settings[element.attr('name')]);
|
elem.prop('checked', settings[elem.attr('name')]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var textareas = form.find("textarea");
|
var textareas = form.find("textarea");
|
||||||
textareas.each( function(index,element) {
|
textareas.each( function(index,element) {
|
||||||
var element = $(element);
|
var elem = $(element);
|
||||||
var value = settings[element.attr('name')];
|
var value = settings[elem.attr('name')];
|
||||||
element.val(value);
|
elem.val(value);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
this.saveSettings = function(newSettings,complete) {
|
this.saveSettings = function(newSettings,complete) {
|
||||||
settings = newSettings; // store new settings in global settings
|
settings = newSettings; // store new settings in global settings
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: self.wifiboxCGIBinURL + "/config",
|
url: self.wifiboxCGIBinURL + "/config",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: newSettings,
|
data: newSettings,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: self.saveSettingsTimeoutTime,
|
timeout: self.saveSettingsTimeoutTime,
|
||||||
success: function(response){
|
success: function(response){
|
||||||
console.log("Settings:saveSettings response: ",response);
|
console.log("Settings:saveSettings response: ",response);
|
||||||
if(response.status == "error") {
|
if(response.status == "error") {
|
||||||
clearTimeout(self.retrySaveSettingsDelay);
|
clearTimeout(self.retrySaveSettingsDelay);
|
||||||
self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings(settings,complete) },self.retryDelay); // retry after delay
|
self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings(settings,complete); },self.retryDelay); // retry after delay
|
||||||
} else {
|
} else {
|
||||||
var data = response.data;
|
var data = response.data;
|
||||||
var validation = data.validation;
|
var validation = data.validation;
|
||||||
self.clearValidationErrors();
|
self.clearValidationErrors();
|
||||||
var validated = true;
|
var validated = true;
|
||||||
$.each(validation, function(key, val) {
|
$.each(validation, function(key, val) {
|
||||||
if (val != "ok") {
|
if (val != "ok") {
|
||||||
console.log("ERROR: setting '" + key + "' not successfully set. Message: " + val);
|
console.log("ERROR: setting '" + key + "' not successfully set. Message: " + val);
|
||||||
self.displayValidationError(key,val);
|
self.displayValidationError(key,val);
|
||||||
validated = false;
|
validated = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
settings.substituted_ssid = data.substituted_ssid;
|
settings.substituted_ssid = data.substituted_ssid;
|
||||||
if(complete) complete(validated);
|
if(complete) complete(validated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log("Settings:saveSettings: failed");
|
console.log("Settings:saveSettings: failed");
|
||||||
clearTimeout(self.retrySaveSettingsDelay);
|
clearTimeout(self.retrySaveSettingsDelay);
|
||||||
self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings(settings,complete) },self.retryDelay); // retry after delay
|
self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings(settings,complete); },self.retryDelay); // retry after delay
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
this.resetSettings = function() {
|
this.resetSettings = function() {
|
||||||
console.log("resetSettings");
|
console.log("resetSettings");
|
||||||
//$("#restoreSettings").addClass("disabled");
|
//$("#restoreSettings").addClass("disabled");
|
||||||
@ -283,18 +287,18 @@ function SettingsWindow() {
|
|||||||
//console.log(" self.wifiboxURL: ",self.wifiboxURL);
|
//console.log(" self.wifiboxURL: ",self.wifiboxURL);
|
||||||
|
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: self.wifiboxCGIBinURL + "/config/resetall",
|
url: self.wifiboxCGIBinURL + "/config/resetall",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: this.timeoutTime,
|
timeout: this.timeoutTime,
|
||||||
success: function(response){
|
success: function(response){
|
||||||
console.log("Settings:resetSettings response: ",response);
|
console.log("Settings:resetSettings response: ",response);
|
||||||
if(response.status == "error") {
|
if(response.status == "error") {
|
||||||
clearTimeout(self.retryResetSettingsDelay);
|
clearTimeout(self.retryResetSettingsDelay);
|
||||||
self.retryResetSettingsDelay = setTimeout(function() { self.resetSettings() },self.retryDelay); // retry after delay
|
self.retryResetSettingsDelay = setTimeout(function() { self.resetSettings(); },self.retryDelay); // retry after delay
|
||||||
} else {
|
} else {
|
||||||
settings = response.data;
|
settings = response.data;
|
||||||
console.log(" settings: ",settings);
|
console.log(" settings: ",settings);
|
||||||
self.fillForm(settings);
|
self.fillForm(settings);
|
||||||
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
|
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
|
||||||
@ -304,65 +308,68 @@ function SettingsWindow() {
|
|||||||
// auto hide status
|
// auto hide status
|
||||||
clearTimeout(self.restoredStateHideDelay);
|
clearTimeout(self.restoredStateHideDelay);
|
||||||
self.restoredStateHideDelay = setTimeout(function() { self.setRestoreState(""); },self.restoredStateHideDelayTime);
|
self.restoredStateHideDelay = setTimeout(function() { self.setRestoreState(""); },self.restoredStateHideDelayTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log("Settings:resetSettings: failed");
|
console.log("Settings:resetSettings: failed");
|
||||||
clearTimeout(self.retryResetSettingsDelay);
|
clearTimeout(self.retryResetSettingsDelay);
|
||||||
self.retryResetSettingsDelay = setTimeout(function() { self.resetSettings() },self.retryDelay); // retry after delay
|
self.retryResetSettingsDelay = setTimeout(function() { self.resetSettings(); },self.retryDelay); // retry after delay
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
this.setRestoreState = function(text) {
|
this.setRestoreState = function(text) {
|
||||||
self.restoreStateField.html(text);
|
self.restoreStateField.html(text);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.displayValidationError = function(key,msg) {
|
this.displayValidationError = function(key,msg) {
|
||||||
var formElement = self.form.find("[name|='"+key+"']");
|
var formElement = self.form.find("[name|='"+key+"']");
|
||||||
formElement.addClass("error");
|
formElement.addClass("error");
|
||||||
var errorMsg = "<p class='errorMsg'>"+msg+"</p>"
|
var errorMsg = "<p class='errorMsg'>"+msg+"</p>";
|
||||||
formElement.after(errorMsg);
|
formElement.after(errorMsg);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.clearValidationErrors = function() {
|
this.clearValidationErrors = function() {
|
||||||
self.form.find(".errorMsg").remove();
|
self.form.find(".errorMsg").remove();
|
||||||
self.form.find(".error").removeClass("error");
|
self.form.find(".error").removeClass("error");
|
||||||
}
|
};
|
||||||
|
|
||||||
this.readForm = function() {
|
this.readForm = function() {
|
||||||
//console.log("SettingsWindow:readForm");
|
//console.log("SettingsWindow:readForm");
|
||||||
var settings = {};
|
var settings = {};
|
||||||
var selects = self.form.find("select");
|
var selects = self.form.find("select");
|
||||||
selects.each( function(index,element) {
|
selects.each( function(index,element) {
|
||||||
var element = $(element);
|
var elem = $(element);
|
||||||
var fieldName = element.attr('name');
|
//var fieldName = elem.attr('name');
|
||||||
if(element.attr('name') != "") {
|
if(elem.attr('name') != "") {
|
||||||
settings[element.attr('name')] = element.val();
|
settings[elem.attr('name')] = elem.val();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var inputs = self.form.find("input");
|
var inputs = self.form.find("input");
|
||||||
inputs.each( function(index,element) {
|
inputs.each( function(index,element) {
|
||||||
var element = $(element);
|
var elem = $(element);
|
||||||
if(element.attr('name') != "") {
|
if(elem.attr('name') != "") {
|
||||||
switch(element.attr("type")) {
|
switch(elem.attr("type")) {
|
||||||
case "text":
|
case "text":
|
||||||
case "number":
|
case "number":
|
||||||
settings[element.attr('name')] = element.val();
|
settings[elem.attr('name')] = elem.val();
|
||||||
break;
|
break;
|
||||||
case "checkbox":
|
case "checkbox":
|
||||||
settings[element.attr('name')] = element.prop('checked')
|
settings[elem.attr('name')] = elem.prop('checked');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var textareas = self.form.find("textarea");
|
var textareas = self.form.find("textarea");
|
||||||
textareas.each( function(index,element) {
|
textareas.each( function(index,element) {
|
||||||
var element = $(element);
|
var elem = $(element);
|
||||||
settings[element.attr('name')] = element.val();
|
settings[elem.attr('name')] = elem.val();
|
||||||
});
|
});
|
||||||
//console.log(settings);
|
//console.log(settings);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.signin = function() {
|
this.signin = function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -376,11 +383,11 @@ function SettingsWindow() {
|
|||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log("Settings:signin: failed");
|
console.log("Settings:signin: failed");
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
this.downloadlogs = function() {
|
this.downloadlogs = function() {
|
||||||
window.location.href = self.wifiboxURL + "/info/logfiles"
|
window.location.href = self.wifiboxURL + "/info/logfiles";
|
||||||
}
|
};
|
||||||
|
|
||||||
this.downloadGcode = function() {
|
this.downloadGcode = function() {
|
||||||
var gcode = generate_gcode();
|
var gcode = generate_gcode();
|
||||||
@ -388,7 +395,7 @@ function SettingsWindow() {
|
|||||||
var blob = new Blob([gcode.join("\n")], {type: "text/plain;charset=utf-8"});
|
var blob = new Blob([gcode.join("\n")], {type: "text/plain;charset=utf-8"});
|
||||||
saveAs(blob, "doodle3d.gcode");
|
saveAs(blob, "doodle3d.gcode");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
this.downloadSvg = function() {
|
this.downloadSvg = function() {
|
||||||
var svg = saveToSvg();
|
var svg = saveToSvg();
|
||||||
@ -396,7 +403,7 @@ function SettingsWindow() {
|
|||||||
var blob = new Blob([svg], {type: "text/plain;charset=utf-8"});
|
var blob = new Blob([svg], {type: "text/plain;charset=utf-8"});
|
||||||
saveAs(blob, "doodle3d.svg");
|
saveAs(blob, "doodle3d.svg");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Networks ui
|
* Networks ui
|
||||||
@ -404,262 +411,268 @@ function SettingsWindow() {
|
|||||||
this.showAPSettings = function() {
|
this.showAPSettings = function() {
|
||||||
self.apFieldSet.show();
|
self.apFieldSet.show();
|
||||||
self.clientFieldSet.hide();
|
self.clientFieldSet.hide();
|
||||||
}
|
};
|
||||||
|
|
||||||
this.showClientSettings = function() {
|
this.showClientSettings = function() {
|
||||||
self.clientFieldSet.show();
|
self.clientFieldSet.show();
|
||||||
self.apFieldSet.hide();
|
self.apFieldSet.hide();
|
||||||
}
|
};
|
||||||
|
|
||||||
this.refreshNetworks = function() {
|
this.refreshNetworks = function() {
|
||||||
console.log("Settings:refreshNetworks");
|
console.log("Settings:refreshNetworks");
|
||||||
|
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: self.wifiboxURL + "/network/scan",
|
url: self.wifiboxURL + "/network/scan",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: self.timeoutTime,
|
timeout: self.timeoutTime,
|
||||||
success: function(response){
|
success: function(response){
|
||||||
console.log("Settings:refreshNetworks response: ",response);
|
console.log("Settings:refreshNetworks response: ",response);
|
||||||
if(response.status == "error") {
|
if(response.status == "error") {
|
||||||
//clearTimeout(self.retrySaveSettingsDelay);
|
//clearTimeout(self.retrySaveSettingsDelay);
|
||||||
//self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings() },self.retryDelay); // retry after delay
|
//self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings() },self.retryDelay); // retry after delay
|
||||||
} else {
|
} else {
|
||||||
var networks = response.data.networks
|
var networks = response.data.networks;
|
||||||
self.networks = {};
|
self.networks = {};
|
||||||
var foundCurrentNetwork = false;
|
var foundCurrentNetwork = false;
|
||||||
var networkSelector = self.form.find("#network");
|
var networkSelector = self.form.find("#network");
|
||||||
networkSelector.empty();
|
networkSelector.empty();
|
||||||
networkSelector.append(
|
networkSelector.append(
|
||||||
$("<option></option>").val(SettingsWindow.NOT_CONNECTED).html("not connected")
|
$("<option></option>").val(SettingsWindow.NOT_CONNECTED).html("not connected")
|
||||||
);
|
);
|
||||||
$.each(networks, function(index,element) {
|
$.each(networks, function(index,element) {
|
||||||
if(element.ssid == self.currentNetwork) {
|
if(element.ssid == self.currentNetwork) {
|
||||||
foundCurrentNetwork = true;
|
foundCurrentNetwork = true;
|
||||||
}
|
}
|
||||||
networkSelector.append(
|
networkSelector.append(
|
||||||
$("<option></option>").val(element.ssid).html(element.ssid)
|
$("<option></option>").val(element.ssid).html(element.ssid)
|
||||||
);
|
);
|
||||||
self.networks[element.ssid] = element;
|
self.networks[element.ssid] = element;
|
||||||
});
|
});
|
||||||
if(foundCurrentNetwork) {
|
if(foundCurrentNetwork) {
|
||||||
networkSelector.val(self.currentNetwork);
|
networkSelector.val(self.currentNetwork);
|
||||||
self.selectNetwork(self.currentNetwork);
|
self.selectNetwork(self.currentNetwork);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
this.retrieveNetworkStatus = function(connecting) {
|
this.retrieveNetworkStatus = function(connecting) {
|
||||||
//console.log("Settings:retrieveNetworkStatus");
|
//console.log("Settings:retrieveNetworkStatus");
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: self.wifiboxURL + "/network/status",
|
url: self.wifiboxURL + "/network/status",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: self.timeoutTime,
|
timeout: self.timeoutTime,
|
||||||
success: function(response){
|
success: function(response){
|
||||||
console.log("Settings:retrieveNetworkStatus response: ",response);
|
console.log("Settings:retrieveNetworkStatus response: ",response);
|
||||||
if(response.status == "error") {
|
if(response.status == "error") {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var data = response.data;
|
var data = response.data;
|
||||||
|
|
||||||
if(typeof data.status === 'string') {
|
if(typeof data.status === 'string') {
|
||||||
data.status = parseInt(data.status);
|
data.status = parseInt(data.status);
|
||||||
}
|
|
||||||
//console.log(" data.status: ",data.status,data.statusMessage);
|
|
||||||
|
|
||||||
// Determine which network settings to show
|
|
||||||
switch(data.status) {
|
|
||||||
case SettingsWindow.API_NOT_CONNECTED:
|
|
||||||
//console.log(" not connected & not a access point");
|
|
||||||
self.apFieldSet.show();
|
|
||||||
self.clientFieldSet.show();
|
|
||||||
|
|
||||||
self.networkMode = SettingsWindow.NETWORK_MODE_NEITHER;
|
|
||||||
break;
|
|
||||||
case SettingsWindow.API_CONNECTING_FAILED:
|
|
||||||
case SettingsWindow.API_CONNECTING:
|
|
||||||
case SettingsWindow.API_CONNECTED:
|
|
||||||
//console.log(" client mode");
|
|
||||||
self.form.find("#client").prop('checked',true);
|
|
||||||
|
|
||||||
self.apFieldSet.hide();
|
|
||||||
self.clientFieldSet.show();
|
|
||||||
|
|
||||||
if(data.status == SettingsWindow.API_CONNECTED) {
|
|
||||||
var networkSelector = self.form.find("#network");
|
|
||||||
networkSelector.val(data.ssid);
|
|
||||||
|
|
||||||
self.currentNetwork = data.ssid;
|
|
||||||
self.currentLocalIP = data.localip;
|
|
||||||
self.selectNetwork(data.ssid);
|
|
||||||
} else {
|
|
||||||
self.currentLocalIP = ""
|
|
||||||
}
|
|
||||||
self.networkMode = SettingsWindow.NETWORK_MODE_CLIENT;
|
|
||||||
break;
|
|
||||||
case SettingsWindow.API_CREATING:
|
|
||||||
case SettingsWindow.API_CREATED:
|
|
||||||
//console.log(" access point mode");
|
|
||||||
self.form.find("#ap").prop('checked',true);
|
|
||||||
|
|
||||||
self.apFieldSet.show();
|
|
||||||
self.clientFieldSet.hide();
|
|
||||||
|
|
||||||
self.currentNetwork = undefined;
|
|
||||||
self.selectNetwork(SettingsWindow.NOT_CONNECTED);
|
|
||||||
var networkSelector = self.form.find("#network");
|
|
||||||
networkSelector.val(SettingsWindow.NOT_CONNECTED);
|
|
||||||
|
|
||||||
if(data.ssid && data.status == SettingsWindow.API_CREATED) {
|
|
||||||
self.currentAP = data.ssid;
|
|
||||||
}
|
|
||||||
self.networkMode = SettingsWindow.NETWORK_MODE_ACCESS_POINT;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
self.updatePanel.setNetworkMode(self.networkMode);
|
//console.log(" data.status: ",data.status,data.statusMessage);
|
||||||
|
|
||||||
// update status message
|
// Determine which network settings to show
|
||||||
switch(data.status) {
|
switch(data.status) {
|
||||||
case SettingsWindow.API_CONNECTING_FAILED:
|
case SettingsWindow.API_NOT_CONNECTED:
|
||||||
self.setClientModeState(SettingsWindow.CONNECTING_FAILED,data.statusMessage);
|
//console.log(" not connected & not a access point");
|
||||||
self.setAPModeState(SettingsWindow.NO_AP,"");
|
self.apFieldSet.show();
|
||||||
break;
|
self.clientFieldSet.show();
|
||||||
case SettingsWindow.API_NOT_CONNECTED:
|
|
||||||
self.setClientModeState(SettingsWindow.NOT_CONNECTED,"");
|
|
||||||
self.setAPModeState(SettingsWindow.NO_AP,"");
|
|
||||||
break;
|
|
||||||
case SettingsWindow.API_CONNECTING:
|
|
||||||
self.setClientModeState(SettingsWindow.CONNECTING,"");
|
|
||||||
self.setAPModeState(SettingsWindow.NO_AP,"");
|
|
||||||
break;
|
|
||||||
case SettingsWindow.API_CONNECTED:
|
|
||||||
self.setClientModeState(SettingsWindow.CONNECTED,"");
|
|
||||||
self.setAPModeState(SettingsWindow.NO_AP,"");
|
|
||||||
break;
|
|
||||||
case SettingsWindow.API_CREATING:
|
|
||||||
self.setClientModeState(SettingsWindow.NOT_CONNECTED,"");
|
|
||||||
self.setAPModeState(SettingsWindow.CREATING_AP,"");
|
|
||||||
break;
|
|
||||||
case SettingsWindow.API_CREATED:
|
|
||||||
self.setClientModeState(SettingsWindow.NOT_CONNECTED,"");
|
|
||||||
self.setAPModeState(SettingsWindow.AP,"");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keep checking for updates?
|
self.networkMode = SettingsWindow.NETWORK_MODE_NEITHER;
|
||||||
if(connecting) {
|
break;
|
||||||
switch(data.status) {
|
case SettingsWindow.API_CONNECTING_FAILED:
|
||||||
case SettingsWindow.API_CONNECTING:
|
case SettingsWindow.API_CONNECTING:
|
||||||
case SettingsWindow.API_CREATING:
|
case SettingsWindow.API_CONNECTED:
|
||||||
clearTimeout(self.retryRetrieveNetworkStatusDelay);
|
//console.log(" client mode");
|
||||||
self.retryRetrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(connecting) },self.retryRetrieveNetworkStatusDelayTime); // retry after delay
|
self.form.find("#client").prop('checked',true);
|
||||||
break;
|
|
||||||
|
self.apFieldSet.hide();
|
||||||
|
self.clientFieldSet.show();
|
||||||
|
|
||||||
|
if(data.status == SettingsWindow.API_CONNECTED) {
|
||||||
|
var networkSelector = self.form.find("#network");
|
||||||
|
networkSelector.val(data.ssid);
|
||||||
|
|
||||||
|
self.currentNetwork = data.ssid;
|
||||||
|
self.currentLocalIP = data.localip;
|
||||||
|
self.selectNetwork(data.ssid);
|
||||||
|
} else {
|
||||||
|
self.currentLocalIP = "";
|
||||||
}
|
}
|
||||||
}
|
self.networkMode = SettingsWindow.NETWORK_MODE_CLIENT;
|
||||||
}
|
break;
|
||||||
|
case SettingsWindow.API_CREATING:
|
||||||
|
case SettingsWindow.API_CREATED:
|
||||||
|
//console.log(" access point mode");
|
||||||
|
self.form.find("#ap").prop('checked',true);
|
||||||
|
|
||||||
|
self.apFieldSet.show();
|
||||||
|
self.clientFieldSet.hide();
|
||||||
|
|
||||||
|
self.currentNetwork = undefined;
|
||||||
|
self.selectNetwork(SettingsWindow.NOT_CONNECTED);
|
||||||
|
var networkSelector = self.form.find("#network");
|
||||||
|
networkSelector.val(SettingsWindow.NOT_CONNECTED);
|
||||||
|
|
||||||
|
if(data.ssid && data.status == SettingsWindow.API_CREATED) {
|
||||||
|
self.currentAP = data.ssid;
|
||||||
|
}
|
||||||
|
self.networkMode = SettingsWindow.NETWORK_MODE_ACCESS_POINT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
self.updatePanel.setNetworkMode(self.networkMode);
|
||||||
|
|
||||||
|
// update status message
|
||||||
|
switch(data.status) {
|
||||||
|
case SettingsWindow.API_CONNECTING_FAILED:
|
||||||
|
self.setClientModeState(SettingsWindow.CONNECTING_FAILED,data.statusMessage);
|
||||||
|
self.setAPModeState(SettingsWindow.NO_AP,"");
|
||||||
|
break;
|
||||||
|
case SettingsWindow.API_NOT_CONNECTED:
|
||||||
|
self.setClientModeState(SettingsWindow.NOT_CONNECTED,"");
|
||||||
|
self.setAPModeState(SettingsWindow.NO_AP,"");
|
||||||
|
break;
|
||||||
|
case SettingsWindow.API_CONNECTING:
|
||||||
|
self.setClientModeState(SettingsWindow.CONNECTING,"");
|
||||||
|
self.setAPModeState(SettingsWindow.NO_AP,"");
|
||||||
|
break;
|
||||||
|
case SettingsWindow.API_CONNECTED:
|
||||||
|
self.setClientModeState(SettingsWindow.CONNECTED,"");
|
||||||
|
self.setAPModeState(SettingsWindow.NO_AP,"");
|
||||||
|
break;
|
||||||
|
case SettingsWindow.API_CREATING:
|
||||||
|
self.setClientModeState(SettingsWindow.NOT_CONNECTED,"");
|
||||||
|
self.setAPModeState(SettingsWindow.CREATING_AP,"");
|
||||||
|
break;
|
||||||
|
case SettingsWindow.API_CREATED:
|
||||||
|
self.setClientModeState(SettingsWindow.NOT_CONNECTED,"");
|
||||||
|
self.setAPModeState(SettingsWindow.AP,"");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep checking for updates?
|
||||||
|
if(connecting) {
|
||||||
|
switch(data.status) {
|
||||||
|
case SettingsWindow.API_CONNECTING:
|
||||||
|
case SettingsWindow.API_CREATING:
|
||||||
|
clearTimeout(self.retryRetrieveNetworkStatusDelay);
|
||||||
|
self.retryRetrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(connecting); },self.retryRetrieveNetworkStatusDelayTime); // retry after delay
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log("Settings:retrieveNetworkStatus: failed");
|
console.log("Settings:retrieveNetworkStatus: failed");
|
||||||
clearTimeout(self.retryRetrieveNetworkStatusDelay);
|
clearTimeout(self.retryRetrieveNetworkStatusDelay);
|
||||||
self.retryRetrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(connecting) },self.retryDelay); // retry after delay
|
self.retryRetrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(connecting); },self.retryDelay); // retry after delay
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
this.networkSelectorChanged = function(e) {
|
this.networkSelectorChanged = function(e) {
|
||||||
var selectedOption = $(this).find("option:selected");
|
var selectedOption = $(this).find("option:selected");
|
||||||
self.selectNetwork(selectedOption.val());
|
self.selectNetwork(selectedOption.val());
|
||||||
}
|
};
|
||||||
|
|
||||||
this.selectNetwork = function(ssid) {
|
this.selectNetwork = function(ssid) {
|
||||||
console.log("select network: ",ssid);
|
console.log("select network: ",ssid);
|
||||||
if(ssid == "") return;
|
if(ssid == "") return;
|
||||||
console.log(" checked");
|
console.log(" checked");
|
||||||
this.selectedNetwork = ssid;
|
this.selectedNetwork = ssid;
|
||||||
if(this.networks == undefined || ssid == SettingsWindow.NOT_CONNECTED) {
|
if(this.networks == undefined || ssid == SettingsWindow.NOT_CONNECTED) {
|
||||||
this.hideWiFiPassword();
|
this.hideWiFiPassword();
|
||||||
} else {
|
} else {
|
||||||
var network = this.networks[ssid];
|
var network = this.networks[ssid];
|
||||||
if(network.encryption == "none") {
|
if(network.encryption == "none") {
|
||||||
this.hideWiFiPassword();
|
this.hideWiFiPassword();
|
||||||
} else {
|
} else {
|
||||||
this.showWiFiPassword();
|
this.showWiFiPassword();
|
||||||
}
|
}
|
||||||
this.form.find("#password").val("");
|
this.form.find("#password").val("");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
this.showWiFiPassword = function() {
|
this.showWiFiPassword = function() {
|
||||||
this.form.find("#passwordLabel").show();
|
this.form.find("#passwordLabel").show();
|
||||||
this.form.find("#password").show();
|
this.form.find("#password").show();
|
||||||
}
|
};
|
||||||
|
|
||||||
this.hideWiFiPassword = function() {
|
this.hideWiFiPassword = function() {
|
||||||
this.form.find("#passwordLabel").hide();
|
this.form.find("#passwordLabel").hide();
|
||||||
this.form.find("#password").hide();
|
this.form.find("#password").hide();
|
||||||
}
|
};
|
||||||
|
|
||||||
this.setClientModeState = function(state,msg) {
|
this.setClientModeState = function(state,msg) {
|
||||||
var field = this.form.find("#clientModeState");
|
var field = this.form.find("#clientModeState");
|
||||||
var btnConnect = self.form.find("#connectToNetwork");
|
var btnConnect = self.form.find("#connectToNetwork");
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case SettingsWindow.NOT_CONNECTED:
|
case SettingsWindow.NOT_CONNECTED:
|
||||||
btnConnect.removeAttr("disabled");
|
btnConnect.removeAttr("disabled");
|
||||||
field.html("Not connected");
|
field.html("Not connected");
|
||||||
break;
|
break;
|
||||||
case SettingsWindow.CONNECTED:
|
case SettingsWindow.CONNECTED:
|
||||||
btnConnect.removeAttr("disabled");
|
btnConnect.removeAttr("disabled");
|
||||||
|
|
||||||
var fieldText = "Connected to: <b>"+this.currentNetwork+"</b>.";
|
var fieldText = "Connected to: <b>"+this.currentNetwork+"</b>.";
|
||||||
if(this.currentLocalIP != undefined && this.currentLocalIP != "") {
|
if(this.currentLocalIP != undefined && this.currentLocalIP != "") {
|
||||||
var a = "<a href='http://"+this.currentLocalIP+"' target='_black'>"+this.currentLocalIP+"</a>";
|
var a = "<a href='http://"+this.currentLocalIP+"' target='_black'>"+this.currentLocalIP+"</a>";
|
||||||
fieldText += " (IP: "+a+")";
|
fieldText += " (IP: "+a+")";
|
||||||
}
|
}
|
||||||
field.html(fieldText);
|
field.html(fieldText);
|
||||||
break;
|
break;
|
||||||
case SettingsWindow.CONNECTING:
|
case SettingsWindow.CONNECTING:
|
||||||
btnConnect.attr("disabled", true);
|
btnConnect.attr("disabled", true);
|
||||||
field.html("Connecting... Reconnect by connecting your device to <b>"+this.selectedNetwork+"</b> and going to <a href='http://connect.doodle3d.com'>connect.doodle3d.com</a>");
|
field.html("Connecting... Reconnect by connecting your device to <b>"+this.selectedNetwork+"</b> and going to <a href='http://connect.doodle3d.com'>connect.doodle3d.com</a>");
|
||||||
break;
|
break;
|
||||||
case SettingsWindow.CONNECTING_FAILED:
|
case SettingsWindow.CONNECTING_FAILED:
|
||||||
btnConnect.removeAttr("disabled");
|
btnConnect.removeAttr("disabled");
|
||||||
field.html(msg);
|
field.html(msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.clientModeState = state;
|
this.clientModeState = state;
|
||||||
}
|
};
|
||||||
this.setAPModeState = function(state,msg) {
|
|
||||||
|
this.setAPModeState = function(state,msg) {
|
||||||
var field = this.form.find("#apModeState");
|
var field = this.form.find("#apModeState");
|
||||||
var btnCreate = this.form.find("#createAP");
|
var btnCreate = this.form.find("#createAP");
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case SettingsWindow.NO_AP:
|
case SettingsWindow.NO_AP:
|
||||||
btnCreate.removeAttr("disabled");
|
btnCreate.removeAttr("disabled");
|
||||||
field.html("Not currently a access point");
|
field.html("Not currently a access point");
|
||||||
break;
|
break;
|
||||||
case SettingsWindow.AP:
|
case SettingsWindow.AP:
|
||||||
btnCreate.removeAttr("disabled");
|
btnCreate.removeAttr("disabled");
|
||||||
field.html("Is access point: <b>"+this.currentAP+"</b>");
|
field.html("Is access point: <b>"+this.currentAP+"</b>");
|
||||||
break;
|
break;
|
||||||
case SettingsWindow.CREATING_AP:
|
case SettingsWindow.CREATING_AP:
|
||||||
btnCreate.attr("disabled", true);
|
btnCreate.attr("disabled", true);
|
||||||
field.html("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>");
|
field.html("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;
|
||||||
}
|
}
|
||||||
this.apModeState = state;
|
this.apModeState = state;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.connectToNetwork = function() {
|
this.connectToNetwork = function() {
|
||||||
console.log("connectToNetwork");
|
console.log("connectToNetwork");
|
||||||
if(self.selectedNetwork == undefined) return;
|
if(self.selectedNetwork == undefined) return;
|
||||||
var postData = {
|
var postData = {
|
||||||
ssid:self.selectedNetwork,
|
ssid:self.selectedNetwork,
|
||||||
phrase:self.form.find("#password").val(),
|
phrase:self.form.find("#password").val(),
|
||||||
recreate:true
|
recreate:true
|
||||||
}
|
};
|
||||||
|
|
||||||
console.log(" postData: ",postData);
|
console.log(" postData: ",postData);
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
|
|
||||||
@ -681,17 +694,17 @@ function SettingsWindow() {
|
|||||||
//self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings() },self.retryDelay); // retry after delay
|
//self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings() },self.retryDelay); // retry after delay
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
self.setClientModeState(SettingsWindow.CONNECTING,"");
|
self.setClientModeState(SettingsWindow.CONNECTING,"");
|
||||||
|
|
||||||
// after switching wifi network or creating a access point we delay the status retrieval
|
// after switching wifi network or creating a access point we delay the status retrieval
|
||||||
// because the webserver needs time to switch
|
// because the webserver needs time to switch
|
||||||
clearTimeout(self.retrieveNetworkStatusDelay);
|
clearTimeout(self.retrieveNetworkStatusDelay);
|
||||||
self.retrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(true) },self.retrieveNetworkStatusDelayTime);
|
self.retrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(true); },self.retrieveNetworkStatusDelayTime);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.createAP = function() {
|
this.createAP = function() {
|
||||||
console.log("createAP");
|
console.log("createAP");
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
|
|
||||||
// save network related settings and on complete, create access point
|
// save network related settings and on complete, create access point
|
||||||
@ -717,10 +730,10 @@ function SettingsWindow() {
|
|||||||
// after switching wifi network or creating a access point we delay the status retrieval
|
// after switching wifi network or creating a access point we delay the status retrieval
|
||||||
// because the webserver needs time to switch
|
// because the webserver needs time to switch
|
||||||
clearTimeout(self.retrieveNetworkStatusDelay);
|
clearTimeout(self.retrieveNetworkStatusDelay);
|
||||||
self.retrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(true) },self.retrieveNetworkStatusDelayTime);
|
self.retrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(true); },self.retrieveNetworkStatusDelayTime);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
|
Loading…
Reference in New Issue
Block a user