From 66eff965c99f4cd8c9757a0c2f58ba1f212bd2b8 Mon Sep 17 00:00:00 2001 From: Emma Dauterman Date: Mon, 22 Aug 2016 17:48:31 -0700 Subject: [PATCH] Blockly Factory: Workspace Factory Import Buttons (#578) * Split import into 2 buttons, made file endings consistent * Nit spelling * Nit removed logging message --- .../block_exporter_controller.js | 12 ++++-- demos/blocklyfactory/index.html | 26 +++++++----- .../workspacefactory/wfactory_controller.js | 2 +- .../workspacefactory/wfactory_init.js | 41 ++++++++++++++----- 4 files changed, 56 insertions(+), 25 deletions(-) diff --git a/demos/blocklyfactory/block_exporter_controller.js b/demos/blocklyfactory/block_exporter_controller.js index 5d0c83063..d6c6fd649 100644 --- a/demos/blocklyfactory/block_exporter_controller.js +++ b/demos/blocklyfactory/block_exporter_controller.js @@ -143,9 +143,9 @@ BlockExporterController.prototype.export = function() { // Get block definition code in the selected format for the blocks. var blockDefs = this.tools.getBlockDefs(blockXmlMap, definitionFormat); - // Download the file. + // Download the file, using .js file ending for JSON or Javascript. FactoryUtils.createAndDownloadFile( - blockDefs, blockDef_filename, definitionFormat); + blockDefs, blockDef_filename, 'javascript'); } } @@ -158,9 +158,15 @@ BlockExporterController.prototype.export = function() { // Get generator stub code in the selected language for the blocks. var genStubs = this.tools.getGeneratorCode(blockXmlMap, language); + // Get the correct file extension. + if (language == 'JavaScript') { + var fileType = 'javascript'; + } else { + var fileType = 'plain'; + } // Download the file. FactoryUtils.createAndDownloadFile( - genStubs, generatorStub_filename, language); + genStubs, generatorStub_filename, fileType); } } diff --git a/demos/blocklyfactory/index.html b/demos/blocklyfactory/index.html index 4beb7f029..b9f47a06d 100644 --- a/demos/blocklyfactory/index.html +++ b/demos/blocklyfactory/index.html @@ -124,16 +124,22 @@