blockly解析提示
This commit is contained in:
parent
47283d30a9
commit
0d3ed417b3
@ -398,22 +398,22 @@ function omitedcheckUpdateFunction(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(editor_blockly.workspace.topBlocks_.length>=2){
|
if(editor_blockly.workspace.topBlocks_.length>=2){
|
||||||
codeAreaHL.setValue('入口方块只能有一个');
|
editor_blockly.setValue('入口方块只能有一个');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var eventType = document.getElementById('entryType').value;
|
var eventType = document.getElementById('entryType').value;
|
||||||
if(editor_blockly.workspace.topBlocks_.length==1){
|
if(editor_blockly.workspace.topBlocks_.length==1){
|
||||||
var blockType = editor_blockly.workspace.topBlocks_[0].type;
|
var blockType = editor_blockly.workspace.topBlocks_[0].type;
|
||||||
if(blockType!==eventType+'_m'){
|
if(blockType!==eventType+'_m'){
|
||||||
codeAreaHL.setValue('入口方块类型错误');
|
editor_blockly.setValue('入口方块类型错误');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var code = Blockly.JavaScript.workspaceToCode(workspace).replace(/\\\\(i|c|d|e|z)/g, '\\\\\\\\$1');
|
var code = Blockly.JavaScript.workspaceToCode(workspace).replace(/\\\\(i|c|d|e|z)/g, '\\\\\\\\$1');
|
||||||
codeAreaHL.setValue(code);
|
editor_blockly.setValue(code);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
codeAreaHL.setValue(String(error));
|
editor_blockly.setValue(String(error));
|
||||||
if (error instanceof OmitedError){
|
if (error instanceof OmitedError){
|
||||||
var blockName = error.blockName;
|
var blockName = error.blockName;
|
||||||
var varName = error.varName;
|
var varName = error.varName;
|
||||||
@ -529,13 +529,19 @@ function omitedcheckUpdateFunction(event) {
|
|||||||
xhr.open('GET', '_server/MotaAction.g4', true);
|
xhr.open('GET', '_server/MotaAction.g4', true);
|
||||||
xhr.send(null);
|
xhr.send(null);
|
||||||
|
|
||||||
codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), {
|
var codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
matchBrackets: true,
|
matchBrackets: true,
|
||||||
lineWrapping: true,
|
lineWrapping: true,
|
||||||
continueComments: "Enter",
|
continueComments: "Enter",
|
||||||
extraKeys: {"Ctrl-Q": "toggleComment"}
|
extraKeys: {"Ctrl-Q": "toggleComment"},
|
||||||
});
|
});
|
||||||
|
codeAreaHL.on('changes', function () {
|
||||||
|
editor_blockly.highlightParse(!changeFromBlockly);
|
||||||
|
changeFromBlockly = false;
|
||||||
|
});
|
||||||
|
var changeFromBlockly = false;
|
||||||
|
var shouldNotifyParse = false;
|
||||||
|
|
||||||
editor_blockly.showXML = function () {
|
editor_blockly.showXML = function () {
|
||||||
var xml = Blockly.Xml.workspaceToDom(editor_blockly.workspace);
|
var xml = Blockly.Xml.workspaceToDom(editor_blockly.workspace);
|
||||||
@ -561,6 +567,11 @@ function omitedcheckUpdateFunction(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editor_blockly.setValue = function (value) {
|
||||||
|
changeFromBlockly = true;
|
||||||
|
codeAreaHL.setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
editor_blockly.parse = function () {
|
editor_blockly.parse = function () {
|
||||||
MotaActionFunctions.parse(
|
MotaActionFunctions.parse(
|
||||||
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
|
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
|
||||||
@ -580,7 +591,7 @@ function omitedcheckUpdateFunction(event) {
|
|||||||
var type = args.type;
|
var type = args.type;
|
||||||
if (!type) return false;
|
if (!type) return false;
|
||||||
editor_blockly.id = id_;
|
editor_blockly.id = id_;
|
||||||
codeAreaHL.setValue(input.value);
|
editor_blockly.setValue(input.value);
|
||||||
document.getElementById('entryType').value = type;
|
document.getElementById('entryType').value = type;
|
||||||
editor_blockly.parse();
|
editor_blockly.parse();
|
||||||
editor_blockly.show();
|
editor_blockly.show();
|
||||||
@ -604,6 +615,13 @@ function omitedcheckUpdateFunction(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var blocklyParseBtn = document.getElementById('blocklyParse');
|
||||||
|
editor_blockly.highlightParse = function (shouldHighLight) {
|
||||||
|
if (shouldNotifyParse == shouldHighLight) return;
|
||||||
|
shouldNotifyParse = shouldHighLight;
|
||||||
|
blocklyParseBtn.style.background = shouldNotifyParse ? '#FFCCAA' : 'unset';
|
||||||
|
}
|
||||||
|
|
||||||
editor_blockly.cancel = function () {
|
editor_blockly.cancel = function () {
|
||||||
editor_blockly.id = '';
|
editor_blockly.id = '';
|
||||||
editor_blockly.hide();
|
editor_blockly.hide();
|
||||||
@ -614,15 +632,19 @@ function omitedcheckUpdateFunction(event) {
|
|||||||
editor_blockly.id = '';
|
editor_blockly.id = '';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (shouldNotifyParse) {
|
||||||
|
alert('你尚未解析修改后的内容,请进行解析或放弃操作');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(editor_blockly.workspace.topBlocks_.length>=2){
|
if(editor_blockly.workspace.topBlocks_.length>=2){
|
||||||
codeAreaHL.setValue('入口方块只能有一个');
|
editor_blockly.setValue('入口方块只能有一个');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var eventType = document.getElementById('entryType').value;
|
var eventType = document.getElementById('entryType').value;
|
||||||
if(editor_blockly.workspace.topBlocks_.length==1){
|
if(editor_blockly.workspace.topBlocks_.length==1){
|
||||||
var blockType = editor_blockly.workspace.topBlocks_[0].type;
|
var blockType = editor_blockly.workspace.topBlocks_[0].type;
|
||||||
if(blockType!==eventType+'_m'){
|
if(blockType!==eventType+'_m'){
|
||||||
codeAreaHL.setValue('入口方块类型错误');
|
editor_blockly.setValue('入口方块类型错误');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -219,7 +219,7 @@
|
|||||||
<option value="item">item</option>
|
<option value="item">item</option>
|
||||||
</select>
|
</select>
|
||||||
<button onclick="editor_blockly.confirm()">确认</button>
|
<button onclick="editor_blockly.confirm()">确认</button>
|
||||||
<button onclick="editor_blockly.parse()">解析</button>
|
<button id='blocklyParse' onclick="editor_blockly.parse()">解析</button>
|
||||||
<button onclick="editor_blockly.cancel()">取消</button>
|
<button onclick="editor_blockly.cancel()">取消</button>
|
||||||
<!-- 手机端放不下,因此不显示搜索框 -->
|
<!-- 手机端放不下,因此不显示搜索框 -->
|
||||||
<div style="display: none">
|
<div style="display: none">
|
||||||
|
|||||||
@ -215,7 +215,7 @@
|
|||||||
<option value="item">item</option>
|
<option value="item">item</option>
|
||||||
</select>
|
</select>
|
||||||
<button onclick="editor_blockly.confirm()">确认</button>
|
<button onclick="editor_blockly.confirm()">确认</button>
|
||||||
<button onclick="editor_blockly.parse()">解析</button>
|
<button id='blocklyParse' onclick="editor_blockly.parse()">解析</button>
|
||||||
<button onclick="editor_blockly.cancel()">取消</button>
|
<button onclick="editor_blockly.cancel()">取消</button>
|
||||||
<div style="position: relative; display: inline-block; margin-left: 10px">
|
<div style="position: relative; display: inline-block; margin-left: 10px">
|
||||||
<div class="searchLogo"></div>
|
<div class="searchLogo"></div>
|
||||||
|
|||||||
@ -55,7 +55,7 @@
|
|||||||
(已完成!) loader并行加载
|
(已完成!) loader并行加载
|
||||||
合并items.js
|
合并items.js
|
||||||
(已完成!) 增加fonts目录,全塔属性增加fonts引用
|
(已完成!) 增加fonts目录,全塔属性增加fonts引用
|
||||||
右边框输入完后解析按钮高亮
|
(已完成!) 右边框输入完后解析按钮高亮
|
||||||
|
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user