Explorar o código

Merge branch 'beta' into HK

lsc %!s(int64=2) %!d(string=hai) anos
pai
achega
4ee3926d74
Modificáronse 1 ficheiros con 82 adicións e 19 borrados
  1. 82 19
      js/Desktop/DeskTop.js

+ 82 - 19
js/Desktop/DeskTop.js

@@ -1792,6 +1792,8 @@ window.addEventListener('message', function (e) { // 監聽 message 事件
         U.MD.D.I.openApplicationJieE("whiteboard", e.data.cid, e.data.stage, e.data.task, e.data.tool)
     } else if (e.data.tools && e.data.tools == "3E") {
         U.MD.D.I.openApplicationJieE("mind", e.data.cid, e.data.stage, e.data.task, e.data.tool)
+    } else if (e.data.tools && e.data.tools == "57y") {
+        U.MD.D.I.openApplicationYu("CocoPi", e.data.cid, e.data.stage, e.data.task, e.data.tool)
     } else if (e.data.tools && e.data.tools == "57u") {
         U.MD.D.I.openApplicationUpload("CocoPi", e.data.cid, e.data.stage, e.data.task, e.data.tool)
     } else if (e.data.tools && e.data.tools == "57teacher") {
@@ -5539,9 +5541,7 @@ U.MD.D.I.getContent = function (cid, s, task, t, uid, type, iframe) {
             if (xmlhttp.response && JSON.parse(xmlhttp.response)[0].length > 0) {
                 // resolve(res.value[0][0].text);
                 if (type == '2') {
-                    iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text).then(function (data) {
-                        $(fileInput).val('');
-                    });
+                    iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text)
                 } else if (type == '3') {
                     iframe.contentWindow.h.app.updateScene({ elements: JSON.parse(JSON.parse(xmlhttp.response)[0][0].text) })
                 }
@@ -6230,7 +6230,7 @@ U.MD.D.I.openApplicationYu = function (str, cid, stage, task, tool) {
             _formdiv = new U.UF.UI.form(
                 "電子白板",
                 _box, {
-                "id": "whiteboards" + cid + stage + task + tool,
+                "id": "whiteboards_Yu" + cid + stage + task + tool,
                 "style": {
                     "width": "90%",
                     "height": "90%",
@@ -6272,7 +6272,7 @@ U.MD.D.I.openApplicationYu = function (str, cid, stage, task, tool) {
             _formdiv = new U.UF.UI.form(
                 "思維導圖",
                 _box, { //"/jsmind/example/demo.html" 
-                "id": "minds" + cid + stage + task + tool,
+                "id": "minds_Yu" + cid + stage + task + tool,
                 "style": {
                     "width": "90%",
                     "height": "90%",
@@ -6314,7 +6314,7 @@ U.MD.D.I.openApplicationYu = function (str, cid, stage, task, tool) {
             _formdiv = new U.UF.UI.form(
                 "協同文檔",
                 _box, {
-                "id": "docs" + cid + stage + task + tool,
+                "id": "docs_Yu" + cid + stage + task + tool,
                 "style": {
                     "width": "90%",
                     "height": "90%",
@@ -6344,6 +6344,51 @@ U.MD.D.I.openApplicationYu = function (str, cid, stage, task, tool) {
                 }
             }
             break;
+        case "CocoPi":
+                aTool = 57;
+                _iframe = $$("iframe", {
+                    "allowpaymentrequest":"allowpaymentrequest",
+                    "allow": "camera *; microphone *;display-capture;usb",
+                    "webkitallowfullscreen": "", "mozallowfullscreen": "",
+                    "frameborder": "no",
+                    "border": "0",
+                    "scrolling ": "no",
+                    "style": {
+                        "cssText": "border:0;width:100%;height:100%"
+                    },
+                    "src": "https://beta.v.cocorobo.cn/"
+                })
+                _box.appendChild(_iframe);
+                _box.appendChild(_jie);
+                _formdiv = new U.UF.UI.form(
+                    "CocoPi",
+                    _box, {
+                    "id": "CocoPi_Yu" + cid + stage + task + tool,
+                    "style": {
+                        "width": "90%",
+                        "height": "90%",
+                        "overflow": 'hidden'
+                    },
+                    "onresize": function () { }
+                }, {
+                    closecallback: function () { }
+                }, {
+                    "style": {
+                        "height": "36px"
+                    }
+                }).form; //创建窗体
+                _taskbar = {
+                    "id": str + _formdiv.id,
+                    "style": {
+                        "backgroundImage": "url(/img/icon/cocopi.png)"
+                    },
+                    "name": "CocoPi",
+                    "forms": _formdiv,
+                    "click": function () {
+                        U.MD.D.I.openApplication(str, obj, info);
+                    }
+                }
+                break;
     }
 
     if (_iframe) {
@@ -6377,6 +6422,16 @@ U.MD.D.I.openApplicationYu = function (str, cid, stage, task, tool) {
             } else {
                 _iframe.contentDocument.location.reload()
             }
+        } else if (str == 'CocoPi') {
+            _iframe = _formdiv.querySelector('iframe')
+            let onloadListener = U.UF.DL.iframeLoad(_iframe, function () {
+                U.MD.D.I.getContents2(cid, stage, task, tool, _userid, '4', _iframe)
+            })
+            if (onloadListener) {
+                _iframe.contentDocument.location.reload()
+            } else {
+                _iframe.contentDocument.location.reload()
+            }
         } else {
             _iframe.onload = () => {
             };
@@ -6393,6 +6448,9 @@ U.MD.D.I.openApplicationYu = function (str, cid, stage, task, tool) {
             } else if (aTool == 3) {
                 text = await U.MD.D.I.getEditorContent(_iframe);
                 type = '2'
+            } else if (aTool == 57) {
+                text = encodeURIComponent(_iframe.contentWindow.getLoadXmlStr())
+                type = '4'
             }
             _loading.style.display = 'flex'
 
@@ -6423,9 +6481,7 @@ U.MD.D.I.getContents = function (cid, s, task, t, uid, type, iframe) {
         if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
             if (xmlhttp.response && JSON.parse(xmlhttp.response)[0].length > 0) {
                 // resolve(res.value[0][0].text);
-                iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text).then(function (data) {
-                    $(fileInput).val('');
-                });
+                iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text)
             }
         }
     }
@@ -6451,14 +6507,20 @@ U.MD.D.I.getContents2 = function (cid, s, task, t, uid, type, iframe) {
             if (xmlhttp.response && JSON.parse(xmlhttp.response)[0].length > 0) {
                 // resolve(res.value[0][0].text);
                 if (type == '2') {
-                    iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text).then(function (data) {
-                        $(fileInput).val('');
-                    });
+                    iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text)
                 } else if (type == '3') {
                     iframe.contentWindow.h.app.updateScene({ elements: JSON.parse(JSON.parse(xmlhttp.response)[0][0].text) })
+                } else if (type == '4') {
+                    iframe.contentWindow.loadingXml(JSON.parse(xmlhttp.response)[0][0].text)
                 }
             } else {
-                iframe.contentWindow.h.app.updateScene({ elements: [] })
+                if (type == '2') {
+                    iframe.contentWindow.editor.minder.importData('json', '')
+                } else if (type == '3') {
+                    iframe.contentWindow.h.app.updateScene({ elements: [] })
+                } else if (type == '4') {
+                    iframe.contentWindow.window.blockpy.components.editor.blockly.clear();
+                }
             }
         }
     }
@@ -6496,9 +6558,9 @@ U.MD.D.I.setContents = function (cid, s, task, t, uid, type, text, loading, span
     xmlhttp.open("POST", US.Config.pbl + "insertWord2y", true);
     // xmlhttp.open("POST", "http://localhost:7003/api/pbl/" + "insertWord2y", true);
     xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-    // 設置請求頭,表示請求體的編碼格式
-    xmlhttp.send("uid=" + uid + "&cid=" + cid + "&s=" + s + "&task=" + task + "&t=" + t + "&text=" + text + "&type=" + type);
-    // 設置請求體,使用url-encoded格式的數據
+    // 设置请求头,表示请求体的编码格式
+    xmlhttp.send("uid=" + uid + "&cid=" + cid + "&s=" + s + "&task=" + task + "&t=" + t + "&text=" + text.replaceAll(/%/g, "%25") + "&type=" + type);
+    // 设置请求体,使用url-encoded格式的数据
 }
 
 
@@ -6569,7 +6631,7 @@ U.MD.D.I.openApplicationUpload = function (str, cid, stage, task, tool) {
             _formdiv = new U.UF.UI.form(
                 "CocoPi",
                 _box, {
-                "id": "CocoPi" + cid + stage + task + tool,
+                "id": "CocoPi_Upload" + cid + stage + task + tool,
                 "style": {
                     "width": "90%",
                     "height": "90%",
@@ -6705,7 +6767,7 @@ U.MD.D.I.openApplicationTeacherUpload = function (str, cid, stage, task, tool, s
             _formdiv = new U.UF.UI.form(
                 "CocoPi-" + _username,
                 _box, {
-                "id": "CocoPi" + cid + stage + task + tool + _userid,
+                "id": "CocoPi_TeacherUpload" + cid + stage + task + tool + _userid,
                 "style": {
                     "width": "90%",
                     "height": "90%",
@@ -6782,7 +6844,8 @@ U.MD.D.I.getUploadContent = function (cid, s, task, t, uid, atool, type, iframe)
                 }
             } else {
                 if (atool == 57) {
-                    iframe.contentWindow.window.blockpy.components.editor.blockly.clear();
+                    U.MD.D.I.getContents2(cid, s, task, t, uid, '4', iframe)
+                    // iframe.contentWindow.window.blockpy.components.editor.blockly.clear();
                 }
             }
         }, [], { "type": "POST", "withCredentials": true });