chao 1 kuukausi sitten
vanhempi
commit
85f3085f42
5 muutettua tiedostoa jossa 372 lisäystä ja 329 poistoa
  1. 61 0
      getToken.js
  2. BIN
      icons/logo1.png
  3. 10 44
      index.html
  4. 33 47
      index.js
  5. 268 238
      src/blockly/account.js

+ 61 - 0
getToken.js

@@ -0,0 +1,61 @@
+class Auth {
+    static _getKey() {
+        return '__DEEP_RACER_TOKEN';
+    }
+
+    static _eventList = [];
+
+    static get() {
+        const res = localStorage.getItem(this._getKey());
+        if (res) {
+            try {
+                return JSON.parse(res);
+            } catch {
+                return null;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 默认是追加数据,这样方便设置 schoolId
+     */
+    static set(auth, append = true) {
+        let value = append ? this.get() : auth;
+
+        if (append) {
+            if (value) {
+                value = {
+                    ...value,
+                    ...auth,
+                };
+            } else {
+                value = auth;
+            }
+        }
+
+        localStorage.setItem(this._getKey(), JSON.stringify(value));
+
+        for (const callback of this._eventList) {
+            callback(value);
+        }
+    }
+
+    static remove() {
+        localStorage.removeItem(this._getKey());
+        for (const callback of this._eventList) {
+            callback(null);
+        }
+    }
+
+    static addListener(callback) {
+        this._eventList.push(callback);
+        window.addEventListener('storage', (e) => {
+            if (e.key === this._getKey()) {
+                callback(e.newValue ? JSON.parse(e.newValue) : null);
+            }
+        });
+    }
+}
+
+window.Auth = Auth;

BIN
icons/logo1.png


+ 10 - 44
index.html

@@ -156,6 +156,7 @@
     <script type="text/javaScript" src="src/webble.js"></script>
     <script type="text/javascript" src="./JSZip.js"></script>
     <script type="text/javascript" src="./crc32.js"></script>
+    <script type="text/javaScript" src="./getToken.js"></script>
 </head>
 
 <body>
@@ -176,8 +177,8 @@
             <div class="nav-wrapper"
                 style="min-width: 1200px; padding:0px 10px;display: flex;justify-content: space-between;position:static;">
                 <ul id="nav-mobile" class="" style="display: inline-block;">
-                    <li style="font-size: 30px;" class="nav_logo">
-                        <!-- <img style="height: 40px;margin-top: 10px;" class="left nav-icon" src="./icons/logo1.png"> -->
+                    <li style="height:100%;background: linear-gradient(to right,#0060D3,#FFFFFF);" class="nav_logo">
+                        <img style="height:99%;margin-top: 0;margin-right: 0;" class="left nav-icon" src="./icons/logo1.png">
                     </li>
                     <li>
                         <!-- <span class="vertical-separator"></span> -->
@@ -193,39 +194,17 @@
                         <button id="downloadbutton" class="translatable_sketch_save"
                             style="color: #2c4fcd;font-weight: 700;border-radius: 30px;background: #fff;border: none;margin: 0 0 0 15px;font-size: 14px;padding: 8px 14px;">Save</button>
                     </li>
-                    <li id="cloudBtn-shares">
+                    <!-- <li id="cloudBtn-shares">
                         <i class="material-icons" style="margin-left:5px;cursor: pointer;">share</i>
-                    </li>
+                    </li> -->
                     <i id="workspace_screenshot" class="material-icons sketch_name_icon right"
                         style="margin-left:5px;cursor: pointer;">photo_camera</i>
                     <i id="button_delete" class="material-icons sketch_name_icon right"
                         style="margin-left:5px;cursor: pointer;">delete</i>
                 </ul>
-                <!-- <i id="workspace_screenshot" class="material-icons sketch_name_icon right"
-                    style="margin-left:5px;cursor: pointer;">photo_camera</i> -->
-                <!-- <i class="material-icons sketch_name_icon right">create</i> -->
-                <!-- <input id="sketch_name" class="sketch_name" type="text"> -->
                 <input id="sketch_name_w" class="sketch_name" type="text" name="wifi" style="display:none">
                 </span>
-                <!-- </a> -->
-                <!-- Horizontal Navbar links only shown on large resolutions -->
                 <ul id="nav-mobile" class="right nav-mobile-right" style="display: flex;">
-                    <!-- AI Demo -->
-                    <!-- <li>
-                    <a id="AI_experience" class='dropdown-button lang_resize' data-activates='AI_experience_dropdown' style="position:relative">
-                        <span class="translatable_AI_experience">AI</span>
-                        <img class="left nav-icon" src="./icons/nav-ai-experience.png">
-                    </a>
-                    <ul id='AI_experience_dropdown' class='dropdown-content' style="top:62px">
-                        <li id="webcam" class='modal-trigger' href="#webcam_capture_modal">
-                            <span class="translatable_AI_emotion">Emotion Recognotion</span>
-                        </li>
-                        <li class="divider"></li>
-                        <li id="voice-input" class='modal-trigger' href="#voice_input_modal">
-                            <span class="translatable_AI_speech">Speech Recognotion</span>
-                        </li>
-                    </ul>
-                </li> -->
                     <!-- help button -->
                     <li style="display: none;">
                         <a id="help" style="display:none" class='dropdown-button lang_resize'
@@ -240,18 +219,7 @@
                                     <span class="translatable_tutorial">Tutorial</span>
                                 </a>
                             </li>
-                            <!-- <li class="divider"></li>
-                        <li>
-                            <a href="#tourmode" class="modal-trigger">
-                                <span class="translatable_tour">Start Tour</span>
-                            </a>
-                        </li> -->
                             <li class="divider"></li>
-                            <!-- <li>
-                                <a href="#env_detect" class="modal-trigger">
-                                    <span class="translatable_env_detect">Environment Detect</span>
-                                </a>
-                            </li> -->
                             <li class="divider"></li>
                             <li>
                                 <a href="http://help.cocorobo.cn/#/changelog" target="_blank">
@@ -623,7 +591,7 @@
                         </a> -->
                     </li>
                     <!-- App Center demo -->
-                    <li>
+                    <!-- <li>
                         <a id="app_center_title" href="#app_center_modal" class="modal-trigger lang_resize"
                             style="position:relative">
                             <span id="app_center_title_demo">
@@ -631,7 +599,7 @@
                                 <img class="left nav-icon" src="./icons/cocoblockly-navbar_labs-icon.png">
                             </span>
                         </a>
-                    </li>
+                    </li> -->
                     <li>
                         <a id="nav_learn" class='dropdown-button lang_resize' data-activates="learn_board"
                             style="position:relative">
@@ -773,13 +741,11 @@
                         <span class="vertical-separator"></span>
                     </li> -->
                     <li>
-                        <a id="nav_account" href="#login_modal" class="modal-trigger lang_resize"
-                            style="position:relative"
-                            onclick="$('#api-key').html(''); $('#api-key').html($('#cloud_events').val()); document.getElementById('api-key').value = $('#cloud_events').val();">
+                        <a id="nav_account" class="modal-trigger lang_resize"
+                            style="position:relative">
                             <span id="account_alias"></span>
                             <button id="account_loginTitle" class="translatable_login_title"
                                 style="color: #fff;font-weight: 500;width: 80px;height: 35px;border-radius: 30px;background: #fff0;border: 2px solid #fff;margin: 0 0 0 15px;">Login</button>
-                            <!-- <span id="account_loginTitle" class="translatable_login_title">Login</span> -->
                             <img class="nav-icon2 left" src="./icons/user.png">
                         </a>
                     </li>
@@ -819,7 +785,7 @@
                             </div>
                         </div>
                         <p id="left_move_right"></p>
-                        <div id='sss' style="display:block;overflow: hidden;width: 35%;min-width: 510px;">
+                        <div id='sss' style="display:block;overflow: hidden;width: 35%;min-width: 510px;height: calc(100vh - 64px);">
                             <span onclick="mobileSwitchMode('python')"
                                 class="mobileSwitch btn translatable_hardware_mode" style="display: none;">积木模式</span>
                             <div id="py-editor" class="blockpy-editor card-panel" style="position: relative;">

+ 33 - 47
index.js

@@ -1,3 +1,4 @@
+
 function initLanguage(langKey) {
   let defaultLang = 'en';
   let lang = langKey || defaultLang;
@@ -154,54 +155,10 @@ function clearBlocks(cb = () => { }) {
 }
 
 function addLibButton(lang) {
-  // const addLib = document.createElement("button");
-  // addLib.className = "waves-effect waves-light btn blue";
-  // let content = lang === 'zh-hans' ? "添加库" : lang === 'zh-hant' ? "添加庫" : "Add Library";
-  // addLib.textContent = content;
-  // addLib.style = `
-  //   position: absolute;
-  //   width: 88%;
-  //   bottom: 10px;
-  //   left: 50%;
-  //   transform: translateX(-50%);
-  // `;
-  // $(addLib).click(e =>
-  //   blockpy.components.dialog.show("Add Library", document.createElement("div")));
-  // $(".blocklyToolboxDiv").append(addLib);
 }
 
-// /**
-//  * Save blocks into local storage. Note that MSIE 11 does not support
-//  * LocalStorage on file:// URLs.
-//  */
-// function saveLocalStorageBlocks() {
-//   if (window.sessionStorage) {
-//     var xml = blockpy.components.editor.getBlocksFromXml();
-//     var text = Blockly.Xml.domToText(xml);
-//     localStorage.setItem("blocks", text);
-//   }
-//   // blockpy.components.editor.getBlocksFromXml()
-// };
-// /** Load blocks saved on loacl storage and deletes them from storage. */
-// function loadLocalStorageBlocks() {
-//   // try {
-//   //     var loadOnce = window.localStorage.loadOnceBlocks;
-//   // } catch (e) {
-//   //     // Firefox sometimes throws a SecurityError when accessing sessionStorage.
-//   //     // Restarting Firefox fixes this, so it looks like a bug.
-//   //     var loadOnce = null;
-//   // }
-//   var loadBlocks = localStorage.getItem("blocks");
-//   if (loadBlocks) {
-//     var xml = Blockly.Xml.textToDom(loadBlocks);
-//     blockpy.components.editor.setBlocksFromXml(xml);
-//     localStorage.removeItem('blocks')
-//   }
-// };
 
 var copyCodeClipboard;
-
-
 window.onbeforeunload = window.onunload = function () {
   if ($("#mode")[0].selectedIndex == 0) {
     saveLocalStorage("type", 1);
@@ -219,10 +176,39 @@ function getJsonData(filepath) {
 
 var isRunCodeData = '';
 var RunInterval = '';
-
+var token = '';
 window.onload = async function () {
   // stia 登录获取信息
-  console.log('window.onload', window.location.search)
+  const authInfo = Auth.get();
+  console.log('window.onload', authInfo)
+  token = authInfo ? authInfo.token : null;
+  var myHeaders = new Headers();
+  myHeaders.append("token", token);
+
+  var requestOptions = {
+    method: 'POST',
+    headers: myHeaders,
+    redirect: 'follow'
+  };
+  fetch("https://eduofai.com/api/coco/user/info", requestOptions)
+    .then(response => response.text())
+    .then(result => {
+      console.log(JSON.parse(result))
+      let data = JSON.parse(result)
+      // 保存用户信息
+      if(data.status == 200){
+        CCB.userState = true;
+        $("#account_alias")
+        .text(data.data.name)
+        .css({ "display": "inline-block", width: '80px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' });
+        $("#account_loginTitle")[0].style.display = "none"
+        // 登录成功获取保存云端数据
+        getCloudFileList()
+      }else if(data.status == 401){
+        window.location.href = 'https://eduofai.com/'
+      }
+    })
+    .catch(error => console.log('error', error));
   $("#copyright_middle")[0].innerText = new Date().getFullYear()
   var url = window.location.hash.substring(1);
   // if (url) {
@@ -599,7 +585,7 @@ window.onload = async function () {
       }
     }, 1000)
   }
-  
+
   updateContentFun()
 
   // $("#root").modal("open");

+ 268 - 238
src/blockly/account.js

@@ -20,7 +20,7 @@ function logout() {
       appendIframe("TM_posenet_login");
       $('#TM_posenet_login').children().css("height", "820px");
       appendIframe("before_login");
-      appendIframe("cloud_askLogin");
+      // appendIframe("cloud_askLogin");
       appendIframe("TM_login_Model_download_modal");
       $('#TM_login_Model_download_modal').children().css("height", "820px");
       $('#TM_login_Model_download_modal').children().css("margin-top", "-225px");
@@ -70,27 +70,36 @@ function getUserProfile(data) {
  * filelist {object}: a list of files name
  */
 function getCloudFileList() {
-  $.ajax(`${CCB.base_url}blockx/files`, {
-    type: "GET",
-    xhrFields: {
-      withCredentials: true
-    },
-    success: fileList => {
-      // console.log(fileList, 'getCloudFileList')
-      updateCloudFileList(fileList);
-      updateCloudFilePanel();
-      // openCloudFile(CCB.cloudFileList[i].filename); 打开文件
-      let arr = window.location.search.split('&')[1]
-      if (arr) {
-        fileList.map(x => {
-          if (x.filenameid == arr.split('=')[1]) {
-            openCloudFile(x.filename)
-          }
-          return x;
-        })
+  var myHeaders = new Headers();
+  console.log("getCloudFileList",token)
+  myHeaders.append("token", token);
+  myHeaders.append("Content-Type", "application/json");
+
+  var raw = JSON.stringify({
+    "page": 1,
+    "limit": 1000
+  });
+
+  var requestOptions = {
+    method: 'POST',
+    headers: myHeaders,
+    body: raw,
+    redirect: 'follow'
+  };
+
+  fetch("https://eduofai.com/api/coco/blocks/list", requestOptions)
+    .then(response => response.text())
+    .then(result => {
+      let data = JSON.parse(result);
+      console.log("list", data)
+      if (data.status == 200) {
+        loginModalStatus();
+        updateCloudFileList(data.data.blocks)
+        updateCloudFilePanel()
       }
     }
-  });
+    )
+    .catch(error => console.log('error', error));
 }
 
 /**
@@ -129,39 +138,46 @@ function updateCloudFile(filename, type) {
  */
 function createCloudFile(filename) {
   var _tp = window.location.pathname.indexOf("/python") == 0
-  $.ajax(`${CCB.base_url}blockx/`, {
-    type: "POST",
-    xhrFields: {
-      withCredentials: true
-    },
-    data: {
-      type: _tp ? "py" : "",
-      filename: filename,
-      xml: _tp ? blockpy.components.editor.codeMirror.getValue() : Ardublockly.generateXml()
-    },
-    beforeSend: () => { $("#cloud_modal_preload").css("display", "block") },
-    success: (res) => {
-      $("#cloud_modal_preload").css("display", "none");
-      console.log(res)
-      Materialize.toast(CCB.str_group.success_uploadFile, 4000);
-      let fileobject = {
-        filenameId: res.filename,
-        filename: filename,
-        time: getCurrentDate(),
-        type: _tp ? "py" : "",
-        timestamp: (new Date()).valueOf()
-      };
-      CCB.cloudFileList.push(fileobject);
-      CCB.selectCloudFile = filename;
-      relistCloudFile(filename);
-      updateCloudFilePanel();
-      cloudFileState("over", 0);
-    },
-    error: () => {
-      $("#cloud_modal_preload").css("display", "none");
-      Materialize.toast(CCB.str_group.error_uploadFile, 4000);
+  var myHeaders = new Headers();
+  myHeaders.append("token", token);
+  myHeaders.append("Content-Type", "application/json");
+  var raw = JSON.stringify({
+    "block": {
+      "name": filename,
+      "xml": Ardublockly.generateXml()
     }
   });
+
+  var requestOptions = {
+    method: 'POST',
+    headers: myHeaders,
+    body: raw,
+    redirect: 'follow'
+  };
+
+  fetch("https://eduofai.com/api/coco/blocks/save", requestOptions)
+    .then(response => response.text())
+    .then(result => {
+      let data = JSON.parse(result);
+      if (data.status == 200) {
+        Materialize.toast(CCB.str_group.success_uploadFile, 4000);
+        let fileobject = {
+          filenameId: data.data.id,
+          filename: filename,
+          time: getCurrentDate(),
+        };
+        CCB.cloudFileList.push(fileobject);
+        CCB.selectCloudFile = filename;
+        relistCloudFile(filename);
+        updateCloudFilePanel();
+        cloudFileState("over", 0);
+        $("#cloud_modal_preload").css("display", "none")
+      }
+    })
+    .catch(error => {
+      $("#cloud_modal_preload").css("display", "none");
+      Materialize.toast(CCB.str_group.error_uploadFile, 4000);
+    });
 }
 
 /**
@@ -169,64 +185,91 @@ function createCloudFile(filename) {
  * @param {String} filename : the name of file
  */
 function openCloudFile(filename) {
-  $.ajax(`${CCB.base_url}blockx/${filename}`, {
-    type: "GET",
-    xhrFields: {
-      withCredentials: true
-    },
-    before: () => { $("#cloud_modal_preload").css("display", "block") },
-    success: data => {
-      var file = data.xml;
-      var date = data.date;
-      Materialize.toast(CCB.str_group.success_downloadFile, 4000);
-      if (data.type == "py") {
-        blockpy.components.editor.codeMirror.setValue(file);
-      }
-      else {
-        loadCloudXmlFile(file, filename);
+  var myHeaders = new Headers();
+  myHeaders.append("token", token);
+  myHeaders.append("Content-Type", "application/json");
+
+  var raw = JSON.stringify({
+    "name": filename
+  });
+
+  var requestOptions = {
+    method: 'POST',
+    headers: myHeaders,
+    body: raw,
+    redirect: 'follow'
+  };
+
+  fetch("https://eduofai.com/api/coco/blocks/get_by_name", requestOptions)
+    .then(response => response.text())
+    .then(result => {
+      let data = JSON.parse(result);
+      if (data.status == 200) {
+        var file = data.data.block.xml;
+        Materialize.toast(CCB.str_group.success_downloadFile, 4000);
+        if (data.data.type == "py") {
+          blockpy.components.editor.codeMirror.setValue(file);
+        }
+        else {
+          loadCloudXmlFile(file, filename);
+        }
+        $("#cloud_storage_modal").modal("close");
+        $("#cloud_modal_preload").css("display", "none");
+        let i = indexGet(filename, CCB.cloudFileList);
+        CCB.selectCloudFile = filename;
+        relistCloudFile(filename);
+        cloudFileState("over", i);
+        updateCloudFilePanel();
       }
-      $("#cloud_storage_modal").modal("close");
-      $("#cloud_modal_preload").css("display", "none");
-      let i = indexGet(filename, CCB.cloudFileList);
-      CCB.selectCloudFile = filename;
-      relistCloudFile(filename);
-      updateCloudFilePanel();
-    },
-    error: () => {
+    })
+    .catch(error => {
       $("#cloud_modal_preload").css("display", "none");
       Materialize.toast(CCB.str_group.error_downloadFile, 4000);
-    }
-  });
+    });
 }
 
 /**
  * AJAX to delete file in the cloud
  * @param {String} filename : the name of file
  */
-function deleteCloudFile(filename) {
-  $.ajax(`${CCB.base_url}blockx/${filename}`, {
-    type: "DELETE",
-    xhrFields: {
-      withCredentials: true
-    },
-    beforeSend: () => { $("#cloud_modal_preload").css("display", "block") },
-    success: () => {
-      $("#cloud_modal_preload").css("display", "none");
-      Materialize.toast(CCB.str_group.success_deleteFile, 4000);
-      let i = indexGet(filename, CCB.cloudFileList);
-      CCB.cloudFileList.splice(i, 1);
-      if (CCB.selectCloudFile == filename) {
-        CCB.selectCloudFile = null;
+function deleteCloudFile(id) {
+  var myHeaders = new Headers();
+  myHeaders.append("token", token);
+  myHeaders.append("Content-Type", "application/json");
+
+  var raw = JSON.stringify({
+    "id": id
+  });
+
+  var requestOptions = {
+    method: 'POST',
+    headers: myHeaders,
+    body: raw,
+    redirect: 'follow'
+  };
+
+  fetch("https://eduofai.com/api/coco/blocks/delete", requestOptions)
+    .then(response => response.text())
+    .then(result => {
+      let data = JSON.parse(result);
+      console.log("delete", data)
+      if (data.status == 200) {
+        Materialize.toast(CCB.str_group.success_deleteFile, 4000);
+        if (CCB.selectCloudFile == filename) {
+          CCB.selectCloudFile = null;
+        }
+        cloudFileState("over", i);
+        getCloudFileList()
+        updateCloudFilePanel();
+      } else {
+        $("#cloud_modal_preload").css("display", "none");
+        Materialize.toast(CCB.str_group.error_deleteFile, 4000);
       }
-      cloudFileState("over", i);
-      updateCloudFilePanel();
-    },
-    error: () => {
+    })
+    .catch(error => {
       $("#cloud_modal_preload").css("display", "none");
       Materialize.toast(CCB.str_group.error_deleteFile, 4000);
-    }
-  });
-
+    });
 }
 
 /**
@@ -252,7 +295,7 @@ function renameCloudFile(newName, oldName) {
 
       let i = indexGet(oldName, CCB.cloudFileList);
       CCB.cloudFileList[i].filename = newName;
-      CCB.cloudFileList[i].filenameId = CCB.cloudFileList[i].filenameId.split("_")[0]+"_"+newName
+      CCB.cloudFileList[i].filenameId = CCB.cloudFileList[i].filenameId.split("_")[0] + "_" + newName
       if (CCB.selectCloudFile == oldName) {
         CCB.selectCloudFile = newName;
       }
@@ -412,20 +455,15 @@ function updateCloudFileList(filelist) {
   var cloudlist = [];
   filelist.filter(val => {
     if (!val.type) {
-      var filename = val.filename;
-      var date = dateFormat(val.date);
-      var Timestamp = val.timestamp != null ? val.timestamp : 0;
+      var filename = val.name;
+      var date = val.create_time.slice(0, 10);
       cloudlist.push({
+        filenameId: val.id,
         filename: filename,
         time: date,
-        timestamp: Timestamp,
-        filenameId: val.filenameid
       });
     }
   });
-  cloudlist.sort((a, b) => {
-    return b.timestamp - a.timestamp
-  })
   CCB.cloudFileList = origin.concat(cloudlist.slice());
 }
 
@@ -492,11 +530,6 @@ function updateCloudFilePanel() {
         '" class="card "  onclick="fileOpen(' + i + ')">' +
         // * *
         '  <ul class="cloud-btnPanel">' +
-        '    <li style="float:left;" class="cloudBtn-share"><i class="material-icons" href="#share" onclick="fileShare(' + i + ')" >share</i></li>' +
-        // '    <li class="cloudBtn-open"><img src="./images/cloudfileopen.png" class="material-icons" style="width:22px;margin-right:6px;top:-1px;position:relative;cursor:pointer"></li>' +
-        // '    <li style="float:left;" class="unblock cloudBtn-update"><i class="material-icons" onclick="fileUpdate(' + i + ')">save</i></li>' +
-        '    <li class="cloudBtn-update"><i class="material-icons" onclick="fileUpdate(' + i + ')">save</i></li>' +
-        // '    <li class="cloudBtn-rename"><i class="material-icons" onclick="fileRename(' + i + ')">edit</i></li>' +
         '    <li class="cloudBtn-delete"><i class="material-icons" onclick="fileDelete(' + i + ')">delete</i></li>' +
         "  </ul>" +
         //icon option:  remove_red_eye , place , personal_video , nature, edit_location ,bookmark
@@ -506,7 +539,7 @@ function updateCloudFilePanel() {
         "  </div>" +
         '  <div class="card-content">' +
         '    <div id="cloud_info_panel' + i + '"class="cloudInfoPanel">' +
-        '      <span style="display:inline-block" id="cloud_name' + i + '" class="ac-card-title card-title grey-text text-darken-4 " title="' + CCB.cloudFileList[i].filename + (CCB.cloudFileList[i].type ? "." + CCB.cloudFileList[i].type : '.xml') + '">' + CCB.cloudFileList[i].filename + (CCB.cloudFileList[i].type ? "." + CCB.cloudFileList[i].type : '.xml') + "</span><i style='position: relative;top: -8px;' class='material-icons' onclick='fileRename(" + i + ")'>edit</i>" +
+        '      <span style="display:inline-block" id="cloud_name' + i + '" class="ac-card-title card-title grey-text text-darken-4 " title="' + CCB.cloudFileList[i].filename + (CCB.cloudFileList[i].type ? "." + CCB.cloudFileList[i].type : '.xml') + '">' + CCB.cloudFileList[i].filename + (CCB.cloudFileList[i].type ? "." + CCB.cloudFileList[i].type : '.xml') + "</span>" +
         "      <p>" + lastModified + '<span id="cloud_time' + i + '"> ' + CCB.cloudFileList[i].time + " </span>" +
         "      </p>" +
         "    </div>" +
@@ -556,7 +589,7 @@ function updateCloudFilePanel() {
  */
 function fileOpen(i) {
   $("#cloud_modal_preload").css("display", "block")
-  openCloudFile(CCB.cloudFileList[i].filenameId);
+  openCloudFile(CCB.cloudFileList[i].filename);
 }
 
 
@@ -659,7 +692,7 @@ function cancelRename(i) {
  * check the current filelist and launch a funciton to rename it
  */
 function confirmDelete(i) {
-  deleteCloudFile(CCB.cloudFileList[i].filename);
+  deleteCloudFile(CCB.cloudFileList[i].filenameId);
   stopPropagation()
 }
 
@@ -737,9 +770,9 @@ function cloudFileState(status, i) {
 function renameBoxSet(i) {
   var sketchOldName = $("#cloud_name" + i).html().replace(".xml", "");
   var sketchNameInput = $("#cloud_sketch_rename" + i);
-  document.getElementById("cloud_sketch_rename" + i).addEventListener("click",function(){
+  document.getElementById("cloud_sketch_rename" + i).addEventListener("click", function () {
     stopPropagation()
-  },true)
+  }, true)
   sketchNameInput.val(sketchOldName);
   sketchNameInput.attr("size", sketchOldName.length);
   sketchNameInput.keydown();
@@ -1096,130 +1129,127 @@ function appendTMIframePosenet(parentId, cb, url) {
 
 
 $(window).one("load", () => {
-  if (!CCB.asIframe) {
-    // $("#TM_iframe").load("https://cocorobo.cn/beta/ai-demos/teachable-machine/public/ #wrapper")
-    appendIframe("TM_login");
-    $('#TM_login').children().css("height", "820px");
-    appendIframe("TM_login_object");
-    $('#TM_login_object').children().css("height", "820px");
-    appendIframe("TM_login_posenet");
-    $('#TM_login_posenet').children().css("height", "820px");
-    appendIframe("TM_posenet_login");
-    $("#TM_posenet_login").children().css("height", "820px");
-    appendIframe("before_login");
-    appendIframe("cloud_askLogin");
-    appendIframe("TM_login_Model_download_modal");
-    $('#TM_login_Model_download_modal').children().css("height", "820px");
-    $('#TM_login_Model_download_modal').children().css("margin-top", "-225px");
-    appendIframe("TM_login_webcam_capture_modal");
-    $('#TM_login_webcam_capture_modal').children().css("width", "820px");
-    $('#TM_login_webcam_capture_modal').children().css("height", "820px");
-    appendIframe("TM_login_gesture_recog_modal");
-    $('#TM_login_gesture_recog_modal').children().css("width", "820px");
-    $('#TM_login_gesture_recog_modal').children().css("height", "820px");
-    appendIframe("TM_login_voice_input_modal");
-    $('#TM_login_voice_input_modal').children().css("width", "820px");
-    $('#TM_login_voice_input_modal').children().css("height", "820px");
-    appendIframe("TM_center_game");
-    $('#TM_center_game').children().css("margin-top", "-300px");
-    $('#TM_center_game').children().css("height", "820px");
-  }
-  // api.cocorobo.cn/blockx/filenameid
-  var _id = U.UF.C.queryString("id") || U.UF.C.queryString("Qd")
-  if (_id) {
-    $.ajax(`${CCB.base_url}blockx/${_id}`, {
-      type: "GET",
-      xhrFields: {
-        withCredentials: true
-      },
-      //data: { userId: CCB.UserInfo.data.username },
-      success: x => {
-        loadCloudXmlFile(x.xml, x.filename)
-      }
-    });
-  }
-  localStorage.setItem("modetype", "");
-  // addObserver("Teachable_Machine")
-  window.addEventListener("storage", function (event) {
-    if (event.key == "modetype" && isgetmcnty == false) {
-      if (event.newValue == "IoT") {
-        $('#status_bar').replaceWith(`<span id="status_bar"><span id="status_txt">${Ardublockly.LOCALISED_TEXT.statusbar}&nbsp&nbsp&nbsp&nbsp</span></span>`);
-        isgetmcnty = true;
-        $('#ports').material_select();
-        $("#mode")[0].selectedIndex = 0;
-        $("#mode")[0].onchange();
-        $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.iot_module;
-        document.getElementById("list").getElementsByTagName("li")[0].onclick();
-      }
-      else if (event.newValue == "AI") {
-        $('#status_bar').replaceWith(`<span id="status_bar"><span id="status_txt">${Ardublockly.LOCALISED_TEXT.statusbar}&nbsp&nbsp&nbsp&nbsp</span></span>`);
-        isgetmcnty = true;
-        $('#ports').material_select();
-        $("#mode")[0].selectedIndex = 1;
-        $("#mode")[0].onchange();
-        $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.ai_module;
-        document.getElementById("list").getElementsByTagName("li")[1].onclick();
-      }
-    }
-
-
-  });
-
-
-
+  // if (!CCB.asIframe) {
+  //   // $("#TM_iframe").load("https://cocorobo.cn/beta/ai-demos/teachable-machine/public/ #wrapper")
+  //   appendIframe("TM_login");
+  //   $('#TM_login').children().css("height", "820px");
+  //   appendIframe("TM_login_object");
+  //   $('#TM_login_object').children().css("height", "820px");
+  //   appendIframe("TM_login_posenet");
+  //   $('#TM_login_posenet').children().css("height", "820px");
+  //   appendIframe("TM_posenet_login");
+  //   $("#TM_posenet_login").children().css("height", "820px");
+  //   appendIframe("before_login");
+  //   // appendIframe("cloud_askLogin");
+  //   appendIframe("TM_login_Model_download_modal");
+  //   $('#TM_login_Model_download_modal').children().css("height", "820px");
+  //   $('#TM_login_Model_download_modal').children().css("margin-top", "-225px");
+  //   appendIframe("TM_login_webcam_capture_modal");
+  //   $('#TM_login_webcam_capture_modal').children().css("width", "820px");
+  //   $('#TM_login_webcam_capture_modal').children().css("height", "820px");
+  //   appendIframe("TM_login_gesture_recog_modal");
+  //   $('#TM_login_gesture_recog_modal').children().css("width", "820px");
+  //   $('#TM_login_gesture_recog_modal').children().css("height", "820px");
+  //   appendIframe("TM_login_voice_input_modal");
+  //   $('#TM_login_voice_input_modal').children().css("width", "820px");
+  //   $('#TM_login_voice_input_modal').children().css("height", "820px");
+  //   appendIframe("TM_center_game");
+  //   $('#TM_center_game').children().css("margin-top", "-300px");
+  //   $('#TM_center_game').children().css("height", "820px");
+  // }
+  // // api.cocorobo.cn/blockx/filenameid
+  // var _id = U.UF.C.queryString("id") || U.UF.C.queryString("Qd")
+  // if (_id) {
+  //   $.ajax(`${CCB.base_url}blockx/${_id}`, {
+  //     type: "GET",
+  //     xhrFields: {
+  //       withCredentials: true
+  //     },
+  //     //data: { userId: CCB.UserInfo.data.username },
+  //     success: x => {
+  //       loadCloudXmlFile(x.xml, x.filename)
+  //     }
+  //   });
+  // }
+  // localStorage.setItem("modetype", "");
+  // // addObserver("Teachable_Machine")
+  // window.addEventListener("storage", function (event) {
+  //   if (event.key == "modetype" && isgetmcnty == false) {
+  //     if (event.newValue == "IoT") {
+  //       $('#status_bar').replaceWith(`<span id="status_bar"><span id="status_txt">${Ardublockly.LOCALISED_TEXT.statusbar}&nbsp&nbsp&nbsp&nbsp</span></span>`);
+  //       isgetmcnty = true;
+  //       $('#ports').material_select();
+  //       $("#mode")[0].selectedIndex = 0;
+  //       $("#mode")[0].onchange();
+  //       $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.iot_module;
+  //       document.getElementById("list").getElementsByTagName("li")[0].onclick();
+  //     }
+  //     else if (event.newValue == "AI") {
+  //       $('#status_bar').replaceWith(`<span id="status_bar"><span id="status_txt">${Ardublockly.LOCALISED_TEXT.statusbar}&nbsp&nbsp&nbsp&nbsp</span></span>`);
+  //       isgetmcnty = true;
+  //       $('#ports').material_select();
+  //       $("#mode")[0].selectedIndex = 1;
+  //       $("#mode")[0].onchange();
+  //       $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.ai_module;
+  //       document.getElementById("list").getElementsByTagName("li")[1].onclick();
+  //     }
+  //   }
+
+
+  // });
 });
 
-window.addEventListener("message", e => {
-  let data = e.data;
-  if (!CCB.asIframe) {
-    if (typeof data === "object" && data.id === "loginVerify" && data.status === "logged") {
-      $("#TM_login").empty();
-      $("#TM_login_object").empty();
-      $("#TM_login_posenet").empty();
-      $("#TM_posenet_login").empty();
-      $("#before_login").empty();
-      $("#cloud_askLogin").empty();
-      $("#TM_login_Model_download_modal").empty();
-      $("#TM_login_webcam_capture_modal").empty();
-      $("#TM_login_gesture_recog_modal").empty();
-      $('#TM_login_voice_input_modal').empty();
-      if (CCB.downloadModelUrl != '' && CCB.downloadModelUrl != '//xunlian.cocorobo.cn') {
-        $("#center_game_modal").modal("close");
-        $("#app_center_modal").modal("open");
-      }
-      $("#TM_center_game").empty();
-      Materialize.toast(CCB.str_group.success_userLogin, 3000);
-      CCB.userState = true;
-      getUserProfile(data.data);
-      loginModalStatus();
-      getCloudFileList();
-      CCB.UserInfo = data;
-
-      /**
-      *post login session message into TM_iframe
-      */
-
-
-      let lang = 'en';
-      document.location.search.substring(1).split('&').forEach((item) => {
-        if (item.split('=')[0] == 'lang') {
-          lang = item.split('=')[1];
-        }
-      });
-      data.url = lang;
-      CCB.UserInfo.boards = CCB.boards[0];
-      if (document.getElementById("TM_id")) {
-        document.getElementById("TM_id").contentWindow.postMessage(data, "*");
-      }
-      if (document.getElementById("TM_id_object")) {
-        document.getElementById("TM_id_object").contentWindow.postMessage(data, "*");
-      }
-      if (document.getElementById("TM_id_posenet")) {
-        document.getElementById("TM_id_posenet").contentWindow.postMessage(data, "*");
-      }
-    }
-  }
-});
+// window.addEventListener("message", e => {
+//   let data = e.data;
+//   if (!CCB.asIframe) {
+//     if (typeof data === "object" && data.id === "loginVerify" && data.status === "logged") {
+//       $("#TM_login").empty();
+//       $("#TM_login_object").empty();
+//       $("#TM_login_posenet").empty();
+//       $("#TM_posenet_login").empty();
+//       $("#before_login").empty();
+//       $("#cloud_askLogin").empty();
+//       $("#TM_login_Model_download_modal").empty();
+//       $("#TM_login_webcam_capture_modal").empty();
+//       $("#TM_login_gesture_recog_modal").empty();
+//       $('#TM_login_voice_input_modal').empty();
+//       if (CCB.downloadModelUrl != '' && CCB.downloadModelUrl != '//xunlian.cocorobo.cn') {
+//         $("#center_game_modal").modal("close");
+//         $("#app_center_modal").modal("open");
+//       }
+//       $("#TM_center_game").empty();
+//       Materialize.toast(CCB.str_group.success_userLogin, 3000);
+//       CCB.userState = true;
+//       getUserProfile(data.data);
+//       loginModalStatus();
+//       getCloudFileList();
+//       CCB.UserInfo = data;
+
+//       /**
+//       *post login session message into TM_iframe
+//       */
+
+
+//       let lang = 'en';
+//       document.location.search.substring(1).split('&').forEach((item) => {
+//         if (item.split('=')[0] == 'lang') {
+//           lang = item.split('=')[1];
+//         }
+//       });
+//       data.url = lang;
+//       CCB.UserInfo.boards = CCB.boards[0];
+//       if (document.getElementById("TM_id")) {
+//         document.getElementById("TM_id").contentWindow.postMessage(data, "*");
+//       }
+//       if (document.getElementById("TM_id_object")) {
+//         document.getElementById("TM_id_object").contentWindow.postMessage(data, "*");
+//       }
+//       if (document.getElementById("TM_id_posenet")) {
+//         document.getElementById("TM_id_posenet").contentWindow.postMessage(data, "*");
+//       }
+//     }
+//   }
+// });
 
 
 window.addEventListener("message", e => {