0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-25 18:47:57 +01:00

Properly reading all the values from the form when saving

This commit is contained in:
peteruithoven 2013-08-29 01:41:18 +02:00
parent 2deec18072
commit 4d53a2ee19

View File

@ -102,16 +102,6 @@ function SettingsWindow() {
this.saveSettings = function(callback) { this.saveSettings = function(callback) {
console.log("Settings:saveSettings"); console.log("Settings:saveSettings");
//var printerSettings = {};
$("#printersettings input").each( function(index,element) {
var element = $(element);
//populate settings are with values from html
if(element.attr("type") == "text" || element.attr("type") == "number") {
settings[element.attr('name')] = element.val();
} else if(element.attr("type") == "checkbox") {
settings[element.attr('name')] = element.prop('checked')
}
});
this.readForm(); this.readForm();
if (communicateWithWifibox) { if (communicateWithWifibox) {
@ -171,7 +161,6 @@ function SettingsWindow() {
} }
}); });
// TODO: textarea's
var textareas = this.form.find("textarea"); var textareas = this.form.find("textarea");
console.log(textareas); console.log(textareas);
textareas.each( function(index,element) { textareas.each( function(index,element) {
@ -186,15 +175,29 @@ function SettingsWindow() {
this.readForm = function() { this.readForm = function() {
console.log("SettingsWindow:readForm"); console.log("SettingsWindow:readForm");
// read settings from form var selects = this.form.find("select");
selects.each( function(index,element) {
var element = $(element);
settings[element.attr('name')] = element.val();
});
var inputs = this.form.find("input");
inputs.each( function(index,element) {
var element = $(element);
switch(element.attr("type")) {
case "text":
case "number":
settings[element.attr('name')] = element.val();
break;
case "checkbox":
settings[element.attr('name')] = element.prop('checked')
break;
}
});
// TODO: textarea's
var textareas = this.form.find("textarea"); var textareas = this.form.find("textarea");
console.log(textareas);
textareas.each( function(index,element) { textareas.each( function(index,element) {
var element = $(element); var element = $(element);
console.log("printer textarea: ",index,element.attr('name')); //,element);
console.log(" val: ",element.val());
settings[element.attr('name')] = element.val(); settings[element.attr('name')] = element.val();
}); });
console.log(settings); console.log(settings);