Commit 18f1968d authored by carlosperate's avatar carlosperate

Ask the user if they are sure they want to load new blocks (replace workspace).

parent 77da5c9e
...@@ -293,28 +293,36 @@ Ardublockly.changeIdeButtons = function(value) { ...@@ -293,28 +293,36 @@ Ardublockly.changeIdeButtons = function(value) {
}; };
/** /**
* Loads an XML file from the server and adds the blocks into the Blockly * Loads an XML file from the server and replaces the current blocks into the
* workspace. * Blockly workspace.
* @param {!string} xmlFile Server location of the XML file to load. * @param {!string} xmlFile Server location of the XML file to load.
*/ */
Ardublockly.loadServerXmlFile = function(xmlFile) { Ardublockly.loadServerXmlFile = function(xmlFile) {
// The loadXmlBlockFile loads the file asynchronously and needs a callback var loadXmlfileAccepted = function() {
var loadXmlCallback = function(sucess) { // loadXmlBlockFile loads the file asynchronously and needs a callback
if (sucess) { var loadXmlCallback = function(sucess) {
Ardublockly.renderContent(); if (sucess) {
} else { Ardublockly.renderContent();
Ardublockly.alertMessage( } else {
'Invalid XML', Ardublockly.alertMessage(
'The XML file was not successfully parsed into blocks.' + 'Invalid XML',
'Please review the XML code and try again.', 'The XML file was not successfully parsed into blocks.' +
false); 'Please review the XML code and try again.',
} false);
}; }
var callbackConnectionError = function() { };
Ardublockly.openNotConnectedModal(); var callbackConnectionError = function() {
Ardublockly.openNotConnectedModal();
};
Ardublockly.loadXmlBlockFile(
xmlFile, loadXmlCallback, callbackConnectionError);
}; };
Ardublockly.loadXmlBlockFile(
xmlFile, loadXmlCallback, callbackConnectionError); Ardublockly.alertMessage(
'Load new blocks?',
'Loading a new XML file will replace the current blocks from the ' +
'workspace.\nAre you sure you want to proceed?',
true, loadXmlfileAccepted);
}; };
/** /**
......
...@@ -61,8 +61,8 @@ Ardublockly.bindBlocklyEventListeners = function() { ...@@ -61,8 +61,8 @@ Ardublockly.bindBlocklyEventListeners = function() {
}; };
/** /**
* Loads an XML file from the server and adds the blocks into the Blockly * Loads an XML file from the server and replaces the current blocks into the
* workspace. * Blockly workspace.
* @param {!string} xmlFile XML file path in a reachable server (no local path). * @param {!string} xmlFile XML file path in a reachable server (no local path).
* @param {!function} callbackFileLoaded Function to be called once the file is * @param {!function} callbackFileLoaded Function to be called once the file is
* loaded. * loaded.
......
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