From 0288f42c8dce13602b6668d822e541980aed595c Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Thu, 5 Jul 2018 20:39:32 +0800 Subject: [PATCH] fix getCategory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了getCategory,因为命名不一致带来bug的可能, 方便添加新分类 --- _server/editor_blockly.js | 10 +++++++--- editor-mobile.html | 4 ---- editor.html | 4 ---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index a128b493..86cc4461 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -5,9 +5,13 @@ editor_blockly = function () { initscript = String.raw` (function(){ var getCategory = function(name){ - for(var node of document.getElementById('toolbox').children) { - if(node.getAttribute('name')==name) return node; - } + for(var node of document.getElementById('toolbox').children) { + if(node.getAttribute('name')==name) return node; + } + var node = document.createElement('category'); + node.setAttribute('name',name); + document.getElementById('toolbox').appendChild(node); + return node; } var toolboxObj = { diff --git a/editor-mobile.html b/editor-mobile.html index 8fb7d599..6f945a90 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -165,10 +165,6 @@
diff --git a/editor.html b/editor.html index 9041889e..cff39acc 100644 --- a/editor.html +++ b/editor.html @@ -164,10 +164,6 @@