mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 23:12:24 -05:00
Add rudimentary toolbox filtering method
This commit is contained in:
parent
370f2c6a47
commit
99e1b24285
1 changed files with 19 additions and 0 deletions
|
@ -336,4 +336,23 @@ VirtualMachine.prototype.postSpriteInfo = function (data) {
|
||||||
this.editingTarget.postSpriteInfo(data);
|
this.editingTarget.postSpriteInfo(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VirtualMachine.prototype.filterToolbox = function (toolboxDOM) {
|
||||||
|
var filteredToolbox = toolboxDOM.cloneNode();
|
||||||
|
var category = toolboxDOM.firstElementChild;
|
||||||
|
while (category) {
|
||||||
|
var filteredCategory = category.cloneNode();
|
||||||
|
var block = category.firstElementChild;
|
||||||
|
while (block) {
|
||||||
|
var opcode = block.getAttribute('type');
|
||||||
|
if (opcode in this.runtime._primitives || opcode in this.runtime._hats) {
|
||||||
|
filteredCategory.appendChild(block.cloneNode(true));
|
||||||
|
}
|
||||||
|
block = block.nextElementSibling;
|
||||||
|
}
|
||||||
|
if (filteredCategory.hasChildNodes()) filteredToolbox.appendChild(filteredCategory);
|
||||||
|
category = category.nextElementSibling;
|
||||||
|
}
|
||||||
|
return filteredToolbox;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = VirtualMachine;
|
module.exports = VirtualMachine;
|
||||||
|
|
Loading…
Reference in a new issue