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,12 +293,13 @@ Ardublockly.changeIdeButtons = function(value) { ...@@ -293,12 +293,13 @@ 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() {
// loadXmlBlockFile loads the file asynchronously and needs a callback
var loadXmlCallback = function(sucess) { var loadXmlCallback = function(sucess) {
if (sucess) { if (sucess) {
Ardublockly.renderContent(); Ardublockly.renderContent();
...@@ -315,6 +316,13 @@ Ardublockly.loadServerXmlFile = function(xmlFile) { ...@@ -315,6 +316,13 @@ Ardublockly.loadServerXmlFile = function(xmlFile) {
}; };
Ardublockly.loadXmlBlockFile( Ardublockly.loadXmlBlockFile(
xmlFile, loadXmlCallback, callbackConnectionError); 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