diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 539cc22c..a5dfbcc6 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -1,6 +1,6 @@ editor_blockly = function () { - var editor_blockly = {}; + var editor_blockly = {entryType:'event'}; /////////////////initscript start///////////////////////////// // do not use String.raw because of highlighting @@ -21,6 +21,7 @@ editor_blockly = function () { var toolboxObj = { '入口方块':[ + '', MotaActionFunctions.actionParser.parse([ "欢迎使用事件编辑器", "本事件触发一次后会消失", @@ -343,6 +344,7 @@ editor_blockly = function () { for (var name in toolboxObj){ var custom = null; if(name=='最近使用事件')custom='searchBlockCategory'; + if(name=='入口方块')custom='entranceCategory'; getCategory(name,custom).innerHTML = toolboxObj[name].join(toolboxgap); } @@ -362,6 +364,23 @@ var workspace = Blockly.inject(blocklyDiv,{ trashcan: false, }); +editor_blockly.entranceCategoryCallback = function(workspace) { + var list=toolboxObj['入口方块'] + var xmlList = []; + var eventType = editor_blockly.entryType+'_m'; + for(var ii=0,blockText;blockText=list[ii];ii++){ + if(new RegExp('').exec(blockText)){ + var block = Blockly.Xml.textToDom(''+blockText+'').firstChild; + block.setAttribute("gap", 5); + xmlList.push(block); + } + } + return xmlList; +} + +workspace.registerToolboxCategoryCallback( + 'entranceCategory', editor_blockly.entranceCategoryCallback); + editor_blockly.searchBlockCategoryCallback = function(workspace) { var xmlList = []; var labels = editor_blockly.searchBlock(); @@ -418,7 +437,7 @@ function omitedcheckUpdateFunction(event) { editor_blockly.setValue('入口方块只能有一个'); return; } - var eventType = document.getElementById('entryType').value; + var eventType = editor_blockly.entryType; if(editor_blockly.workspace.topBlocks_.length==1){ var blockType = editor_blockly.workspace.topBlocks_[0].type; if(blockType!==eventType+'_m'){ @@ -604,7 +623,7 @@ function omitedcheckUpdateFunction(event) { eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) { return {'<': '<', '>': '>', '&': '&'}[c]; }).replace(/\\(r|f|i|c|d|e|z)/g,'\\\\$1')), - document.getElementById('entryType').value + editor_blockly.entryType ); } @@ -619,7 +638,7 @@ function omitedcheckUpdateFunction(event) { if (!type) return false; editor_blockly.id = id_; editor_blockly.setValue(input.value); - document.getElementById('entryType').value = type; + editor_blockly.entryType = type; editor_blockly.parse(); editor_blockly.show(); return true; @@ -667,7 +686,7 @@ function omitedcheckUpdateFunction(event) { editor_blockly.setValue('入口方块只能有一个'); return; } - var eventType = document.getElementById('entryType').value; + var eventType = editor_blockly.entryType; if(editor_blockly.workspace.topBlocks_.length==1){ var blockType = editor_blockly.workspace.topBlocks_[0].type; if(blockType!==eventType+'_m'){ diff --git a/editor-mobile.html b/editor-mobile.html index ea13578b..f4c3cd3d 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -204,25 +204,6 @@ --> - diff --git a/editor.html b/editor.html index 3ede676b..b9cf59a7 100644 --- a/editor.html +++ b/editor.html @@ -200,25 +200,6 @@ --> -