Commit d5322ab4 authored by carlosperate's avatar carlosperate

Front end: Set better Settings default messages

parent 64c5a9da
......@@ -375,9 +375,8 @@ Ardublockly.setCompilerLocationHtml = function(newEl) {
var compLocIp = document.getElementById('settings_compiler_location');
if (compLocIp != null) {
if (newEl.value) {
compLocIp.value = newEl.value;
}
compLocIp.value = newEl.value || compLocIp.value ||
'Please enter the location of the Arduino IDE executable';
compLocIp.style.cssText = newEl.style.cssText;
}
};
......@@ -392,9 +391,8 @@ Ardublockly.setSketchLocationHtml = function(newEl) {
var sketchLocIp = document.getElementById('settings_sketch_location');
if (sketchLocIp != null) {
if (newEl.value) {
sketchLocIp.value = newEl.value;
}
sketchLocIp.value = newEl.value || sketchLocIp.value ||
'Please enter a folder to store the Arduino Sketch';
sketchLocIp.style.cssText = newEl.style.cssText;
}
};
......
......@@ -187,24 +187,29 @@ ArdublocklyServer.jsonToHtmlTextInput = function(jsonObj) {
ArdublocklyServer.jsonToHtmlDropdown = function(jsonObj) {
var element = null;
if (jsonObj && jsonObj.selected && jsonObj.options) {
if (!jsonObj) {
console.error('Invalid JSON received from server.');
} else if(jsonObj.errors) {
console.error('There are errors in the JSON response from server.');
console.error(jsonObj);
} else {
// Drop down list of unknown length with a selected item
element = document.createElement('select');
element.name = jsonObj.response_type;
element.name = jsonObj.settings_type;
for (var i = 0; i < jsonObj.options.length; i++) {
if (jsonObj.options[i].value && jsonObj.options[i].display_text) {
var option = document.createElement('option');
option.value = jsonObj.options[i].value;
option.text = jsonObj.options[i].display_text;
// Check selected option and mark it
if (jsonObj.selected) {
option.selected = jsonObj.options[i].value == jsonObj.selected;
}
element.appendChild(option);
} else {
console.error('Missing required JSON keys for Drop Down conversion.');
}
}
} else {
console.error('Missing required JSON keys for Drop Down conversion.');
}
return element;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment