root 4 years ago
parent
commit
e12d49ef57
6 changed files with 108 additions and 39 deletions
  1. 3 2
      cocoblockly.css
  2. 7 3
      index.css
  3. 69 21
      index.html
  4. 20 4
      index.js
  5. 7 7
      src/blockly/ardublockly.js
  6. 2 2
      src/toolbar.js

+ 3 - 2
cocoblockly.css

@@ -787,7 +787,7 @@ footer.page-footer {
     overflow-y: auto;
     overflow-y: auto;
     opacity: 0;
     opacity: 0;
     position: absolute;
     position: absolute;
-    z-index: 999;
+    z-index: 9999;
     /* will-change: width, height; */
     /* will-change: width, height; */
 }
 }
 
 
@@ -875,7 +875,7 @@ footer.page-footer {
 }
 }
 
 
 nav ul a {
 nav ul a {
-    font-size: 0.9rem;
+    font-size: 14px;
     padding: 0 10px;
     padding: 0 10px;
 }
 }
 
 
@@ -1631,6 +1631,7 @@ nav ul li {
 #plugin_download span,#button_upgrade_firmware span,#button_connection_type span{
 #plugin_download span,#button_upgrade_firmware span,#button_connection_type span{
     color: #222222;
     color: #222222;
     font-family: "微软雅黑";
     font-family: "微软雅黑";
+    font-size: 14px;
 }
 }
 
 
 #local_help_ai span,#local_help_extends span,#local_help_error span {
 #local_help_ai span,#local_help_extends span,#local_help_error span {

+ 7 - 3
index.css

@@ -693,14 +693,17 @@ ul, li {
     position: absolute;
     position: absolute;
     top: 64px;
     top: 64px;
     width: 177px;
     width: 177px;
-    z-index: 1000;
+    z-index: 9999;
     background: #fff;
     background: #fff;
     border-radius: 4px;
     border-radius: 4px;
     border: 1px solid #e6e6e6;
     border: 1px solid #e6e6e6;
     box-shadow: 1px 1px 4px #cccccc;
     box-shadow: 1px 1px 4px #cccccc;
     display: none;
     display: none;
 }
 }
