Commit 30ae6e47 authored by carlosperate's avatar carlosperate

Change variables naming convention in arduino app to comply to Google's js coding style.

Changed from current 'snake_case' to 'lower camel case'.
parent 8c6adf0f
......@@ -25,13 +25,13 @@ There was an error manipulating the sketch data!!
- [ ] Combine Arduino boards from code generator with Arduino boards offered for compilation
## Static typing
- [x] Warnings for setting variables to a different type than first instance
- [x] Type finding for the get variable block
- [ ] math_number block 'errornumber' type
- [ ] remove getVarType types that are use for debugging
- [ ] math_arithmetic getType to check types of given inputs to decide between int or float
- [ ] math_number getType to use regular expressions more efficiently
- [ ] logic_ternary block getType to defines type as that of its inputs
- [ ] logic_null block right now does not return a type, this might change
- [ ] math_number block 'errornumber' type used for debugging, remove
- [ ] math_arithmetic getType to check types of given inputs to decide between int or float . Right now first block within sets the type.
- [ ] math_constrain getType to check types of given inputs to decide between int or float . Right now first block within sets the type.
- [ ] math_number getType to use regular expressions more efficiently
- [ ] math_on_list to add static type if lists get implemented
- [ ] controls_for getVarType function
- [ ] controls_forEach block uses lists, these are not implemented in the Arduino generator (possible arrays), when implemented this block needs a getVarType, varType, and getType functions.
- [ ] add getVarType to the procedures blocks
......@@ -43,6 +43,7 @@ There was an error manipulating the sketch data!!
- [ ] Add a way to select different Arduino boards (settings menu should trigger arduino generator board change)
- [ ] Code generator for lists into arrays.
- [ ] A lot of blocks go through the entire block tree, which end ups being terribly inefficient. Maybe create a general pass through in the arduino.js file to check everything that needs to be checked in one pass.
- [ ] SPI spi_transfer also needs returns a byte back
## Arduino web-app
- [ ] Edit toolbox fade out + visibility button fade in with a CSS animated change in height with overflow hidden.
......
......@@ -156,17 +156,17 @@ ArduinoMaterial.loadUserXmlFile = function() {
reader.readAsText(files[0]);
}
// Create once invisible browse button with event listener, and click it
var select_file = document.getElementById("select_file");
if (select_file == null) {
var select_file_dom = document.createElement('INPUT');
select_file_dom.type = 'file';
select_file_dom.id = 'select_file';
select_file_dom.style = 'display: none';
var selectFile = document.getElementById("select_file");
if (selectFile == null) {
var selectFileDom = document.createElement('INPUT');
selectFileDom.type = 'file';
selectFileDom.id = 'select_file';
selectFileDom.style = 'display: none';
document.body.appendChild(select_file_dom);
select_file = document.getElementById("select_file");
select_file.addEventListener('change', parseInputXMLfile, false);
selectFile = document.getElementById("select_file");
selectFile.addEventListener('change', parseInputXMLfile, false);
}
select_file.click();
selectFile.click();
};
/**
......@@ -205,14 +205,14 @@ ArduinoMaterial.populateSettings = function() {
/**
* Sets the compiler location form data retrieve from an updated element.
* @param {element} new_el New HTML element to replace the one in the current
* @param {element} newEl New HTML element to replace the one in the current
* DOM. Should contain a complete input text element.
*/
ArduinoMaterial.setCompilerLocationHtml = function(new_el) {
if (new_el != null) {
var comp_loc_ip = document.getElementById('settings_compiler_location')
if (comp_loc_ip != null) {
comp_loc_ip.value = new_el.value;
ArduinoMaterial.setCompilerLocationHtml = function(newEl) {
if (newEl != null) {
var compLocIp = document.getElementById('settings_compiler_location')
if (compLocIp != null) {
compLocIp.value = newEl.value;
}
} else {
// If the element is Null, then Ardublockly server is not running
......@@ -222,14 +222,14 @@ ArduinoMaterial.setCompilerLocationHtml = function(new_el) {
/**
* Sets the sketch location form data retrieve from an updated element.
* @param {element} new_el New HTML element to replace the one in the current
* @param {element} newEl New HTML element to replace the one in the current
* DOM. Should contain a complete input text element.
*/
ArduinoMaterial.setSketchLocationHtml = function(new_el) {
if (new_el != null) {
var sketch_loc_ip = document.getElementById('settings_sketch_location');
if (sketch_loc_ip != null) {
sketch_loc_ip.value = new_el.value;
ArduinoMaterial.setSketchLocationHtml = function(newEl) {
if (newEl != null) {
var sketchLocIp = document.getElementById('settings_sketch_location');
if (sketchLocIp != null) {
sketchLocIp.value = newEl.value;
}
} else {
// If the element is Null, then Ardublockly server is not running
......@@ -240,16 +240,16 @@ ArduinoMaterial.setSketchLocationHtml = function(new_el) {
/**
* Replaces the Arduino Boards form data with a new HTMl element.
* Ensures there is a change listener to call 'setSerialPort' function
* @param {element} new_el New HTML element to replace the one in the current
* @param {element} newEl New HTML element to replace the one in the current
* DOM. Should contain a complete select element.
*/
ArduinoMaterial.setArduinoBoardsHtml = function(new_el) {
if (new_el != null) {
var board_dropdown = document.getElementById('board');
if (board_dropdown != null) {
new_el.id = 'board';
new_el.onchange = ArduinoMaterial.setBoard;
board_dropdown.parentNode.replaceChild(new_el, board_dropdown);
ArduinoMaterial.setArduinoBoardsHtml = function(newEl) {
if (newEl != null) {
var boardDropdown = document.getElementById('board');
if (boardDropdown != null) {
newEl.id = 'board';
newEl.onchange = ArduinoMaterial.setBoard;
boardDropdown.parentNode.replaceChild(newEl, boardDropdown);
// Refresh the materialize select menus
// TODO: Currently a reported bug from Materialize
$('select').material_select();
......@@ -265,25 +265,25 @@ ArduinoMaterial.setArduinoBoardsHtml = function(new_el) {
*/
ArduinoMaterial.setBoard = function() {
var el = document.getElementById("board");
var board_value = el.options[el.selectedIndex].value;
var boardValue = el.options[el.selectedIndex].value;
//TODO: check how ArduServerCompiler deals with invalid data and sanitise
ArduServerCompiler.setArduinoBoard(
board_value, ArduinoMaterial.setArduinoBoardsHtml);
boardValue, ArduinoMaterial.setArduinoBoardsHtml);
};
/**
* Replaces the Serial Port form data with a new HTMl element.
* Ensures there is a change listener to call 'setSerialPort' function
* @param {element} new_el New HTML element to replace the one in the current
* @param {element} newEl New HTML element to replace the one in the current
* DOM. Should contain a complete select element.
*/
ArduinoMaterial.setSerialPortsHtml = function(new_el) {
if (new_el != null) {
var serial_dropdown = document.getElementById('serial_port');
if (serial_dropdown != null) {
new_el.id = 'serial_port';
new_el.onchange = ArduinoMaterial.setSerial;
serial_dropdown.parentNode.replaceChild(new_el, serial_dropdown);
ArduinoMaterial.setSerialPortsHtml = function(newEl) {
if (newEl != null) {
var serialDropdown = document.getElementById('serial_port');
if (serialDropdown != null) {
newEl.id = 'serial_port';
newEl.onchange = ArduinoMaterial.setSerial;
serialDropdown.parentNode.replaceChild(newEl, serialDropdown);
// Refresh the materialize select menus
// TODO: Currently a reported bug from Materialize
$('select').material_select();
......@@ -299,25 +299,25 @@ ArduinoMaterial.setSerialPortsHtml = function(new_el) {
*/
ArduinoMaterial.setSerial = function() {
var el = document.getElementById("serial_port");
var serial_value = el.options[el.selectedIndex].value;
var serialValue = el.options[el.selectedIndex].value;
//TODO: check how ArduServerCompiler deals with invalid data and sanitise
ArduServerCompiler.setSerialPort(
serial_value, ArduinoMaterial.setSerialPortsHtml);
serialValue, ArduinoMaterial.setSerialPortsHtml);
};
/**
* Replaces IDE options form data with a new HTMl element.
* Ensures there is a change listener to call 'setIdeSettings' function
* @param {element} new_el New HTML element to replace the one in the current
* @param {element} newEl New HTML element to replace the one in the current
* DOM. Should contain a complete select element.
*/
ArduinoMaterial.setIdeHtml = function(new_el) {
if (new_el != null) {
var ide_dropdown = document.getElementById('ide_settings');
if (ide_dropdown != null) {
new_el.id = 'ide_settings';
new_el.onchange = ArduinoMaterial.setIdeSettings;
ide_dropdown.parentNode.replaceChild(new_el, ide_dropdown);
ArduinoMaterial.setIdeHtml = function(newEl) {
if (newEl != null) {
var ideDropdown = document.getElementById('ide_settings');
if (ideDropdown != null) {
newEl.id = 'ide_settings';
newEl.onchange = ArduinoMaterial.setIdeSettings;
ideDropdown.parentNode.replaceChild(newEl, ideDropdown);
// Refresh the materialize select menus
// TODO: Currently a reported bug from Materialize
$('select').material_select();
......@@ -333,9 +333,9 @@ ArduinoMaterial.setIdeHtml = function(new_el) {
*/
ArduinoMaterial.setIdeSettings = function() {
var el = document.getElementById("ide_settings");
var ide_value = el.options[el.selectedIndex].value;
var ideValue = el.options[el.selectedIndex].value;
//TODO: check how ArduServerCompiler deals with invalid data and sanitise here
ArduServerCompiler.setIdeOptions(ide_value, ArduinoMaterial.setIdeHtml);
ArduServerCompiler.setIdeOptions(ideValue, ArduinoMaterial.setIdeHtml);
};
/**
......@@ -352,13 +352,13 @@ ArduinoMaterial.sendCode = function() {
/**
* Receives the IDE data back to be displayed and stops spinner.
* @param {element} new_el New HTML element to replace the one in the current
* DOM. Should contain a complete select element.
* @param {element} dataBack New HTML elements to include in the modal to
* display the data back from the compiler.
*/
ArduinoMaterial.sendCodeReturn = function(data_back) {
ArduinoMaterial.sendCodeReturn = function(dataBack) {
ArduinoMaterial.runButtonSpinner(false);
if (data_back != null) {
ArduinoMaterial.arduinoIdeModal(data_back);
if (dataBack != null) {
ArduinoMaterial.arduinoIdeModal(dataBack);
} else {
// If the element is Null, then Ardublockly server is not running
$('#not_running_dialog').openModal();
......@@ -387,15 +387,15 @@ ArduinoMaterial.XmlTextareaToBlocks = function() {
*/
ArduinoMaterial.renderContent = function() {
// Render Arduino Code syntax highlighted into element
var arduino_content = document.getElementById('content_arduino');
arduino_content.textContent = ArduinoMaterial.generateArduino();;
var arduinoContent = document.getElementById('content_arduino');
arduinoContent.textContent = ArduinoMaterial.generateArduino();;
if (typeof prettyPrintOne == 'function') {
var code_html = prettyPrintOne(arduino_content.innerHTML, 'cpp');
arduino_content.innerHTML = code_html;
var codeHtml = prettyPrintOne(arduinoContent.innerHTML, 'cpp');
arduinoContent.innerHTML = codeHtml;
}
// Generate plain XML into element
var xml_content = document.getElementById('content_xml');
xml_content.value = ArduinoMaterial.generateXml();
var xmlContent = document.getElementById('content_xml');
xmlContent.value = ArduinoMaterial.generateXml();
};
/**
......@@ -403,13 +403,13 @@ ArduinoMaterial.renderContent = function() {
* @type {!boolean}
* @private
*/
ArduinoMaterial.toolbar_showing_ = true;
ArduinoMaterial.TOOLBAR_SHOWING_ = true;
/**
* Toggles the toolbox and respective button On and Off
*/
ArduinoMaterial.toogleToolbox = function() {
if (ArduinoMaterial.toolbar_showing_ == true ) {
if (ArduinoMaterial.TOOLBAR_SHOWING_ == true ) {
// showToolbox() takes a callback function as its second argument
ArduinoMaterial.showToolbox(false,
function() { ArduinoMaterial.showToolboxButtonState(false); });
......@@ -418,7 +418,7 @@ ArduinoMaterial.toogleToolbox = function() {
ArduinoMaterial.showToolboxButtonState(true);
ArduinoMaterial.showToolbox(true);
}
ArduinoMaterial.toolbar_showing_ = !ArduinoMaterial.toolbar_showing_;
ArduinoMaterial.TOOLBAR_SHOWING_ = !ArduinoMaterial.TOOLBAR_SHOWING_;
};
/**
......@@ -426,7 +426,7 @@ ArduinoMaterial.toogleToolbox = function() {
* @return {boolean} Indicates if the toolbox is currently visible.
*/
ArduinoMaterial.isToolboxVisible = function() {
return ArduinoMaterial.toolbar_showing_;
return ArduinoMaterial.TOOLBAR_SHOWING_;
};
/**
......
......@@ -20,16 +20,16 @@ ArduinoMaterial.BLOCKLY_INJECTED = false;
/**
* Injects Blockly into a given HTML element. Reads the toolbox from an XMl
* file.
* @param {!Element} el Element to inject Blockly into.
* @param {!string} toolbox_path String containing the toolbox XML file path.
* @param {!Element} blocklyEl Element to inject Blockly into.
* @param {!string} toolboxPath String containing the toolbox XML file path.
*/
ArduinoMaterial.injectBlockly = function(blockly_el, toolbox_path) {
ArduinoMaterial.injectBlockly = function(blocklyEl, toolboxPath) {
// Create a an XML HTTP request
var request = ArduinoMaterial.ajaxRequest();
// If file run locally Internet explorer fails here
try {
request.open("GET", toolbox_path, true);
request.open("GET", toolboxPath, true);
} catch(e) {
$('#not_running_dialog').openModal();
}
......@@ -37,7 +37,7 @@ ArduinoMaterial.injectBlockly = function(blockly_el, toolbox_path) {
// Once file is open, inject blockly into element with the toolbox string
request.onreadystatechange = function() {
if ( (request.readyState == 4) && (request.status == 200) ) {
Blockly.inject(blockly_el, {
Blockly.inject(blocklyEl, {
collapse: true,
comments: true,
disable: true,
......@@ -111,13 +111,13 @@ ArduinoMaterial.generateXml = function() {
/**
* Parses the XML from its input to generate and replace the blocks in the
* Blockly workspace.
* @param {!string} blocks_xml String of XML code for the blocks.
* @param {!string} blocksXml String of XML code for the blocks.
* @return {!boolean} Indicates if the XML into blocks parse was successful.
*/
ArduinoMaterial.replaceBlocksfromXml = function(blocks_xml) {
ArduinoMaterial.replaceBlocksfromXml = function(blocksXml) {
var xmlDom = null;
try {
xmlDom = Blockly.Xml.textToDom(blocks_xml);
xmlDom = Blockly.Xml.textToDom(blocksXml);
} catch (e) {
return false;
}
......@@ -131,12 +131,12 @@ ArduinoMaterial.replaceBlocksfromXml = function(blocks_xml) {
/**
* Parses the XML from its input to generate and add blocks to the workspace.
* @param {!string} blocks_xml_dom String of XML DOM code for the blocks.
* @param {!string} blocksXmlDom String of XML DOM code for the blocks.
* @return {!boolean} Indicates if the XML into blocks parse was successful.
*/
ArduinoMaterial.loadBlocksfromXmlDom = function(blocks_xml_dom) {
ArduinoMaterial.loadBlocksfromXmlDom = function(blocksXmlDom) {
try {
Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, blocks_xml_dom);
Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, blocksXmlDom);
} catch (e) {
return false;
}
......@@ -165,14 +165,14 @@ ArduinoMaterial.showToolbox = function(show, callback) {
* Discard all blocks from the workspace.
*/
ArduinoMaterial.discard = function() {
var block_count = Blockly.mainWorkspace.getAllBlocks().length;
if (block_count == 1) {
var blockCount = Blockly.mainWorkspace.getAllBlocks().length;
if (blockCount == 1) {
Blockly.mainWorkspace.clear();
ArduinoMaterial.renderContent();
} else if (block_count > 1) {
} else if (blockCount > 1) {
ArduinoMaterial.materialAlert(
'Delete blocks?',
'There are ' + block_count + ' blocks on the workspace. Are you \
'There are ' + blockCount + ' blocks on the workspace. Are you \
sure you want to delete them?',
true,
function() {
......
......@@ -43,14 +43,14 @@ ArduinoMaterial.materializeJsInit = function() {
*/
ArduinoMaterial.runButtonSpinner = function(active) {
var spinner = document.getElementById('button_run_spinner');
var button_el = document.getElementById('button_run');
var button_class = button_el.className;
var buttonEl = document.getElementById('button_run');
var buttonClass = buttonEl.className;
if (active) {
spinner.style.display = 'block';
button_el.className = button_class.replace('arduino_orange', 'grey');
buttonEl.className = buttonClass.replace('arduino_orange', 'grey');
} else {
spinner.style.display = 'none';
button_el.className = button_class.replace('grey', 'arduino_orange');
buttonEl.className = buttonClass.replace('grey', 'arduino_orange');
}
};
......@@ -58,11 +58,11 @@ ArduinoMaterial.runButtonSpinner = function(active) {
* Displays or hides the 'load textarea xml' button.
*/
ArduinoMaterial.buttonLoadXmlCodeDisplay = function() {
var xml_button = document.getElementById('button_load_xml');
var xml_button_body = document.getElementById('xml_collapsible_body');
//var xmlButton = document.getElementById('button_load_xml');
var xmlButtonBody = document.getElementById('xml_collapsible_body');
// Waiting to check status due to the animation delay
setTimeout(function() {
if (xml_button_body.style.display == 'none') {
if (xmlButtonBody.style.display == 'none') {
$('#button_load_xml').hide();
} else {
$('#button_load_xml').fadeIn('slow');
......@@ -72,21 +72,21 @@ ArduinoMaterial.buttonLoadXmlCodeDisplay = function() {
/**
* Sets the class and content of the toolbox On and Off button.
* @param {!boolean} toolbox_visible Indicates if the toolbox visibility.
* @param {!boolean} toolboxVisible Indicates if the toolbox visibility.
*/
ArduinoMaterial.showToolboxButtonState = function(toolbox_visible) {
var toolbox_button = document.getElementById('button_toggle_toolbox');
var toolbox_button_icon = document.getElementById('button_toggle_toolbox_icon');
ArduinoMaterial.showToolboxButtonState = function(toolboxVisible) {
var toolboxButton = document.getElementById('button_toggle_toolbox');
var toolboxButtonIcon = document.getElementById('button_toggle_toolbox_icon');
// Element conatins several classes, use replace to maintain the rest
if (toolbox_visible == true) {
toolbox_button.className = toolbox_button.className.replace(
if (toolboxVisible == true) {
toolboxButton.className = toolboxButton.className.replace(
"button_toggle_toolbox_on", "button_toggle_toolbox_off");
toolbox_button_icon.className = toolbox_button_icon.className.replace(
toolboxButtonIcon.className = toolboxButtonIcon.className.replace(
'mdi-action-visibility', 'mdi-action-visibility-off');
} else {
toolbox_button.className = toolbox_button.className.replace(
toolboxButton.className = toolboxButton.className.replace(
"button_toggle_toolbox_off", "button_toggle_toolbox_on");
toolbox_button_icon.className = toolbox_button_icon.className.replace(
toolboxButtonIcon.className = toolboxButtonIcon.className.replace(
'mdi-action-visibility-off', 'mdi-action-visibility');
}
};
......@@ -95,25 +95,25 @@ ArduinoMaterial.showToolboxButtonState = function(toolbox_visible) {
* Resizes the container for Blockly and forces a re-render of the SVG.
*/
ArduinoMaterial.resizeBlocklyWorkspace = function() {
var content_blocks = document.getElementById('content_blocks');
var wrapper_panel_size =
var contentBlocks = document.getElementById('content_blocks');
var wrapperPanelSize =
ArduinoMaterial.getBBox_(document.getElementById('blocks_panel'));
content_blocks.style.top = wrapper_panel_size.y + 'px';
content_blocks.style.left = wrapper_panel_size.x + 'px';
contentBlocks.style.top = wrapperPanelSize.y + 'px';
contentBlocks.style.left = wrapperPanelSize.x + 'px';
// Height and width need to be set, read back, then set again to
// compensate for scrollbars.
content_blocks.style.height = wrapper_panel_size.height + 'px';
content_blocks.style.height =
(2 * wrapper_panel_size.height - content_blocks.offsetHeight) + 'px';
content_blocks.style.width = wrapper_panel_size.width + 'px';
content_blocks.style.width =
(2 * wrapper_panel_size.width - content_blocks.offsetWidth) + 'px';
contentBlocks.style.height = wrapperPanelSize.height + 'px';
contentBlocks.style.height =
(2 * wrapperPanelSize.height - contentBlocks.offsetHeight) + 'px';
contentBlocks.style.width = wrapperPanelSize.width + 'px';
contentBlocks.style.width =
(2 * wrapperPanelSize.width - contentBlocks.offsetWidth) + 'px';
//Blockly.MsvgResize();
//Blockly.mainWorkspace.render();
//alert(
// "resized " + wrapper_panel_size.width + " " + content_blocks.style.width);
// "resized " + wrapperPanelSize.width + " " + contentBlocks.style.width);
// Sets the toolbox toggle button width to that of the toolbox
if ( ArduinoMaterial.isToolboxVisible() &&
......@@ -152,11 +152,11 @@ ArduinoMaterial.materialAlert = function(title, body, confirm, callback) {
/**
* Populates the Arduino output data modal and opens it.
* @param {!element} body_el HTML to include into dialog content.
* @param {!element} bodyEl HTML to include into dialog content.
*/
ArduinoMaterial.arduinoIdeModal = function(body_el) {
ArduinoMaterial.arduinoIdeModal = function(bodyEl) {
$("#arduino_dialog_body").text('');
$("#arduino_dialog_body").append(body_el);
$("#arduino_dialog_body").append(bodyEl);
$('#arduino_dialog').openModal();
window.location.hash = '';
};
......
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