|
@@ -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}    </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}    </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}    </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}    </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 => {
|