+.translatable_download_uploader{
 
 
+    font-size: 14px;
+}
 .downbox div {
 .downbox div {
     /* background: #ffffff; */
     /* background: #ffffff; */
     width: 100%;
     width: 100%;
@@ -756,6 +759,7 @@ ul, li {
     top: 63px;
     top: 63px;
     width: 200px;
     width: 200px;
     margin-left: -88px;
     margin-left: -88px;
+    z-index: 9999;
 }
 }
 
 
 /* .downbox div:hover {
 /* .downbox div:hover {
@@ -1361,7 +1365,7 @@ table td, th {
    letter-spacing: 0;
    letter-spacing: 0;
 }
 }
 
 
-.cloud_storage_name_modal {
+.donload_file_cocorobo, .cloud_storage_name_modal {
     top: 25% !important;
     top: 25% !important;
     width: 360px;
     width: 360px;
     max-height: 240px;
     max-height: 240px;
@@ -1387,7 +1391,7 @@ table td, th {
     text-align: center;
     text-align: center;
 }
 }
 
 
-#cloud_input {
+#donload_file_cloud_input, #cloud_input {
     background: #FFFFFF;
     background: #FFFFFF;
     border: 1px solid #CCCCCC;
     border: 1px solid #CCCCCC;
     border-radius: 3px;
     border-radius: 3px;

+ 69 - 21
index.html

@@ -211,10 +211,11 @@
                             <li id="button_load">
                             <li id="button_load">
                                 <span class="translatable_import_local_file">导入本地文件</span>
                                 <span class="translatable_import_local_file">导入本地文件</span>
                             </li>
                             </li>
-                            <li id="button_import_cloud" class='modal-trigger' onclick='openUrl("//demo-lecode.smartedu.lenovo.com/zhangyu/store#/_st=blockpy")'>
+                            <li id="button_import_cloud" class='modal-trigger'
+                                onclick='openUrl("//demo-lecode.smartedu.lenovo.com/zhangyu/store#/_st=blockpy")'>
                                 <span class="translatable_import_cloud_file">导入云端文件</span>
                                 <span class="translatable_import_cloud_file">导入云端文件</span>
                             </li>
                             </li>
-                            <li id="button_save">
+                            <li id="button_save" class='modal-trigger' href="#donload_file_cocorobo">
                                 <span class="translatable_export_local_file">保存到本地</span>
                                 <span class="translatable_export_local_file">保存到本地</span>
                             </li>
                             </li>
                             <li id="button_save_cloud" class='modal-trigger' href="#cloud_storage_name_modal">
                             <li id="button_save_cloud" class='modal-trigger' href="#cloud_storage_name_modal">
@@ -249,7 +250,7 @@
                                     </li>
                                     </li>
                                 </ul>
                                 </ul>
                             </li>
                             </li>
-                            <li id="button_upgrade_firmware" class="modal-trigger" href = "#firmware_upgrade_modal">
+                            <li id="button_upgrade_firmware" class="modal-trigger" href="#firmware_upgrade_modal">
                                 <span class="translatable_upgrade_firmware">固件升级</span>
                                 <span class="translatable_upgrade_firmware">固件升级</span>
                             </li>
                             </li>
                             <li id="button_connection_type" style="display: none;">
                             <li id="button_connection_type" style="display: none;">
@@ -323,10 +324,10 @@
                             <i id="down" class="down"
                             <i id="down" class="down"
                                 style="position: relative;top: -20px;float: right;right: 9px;"></i>
                                 style="position: relative;top: -20px;float: right;right: 9px;"></i>
                             <div class="downbox MouduleBox" id="downboxModule" style="top: 64px;">
                             <div class="downbox MouduleBox" id="downboxModule" style="top: 64px;">
-                                <div style="border: none;"><a href="javaScript:(0)"
-                                        class="translatable_ai_module">A.I. Module</a></div>
-                                <div style="border: none;"><a href="javaScript:(0)"
-                                        class="translatable_iot_module">IoT Module
+                                <div style="border: none;"><a href="javaScript:(0)" class="translatable_ai_module">A.I.
+                                        Module</a></div>
+                                <div style="border: none;"><a href="javaScript:(0)" class="translatable_iot_module">IoT
+                                        Module
                                         Mode</a></div>
                                         Mode</a></div>
 
 
                                 <div style="border: none;"><a id="python_full_screen"
                                 <div style="border: none;"><a id="python_full_screen"
@@ -692,7 +693,7 @@
 
 
                     <li id="sketch_name-li" style="position: absolute;right: 135px;">
                     <li id="sketch_name-li" style="position: absolute;right: 135px;">
                         <input id="sketch_name" placeholder="请输入作品名称" class="sketch_name"
                         <input id="sketch_name" placeholder="请输入作品名称" class="sketch_name"
-                            style="background: #fff;padding: 4px 10px 4px 7px;color:#222222;width:200px;font-style: initial;line-height: 30px; font-size: 15px;"
+                            style="background: #fff;padding: 4px 10px 4px 7px;color:#222222;width:200px;font-style: initial;line-height: 30px; font-size: 14px;"
                             type="text">
                             type="text">
                     </li>
                     </li>
 
 
@@ -907,12 +908,14 @@
                                         data-clipboard-action="copy">
                                         data-clipboard-action="copy">
                                         <img id="copy_code_view" src="./images/icon-view.svg" style="margin-top:7px;">
                                         <img id="copy_code_view" src="./images/icon-view.svg" style="margin-top:7px;">
                                     </a>
                                     </a>
-                                    <a class="blockpy-toolbar-download" style="position:absolute;top: 5px;right:
+                                    <a class="blockpy-toolbar-download" class='modal-trigger'
+                                        href="#donload_file_cocorobo" style="position:absolute;top: 5px;right:
                                     59px;"> <img id="blockpy-toolbar-download" src="./images/icon-download.svg"
                                     59px;"> <img id="blockpy-toolbar-download" src="./images/icon-download.svg"
                                             style="margin-top: 7px;">
                                             style="margin-top: 7px;">
                                     </a>
                                     </a>
-                                    <a class="blockpy-toolbar-upload modal-trigger" style="position:absolute;top: 5px;right: 25px;" href="#cloud_storage_name_modal">
-                                        <img id="blockpy-toolbar-upload" src="./images/icon-upload.svg"
+                                    <a class="blockpy-toolbar-upload" style="position:absolute;top: 5px;right: 25px;">
+                                        <img id="blockpy-toolbar-upload" class="modal-trigger"
+                                            href="#cloud_storage_name_modal" src="./images/icon-upload.svg"
                                             style="margin-top: 7px;"> </a>
                                             style="margin-top: 7px;"> </a>
                                     <img class="fullscreenIcon hidden" src="./images/icon-fullscreen.svg">
                                     <img class="fullscreenIcon hidden" src="./images/icon-fullscreen.svg">
                                     <img class="fullscreenIcon hidden" src="./images/icon-fullscreen-exit.svg">
                                     <img class="fullscreenIcon hidden" src="./images/icon-fullscreen-exit.svg">
@@ -2823,16 +2826,53 @@
             <h4 class="cloudStorage translatable_cloudStorageTitle">Cloud Storage</h4>
             <h4 class="cloudStorage translatable_cloudStorageTitle">Cloud Storage</h4>
             <!-- <div id="cloud_askLogin"></div> -->
             <!-- <div id="cloud_askLogin"></div> -->
             <div class="cloud_fileName">
             <div class="cloud_fileName">
-                <div class="translatable_project_name" style="font-size: 16px;color: #3D3D3D;letter-spacing: 0;margin-top: 15px;margin-left: 25px;">作品名称</div>
+                <div class="translatable_project_name"
+                    style="font-size: 16px;color: #3D3D3D;letter-spacing: 0;margin-top: 15px;margin-left: 25px;">作品名称
+                </div>
                 <div style="text-align: center;margin-top: 15px;">
                 <div style="text-align: center;margin-top: 15px;">
-                    <input id="cloud_input" type="text" placeholder="名称"/>
+                    <input id="cloud_input" type="text" placeholder="名称" />
                 </div>
                 </div>
                 <div style="margin-top: 20px;text-align: center;">
                 <div style="margin-top: 20px;text-align: center;">
-                    <button id="confirm_btn" type="button" style="cursor: pointer;background: #4A6AFF;border-radius: 3px;width: 90px;line-height: 36px;border: none;margin-right: 30px;">
-                        <span class="translatable_cofirm_btn" style="font-size: 14px;color: #FFFFFF;letter-spacing: 0;">确 定</span>
+                    <button id="confirm_btn" type="button"
+                        style="cursor: pointer;background: #4A6AFF;border-radius: 3px;width: 90px;line-height: 36px;border: none;margin-right: 30px;">
+                        <span class="translatable_cofirm_btn"
+                            style="font-size: 14px;color: #FFFFFF;letter-spacing: 0;">确 定</span>
                     </button>
                     </button>
-                    <button id="cancel_btn" class="cancelBtn" type="button" style="cursor: pointer;border-radius: 3px;width: 90px;line-height: 36px;border: 1px solid #CCCCCC;">
-                        <span class="translatable_cancel_btn" style="font-size: 14px;color:#888888;letter-spacing: 0;">取 消</span>
+                    <button id="cancel_btn" class="cancelBtn" type="button"
+                        style="cursor: pointer;border-radius: 3px;width: 90px;line-height: 36px;border: 1px solid #CCCCCC;">
+                        <span class="translatable_cancel_btn" style="font-size: 14px;color:#888888;letter-spacing: 0;">取
+                            消</span>
+                    </button>
+                </div>
+            </div>
+        </div>
+    </div>
+
+
+    <div id="donload_file_cocorobo" class="modal modal_closes donload_file_cocorobo">
+        <div class="modal-content" style="padding: 0;">
+            <span class="modal_close" style="padding: 15px;">
+                <i class="small material-icons" style="font-size: 1.5rem;">close</i>
+            </span>
+            <h4 class="cloudStorage translatable_cloudStorageTitle">Cloud Storage</h4>
+            <!-- <div id="cloud_askLogin"></div> -->
+            <div class="cloud_fileName">
+                <div class="translatable_project_name"
+                    style="font-size: 16px;color: #3D3D3D;letter-spacing: 0;margin-top: 15px;margin-left: 25px;">作品名称
+                </div>
+                <div style="text-align: center;margin-top: 15px;">
+                    <input id="donload_file_cloud_input" type="text" placeholder="名称" />
+                </div>
+                <div style="margin-top: 20px;text-align: center;">
+                    <button id="donload_file_confirm_btn" type="button"
+                        style="cursor: pointer;background: #4A6AFF;border-radius: 3px;width: 90px;line-height: 36px;border: none;margin-right: 30px;">
+                        <span class="translatable_cofirm_btn"
+                            style="font-size: 14px;color: #FFFFFF;letter-spacing: 0;">确 定</span>
+                    </button>
+                    <button id="donload_file_cancel_btn" class="cancelBtn" type="button"
+                        style="cursor: pointer;border-radius: 3px;width: 90px;line-height: 36px;border: 1px solid #CCCCCC;">
+                        <span class="translatable_cancel_btn" style="font-size: 14px;color:#888888;letter-spacing: 0;">取
+                            消</span>
                     </button>
                     </button>
                 </div>
                 </div>
             </div>
             </div>
@@ -2848,26 +2888,34 @@
                 <div style="text-align: center;">
                 <div style="text-align: center;">
                     <div class="firmware_module" style="margin-right: 20%;">
                     <div class="firmware_module" style="margin-right: 20%;">
                         <div style="display: table;width: 126px;height: 126px;">
                         <div style="display: table;width: 126px;height: 126px;">
-                            <div class="firmware_module_ai"><div class="translatable_ai_module_a">AI 模块</div>V1.0</div>
+                            <div class="firmware_module_ai">
+                                <div class="translatable_ai_module_a">AI 模块</div>V1.0
+                            </div>
                         </div>
                         </div>
                     </div>
                     </div>
                     <div class="firmware_module">
                     <div class="firmware_module">
                         <div style="display: table;width: 126px;height: 126px;">
                         <div style="display: table;width: 126px;height: 126px;">
-                            <div class="firmware_module_iot"><div class="translatable_iot_module_a">IOT 模块</div>V0.2</div>
+                            <div class="firmware_module_iot">
+                                <div class="translatable_iot_module_a">IOT 模块</div>V0.2
+                            </div>
                         </div>
                         </div>
                     </div>
                     </div>
                 </div>
                 </div>
                 <div style="text-align: center;">
                 <div style="text-align: center;">
                     <div class="firmware_module_download" style="margin-right: 20%;">
                     <div class="firmware_module_download" style="margin-right: 20%;">
                         <div style="display: table;">
                         <div style="display: table;">
-                            <button style="cursor: pointer;background: #4A6AFF;border-radius: 3px;width: 130px;line-height: 36px;border: none;" onclick='openUrl("./firmware/ai-module_firmware_2020-10-14.rar")'>
+                            <button
+                                style="cursor: pointer;background: #4A6AFF;border-radius: 3px;width: 130px;line-height: 36px;border: none;"
+                                onclick='openUrl("./firmware/ai-module_firmware_2020-10-14.rar")'>
                                 <span class="button_text translatable_button_text">下载固件升级包</span>
                                 <span class="button_text translatable_button_text">下载固件升级包</span>
                             </button>
                             </button>
                         </div>
                         </div>
                     </div>
                     </div>
                     <div class="firmware_module_download">
                     <div class="firmware_module_download">
                         <div style="display: table;">
                         <div style="display: table;">
-                            <button style="cursor: pointer;background: #4A6AFF;border-radius: 3px;width: 130px;line-height: 36px;border: none;" onclick='openUrl("./firmware/mcu-module_firmware_2020-9-21_STABLE.bin")'>
+                            <button
+                                style="cursor: pointer;background: #4A6AFF;border-radius: 3px;width: 130px;line-height: 36px;border: none;"
+                                onclick='openUrl("./firmware/mcu-module_firmware_2020-9-21_STABLE.bin")'>
                                 <span class="button_text translatable_button_text">下载固件升级包</span>
                                 <span class="button_text translatable_button_text">下载固件升级包</span>
                             </button>
                             </button>
                         </div>
                         </div>

+ 20 - 4
index.js

@@ -331,12 +331,16 @@ window.onload = function () {
 
 
   if (window.location.search.indexOf("en") > -1) {
   if (window.location.search.indexOf("en") > -1) {
     $("#cloud_input").attr("placeholder", "name");
     $("#cloud_input").attr("placeholder", "name");
+    $("#donload_file_cloud_input").attr("placeholder", "name");
+
   }
   }
   else if (window.location.search.indexOf("zh-hans") > -1) {
   else if (window.location.search.indexOf("zh-hans") > -1) {
     $("#cloud_input").attr("placeholder", "名称");
     $("#cloud_input").attr("placeholder", "名称");
+    $("#donload_file_cloud_input").attr("placeholder", "名称");
   }
   }
   else {
   else {
     $("#cloud_input").attr("placeholder", "名稱");
     $("#cloud_input").attr("placeholder", "名稱");
+    $("#donload_file_cloud_input").attr("placeholder", "名稱");
   }
   }
 
 
   $('.dropdown-trigger').dropdown();
   $('.dropdown-trigger').dropdown();
@@ -381,9 +385,9 @@ window.onload = function () {
     cocoblockly();
     cocoblockly();
   }, 0);
   }, 0);
   $('.blockpy-toolbar-download').on(
   $('.blockpy-toolbar-download').on(
-    "click", () => export_data(
-      pythonnewcode || Blockly.Python.workspaceToCode(blockpy.components.editor.blockly) || blockpy.components.editor.codeMirror.getValue(), '.py', 0
-    )
+    "click", () =>
+    $("#button_save").click()
+    //  export_data(pythonnewcode || Blockly.Python.workspaceToCode(blockpy.components.editor.blockly) || blockpy.components.editor.codeMirror.getValue(), '.py', 0)
   );
   );
   $('.blockpy-toolbar-edit').click(e => $('#toggle-button').click());
   $('.blockpy-toolbar-edit').click(e => $('#toggle-button').click());
   const uploadXmlButton = $('#pyFileImport > input');
   const uploadXmlButton = $('#pyFileImport > input');
@@ -484,18 +488,30 @@ window.onload = function () {
   });
   });
 
 
   $("#confirm_btn").click(() => {
   $("#confirm_btn").click(() => {
+
     var _xml = blockpy.components.editor.getBlocksFromXml();
     var _xml = blockpy.components.editor.getBlocksFromXml();
     _xml.setAttribute("type", $("#mode")[0].selectedIndex == 1 ? "AI" : "IoT")
     _xml.setAttribute("type", $("#mode")[0].selectedIndex == 1 ? "AI" : "IoT")
     var code = Blockly.Xml.domToPrettyText(_xml);
     var code = Blockly.Xml.domToPrettyText(_xml);
-
     //var code = Ardublockly.generateXml();
     //var code = Ardublockly.generateXml();
     var title = $("#cloud_input").val() != '' ? $("#cloud_input").val() : '未命名';
     var title = $("#cloud_input").val() != '' ? $("#cloud_input").val() : '未命名';
     savelxfile(title, code, showSaveToast);
     savelxfile(title, code, showSaveToast);
+
   });
   });
 
 
   $("#cancel_btn").click(() => {
   $("#cancel_btn").click(() => {
     $("#cloud_storage_name_modal").modal("close");
     $("#cloud_storage_name_modal").modal("close");
   });
   });
+
+  $("#donload_file_confirm_btn").click(() => {
+    var title = $("#donload_file_cloud_input").val() != '' ? $("#donload_file_cloud_input").val() : '未命名';
+    downloadXml(title);
+    $("#donload_file_cocorobo").modal("close");
+  });
+
+  $("#donload_file_cancel_btn").click(() => {
+    $("#donload_file_cocorobo").modal("close");
+  });
+
 }
 }
 
 
 function styled() {
 function styled() {

+ 7 - 7
src/blockly/ardublockly.js

@@ -438,10 +438,10 @@ Ardublockly.alertMessage = function (title, body, confirm, callback) {
     });
     });
 };
 };
 
 
-Ardublockly.alertExampleMessage = function (title, body, confirm, callback) {	
+Ardublockly.alertExampleMessage = function (title, body, confirm, callback) {
     Ardublockly.exampleAlert(title, body, confirm, function () {
     Ardublockly.exampleAlert(title, body, confirm, function () {
 
 
-    });	
+    });
 };
 };
 
 
 Ardublockly.customAlertMessage = function (title, body, customText, callback) {
 Ardublockly.customAlertMessage = function (title, body, customText, callback) {
@@ -589,12 +589,12 @@ Ardublockly.FileReaderLocal = function (xmlFile) {
             Ardublockly.alertExampleMessage(
             Ardublockly.alertExampleMessage(
                 '',
                 '',
                 Ardublockly.getLocalStr('loadBlockBody'),
                 Ardublockly.getLocalStr('loadBlockBody'),
-                true,{});
+                true, {});
         } else {
         } else {
             Ardublockly.alertExampleMessage(
             Ardublockly.alertExampleMessage(
                 '',
                 '',
                 Ardublockly.getLocalStr('loadBlockBody'),
                 Ardublockly.getLocalStr('loadBlockBody'),
-                true,{});
+                true, {});
         }
         }
         var result_xml = reader.result;
         var result_xml = reader.result;
         try {
         try {
@@ -621,7 +621,7 @@ Ardublockly.FileReaderLocal = function (xmlFile) {
     };
     };
     reader.readAsText(xmlFile);
     reader.readAsText(xmlFile);
     setTimeout(() => {
     setTimeout(() => {
-        $('#loading').css({'display':'none'});
+        $('#loading').css({ 'display': 'none' });
         $('#example_alert').modal('close');
         $('#example_alert').modal('close');
     }, 500)
     }, 500)
 }
 }
@@ -672,11 +672,11 @@ Blockly.asyncSvgResize = function (a) {
  * Save blocks as XML file. Note that MSIE 11 does not support
  * Save blocks as XML file. Note that MSIE 11 does not support
  * @param {String} filename 
  * @param {String} filename 
 */
 */
-function downloadXml() {
+function downloadXml(name) {
     var _xml = blockpy.components.editor.getBlocksFromXml();
     var _xml = blockpy.components.editor.getBlocksFromXml();
     _xml.setAttribute("type", $("#mode")[0].selectedIndex == 1 ? "AI" : "IoT")
     _xml.setAttribute("type", $("#mode")[0].selectedIndex == 1 ? "AI" : "IoT")
     var data = Blockly.Xml.domToPrettyText(_xml);
     var data = Blockly.Xml.domToPrettyText(_xml);
-    let filename = $('#sketch_name').val();
+    let filename = name || $('#sketch_name').val();
     // Make safe
     // Make safe
     filename = filename.replace(/[^a-z0-9]/gi, '_').toLowerCase();
     filename = filename.replace(/[^a-z0-9]/gi, '_').toLowerCase();
     filename = filename + '.xml'
     filename = filename + '.xml'

+ 2 - 2
src/toolbar.js

@@ -211,8 +211,8 @@ BlockPyToolbar.prototype.activateToolbar = function () {
     var downloadButton = this.tag.find('.blockpy-toolbar-download');
     var downloadButton = this.tag.find('.blockpy-toolbar-download');
     downloadButton.click(downloadCode);
     downloadButton.click(downloadCode);
 
 
-    $('#button_save').click(downloadXml);
-    $('#side_button_save').click(downloadXml);
+    // $('#button_save').click(downloadXml);
+    // $('#side_button_save').click(downloadXml);
 
 
     this.tag.find('.blockpy-toolbar-filename-picker label').click(function () {
     this.tag.find('.blockpy-toolbar-filename-picker label').click(function () {
         main.model.settings.filename($(this).data('filename'))
         main.model.settings.filename($(this).data('filename'))