Skip to content

Commit cce6562

Browse files
author
Ke, Mingze
committed
Get categories dynamically
1 parent 8f46d90 commit cce6562

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

code.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,10 @@ Code.initLanguage = function () {
417417
document.getElementById('runButton').title = MSG['runTooltip'];
418418
document.getElementById('trashButton').title = MSG['trashTooltip'];
419419

420-
var categories = ['catLogic', 'catLoops', 'catMath', 'catText', 'catLists',
421-
'catColour', 'catVariables', 'catFunctions', 'catExec',
422-
'catBoard', 'catLed', 'catRGBLed', 'catCar'
423-
];
420+
var toolbox = document.getElementById('toolbox');
421+
var categories = Array.prototype.slice.call(toolbox.querySelectorAll('category')).map(function (e) {
422+
return e.id
423+
});
424424
for (var i = 0, cat; cat = categories[i]; i++) {
425425
document.getElementById(cat).setAttribute('name', MSG[cat]);
426426
}

0 commit comments

Comments
 (0)