Skip to content

Commit d5322ab

Browse files
committed
Front end: Set better Settings default messages
1 parent 64c5a9d commit d5322ab

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

ardublockly/ardublockly.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,8 @@ Ardublockly.setCompilerLocationHtml = function(newEl) {
375375

376376
var compLocIp = document.getElementById('settings_compiler_location');
377377
if (compLocIp != null) {
378-
if (newEl.value) {
379-
compLocIp.value = newEl.value;
380-
}
378+
compLocIp.value = newEl.value || compLocIp.value ||
379+
'Please enter the location of the Arduino IDE executable';
381380
compLocIp.style.cssText = newEl.style.cssText;
382381
}
383382
};
@@ -392,9 +391,8 @@ Ardublockly.setSketchLocationHtml = function(newEl) {
392391

393392
var sketchLocIp = document.getElementById('settings_sketch_location');
394393
if (sketchLocIp != null) {
395-
if (newEl.value) {
396-
sketchLocIp.value = newEl.value;
397-
}
394+
sketchLocIp.value = newEl.value || sketchLocIp.value ||
395+
'Please enter a folder to store the Arduino Sketch';
398396
sketchLocIp.style.cssText = newEl.style.cssText;
399397
}
400398
};

ardublockly/ardublocklyserver_ajax.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,29 @@ ArdublocklyServer.jsonToHtmlTextInput = function(jsonObj) {
187187

188188
ArdublocklyServer.jsonToHtmlDropdown = function(jsonObj) {
189189
var element = null;
190-
if (jsonObj && jsonObj.selected && jsonObj.options) {
190+
if (!jsonObj) {
191+
console.error('Invalid JSON received from server.');
192+
} else if(jsonObj.errors) {
193+
console.error('There are errors in the JSON response from server.');
194+
console.error(jsonObj);
195+
} else {
191196
// Drop down list of unknown length with a selected item
192197
element = document.createElement('select');
193-
element.name = jsonObj.response_type;
198+
element.name = jsonObj.settings_type;
194199
for (var i = 0; i < jsonObj.options.length; i++) {
195200
if (jsonObj.options[i].value && jsonObj.options[i].display_text) {
196201
var option = document.createElement('option');
197202
option.value = jsonObj.options[i].value;
198203
option.text = jsonObj.options[i].display_text;
199204
// Check selected option and mark it
200-
option.selected = jsonObj.options[i].value == jsonObj.selected;
205+
if (jsonObj.selected) {
206+
option.selected = jsonObj.options[i].value == jsonObj.selected;
207+
}
201208
element.appendChild(option);
202209
} else {
203210
console.error('Missing required JSON keys for Drop Down conversion.');
204211
}
205212
}
206-
} else {
207-
console.error('Missing required JSON keys for Drop Down conversion.');
208213
}
209214
return element;
210215
};

0 commit comments

Comments
 (0)