From 103f2c64150d5be2a24d817e86a3ce1e40c2e62f Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Tue, 22 Oct 2019 20:46:37 +0800 Subject: [PATCH] reformat table --- _server/css/editor_mode.css | 17 ++++++++++---- _server/css/editor_mode_mobile.css | 13 +++++++---- _server/editor_blockly.js | 36 ++++++++++++++++++++++++++++++ _server/editor_listen.js | 11 ++++----- _server/editor_table.js | 32 +++++++++++++++++++++++--- 5 files changed, 93 insertions(+), 16 deletions(-) diff --git a/_server/css/editor_mode.css b/_server/css/editor_mode.css index a1859f65..d521a617 100644 --- a/_server/css/editor_mode.css +++ b/_server/css/editor_mode.css @@ -121,6 +121,7 @@ display: block; width: 100%; overflow: auto; + word-break: break-all; } .etable table th { @@ -157,14 +158,19 @@ } .etable tr > :nth-child(3) { - width: 60% + width: 35%; +} + +.etable tr > :nth-child(4) { + width: 25%; + padding: 0; } .etable table { overflow: visible; } -.etable tr:not(:first-child) > :last-child:hover { +.etable tr:not(:first-child) > :nth-child(3):hover { border: 1px solid rgb(87, 198, 232); box-shadow: 0px 0px 3px rgb(87, 198, 232); } @@ -175,14 +181,17 @@ box-shadow: 0px 0px 3px rgb(87, 232, 198); } -.etable tr:not(:first-child) > :last-child { +.etable tr:not(:first-child) > :nth-child(3) { margin: 0; padding: 0; height: 100%; - width: 100%; position: relative; } +.etable tr > :nth-child(4) { + text-align: center; +} + div.etableInputDiv { position: absolute; padding: 5px 0 0 5px; diff --git a/_server/css/editor_mode_mobile.css b/_server/css/editor_mode_mobile.css index 3098df27..bb680213 100644 --- a/_server/css/editor_mode_mobile.css +++ b/_server/css/editor_mode_mobile.css @@ -135,6 +135,7 @@ display: block; width: 100%; overflow: auto; + word-break: break-all; } .etable table th { @@ -171,14 +172,19 @@ } .etable tr > :nth-child(3) { - width: 60% + width: 30%; +} + +.etable tr > :nth-child(4) { + width: 30%; + text-align: center; } .etable table { overflow: visible; } -.etable tr:not(:first-child) > :last-child:hover { +.etable tr:not(:first-child) > :nth-child(3):hover { border: 1px solid rgb(87, 198, 232); box-shadow: 0px 0px 3px rgb(87, 198, 232); } @@ -189,11 +195,10 @@ box-shadow: 0px 0px 3px rgb(87, 232, 198); } -.etable tr:not(:first-child) > :last-child { +.etable tr:not(:first-child) > :nth-child(3) { margin: 0; padding: 0; height: 100%; - width: 100%; position: relative; } diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 4a6d9c35..5cbf447a 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -622,9 +622,45 @@ function omitedcheckUpdateFunction(event) { var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace); code = code.replace(/\\(i|c|d|e)/g, '\\\\$1'); eval('var obj=' + code); + if (this.checkAsync(obj) && confirm("警告!存在不等待执行完毕的事件但却没有用【等待所有异步事件处理完毕】来等待" + + "它们执行完毕,这样可能会导致录像检测系统出问题。\n你要返回修改么?")) return; setvalue(JSON.stringify(obj)); } + // 检查"不等待处理完毕" + editor_blockly.checkAsync = function (obj) { + if (!(obj instanceof Array)) return false; + var hasAsync = false; + for (var i = 0; i < obj.length; ++i) { + var one = obj[i]; + if (one.type == 'if' && (this.checkAsync(one['true']) || this.checkAsync(one['false']))) + return true; + if ((one.type == 'while' || one.type == 'dowhile') && this.checkAsync(one.data)) + return true; + if (one.type == 'if' && (this.checkAsync(one.yes) || this.checkAsync(one.no))) + return true; + if (one.type == 'choices') { + var list = one.choices; + if (list instanceof Array) { + for (var j = 0; j < list.length; j++) { + if (this.checkAsync(list[j].action)) return true; + } + } + } + if (one.type == 'switch') { + var list = one.caseList; + if (list instanceof Array) { + for (var j = 0; j < list.length; j++) { + if (this.checkAsync(list[j].action)) return true; + } + } + } + if (one.async && one.type != 'animate') hasAsync = true; + if (one.type == 'waitAsync') hasAsync = false; + } + return hasAsync; + } + var previewBlock = function (b) { var types = [ "previewUI_s", "clearMap_s", "clearMap_1_s", "setAttribute_s", "fillText_s", diff --git a/_server/editor_listen.js b/_server/editor_listen.js index f1fd4ea8..dc957c6a 100644 --- a/_server/editor_listen.js +++ b/_server/editor_listen.js @@ -50,13 +50,13 @@ editor_listen_wrapper = function (editor) { var mobileview = document.getElementById('mobileview'); var mid = document.getElementById('mid'); var right = document.getElementById('right'); - var mobileeditdata = document.getElementById('mobileeditdata'); + // var mobileeditdata = document.getElementById('mobileeditdata'); editor.showdataarea = function (callShowMode) { mid.style = 'z-index:-1;opacity: 0;'; right.style = 'z-index:-1;opacity: 0;'; - mobileeditdata.style = ''; + // mobileeditdata.style = ''; if (callShowMode) editor.mode.showMode(editor.dom.editModeSelect.value); editor.uifunctions.hideMidMenu(); } @@ -66,17 +66,17 @@ editor_listen_wrapper = function (editor) { mobileview.children[1].onclick = function () { mid.style = ''; right.style = 'z-index:-1;opacity: 0;'; - mobileeditdata.style = 'z-index:-1;opacity: 0;'; + // mobileeditdata.style = 'z-index:-1;opacity: 0;'; editor.lastClickId = ''; } mobileview.children[3].onclick = function () { mid.style = 'z-index:-1;opacity: 0;'; right.style = ''; - mobileeditdata.style = 'z-index:-1;opacity: 0;'; + // mobileeditdata.style = 'z-index:-1;opacity: 0;'; editor.lastClickId = ''; } - + /* var gettrbyid = function () { if (!editor.lastClickId) return false; thisTr = document.getElementById(editor.lastClickId); @@ -100,6 +100,7 @@ editor_listen_wrapper = function (editor) { if (!info) return; printf(info[0].children[1].getAttribute('title')) } + */ //===== diff --git a/_server/editor_table.js b/_server/editor_table.js index 6ad458c6..b2e8cf3f 100644 --- a/_server/editor_table.js +++ b/_server/editor_table.js @@ -26,13 +26,19 @@ editor_table_wrapper = function (editor) { editor_table.prototype.textarea = function (value, indent) { return /* html */`\n` } + editor_table.prototype.editGrid = function (showComment) { + var html = ""; + if (showComment) html += "
"; + html += ""; + return html; + } editor_table.prototype.title = function () { - return /* html */`\n条目注释值\n` + return /* html */`\n条目注释值操作\n` } editor_table.prototype.gap = function (field) { - return /* html */`--------${field}\n` + return /* html */`--------${field}----\n` } editor_table.prototype.tr = function (guid, field, shortField, commentHTMLescape, cobjstr, shortCommentHTMLescape, tdstr) { @@ -40,6 +46,7 @@ editor_table_wrapper = function (editor) { ${shortField} ${shortCommentHTMLescape}
${tdstr}
+ ${editor.table.editGrid(commentHTMLescape != shortCommentHTMLescape)} \n` } @@ -194,7 +201,7 @@ editor_table_wrapper = function (editor) { // "['a']['b']" => "b" var shortField = field.split("']").slice(-2)[0].split("['").slice(-1)[0]; // 把长度超过 charlength 的字符改成 固定长度+...的形式 - shortField = (shortField.length < charlength ? shortField : shortField.slice(0, charlength) + '...'); + // shortField = (shortField.length < charlength ? shortField : shortField.slice(0, charlength) + '...'); // 完整的内容转义后供悬停查看 var commentHTMLescape = editor.util.HTMLescape(comment); @@ -299,6 +306,25 @@ editor_table_wrapper = function (editor) { } } + /** + * 当"显示完整注释"被按下时 + */ + editor_table.prototype.onCommentBtnClick = function (button) { + var tr = button.parentNode.parentNode; + printf(tr.children[1].getAttribute('title')); + } + + /** + * 当"编辑表格内容"被按下时 + */ + editor_table.prototype.onEditBtnClick = function (button) { + var tr = button.parentNode.parentNode; + var guid = tr.getAttribute('id'); + var cobj = JSON.parse(tr.children[1].getAttribute('cobj')); + if (cobj._type === 'event') editor_blockly.import(guid, { type: cobj._event }); + if (cobj._type === 'textarea') editor_multi.import(guid, { lint: cobj._lint, string: cobj._string }); + } + /** * 双击表格时 * 正常编辑: 尝试用事件编辑器或多行文本编辑器打开