From c305379393baed9975e9e631e9aa13e54015a4a4 Mon Sep 17 00:00:00 2001 From: Valerie Young Date: Tue, 11 Dec 2018 14:53:38 -0500 Subject: [PATCH] format menu --- src/extensions/scratch3_goforce/index.js | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/extensions/scratch3_goforce/index.js b/src/extensions/scratch3_goforce/index.js index 9290b5885..d858a7bb6 100644 --- a/src/extensions/scratch3_goforce/index.js +++ b/src/extensions/scratch3_goforce/index.js @@ -197,6 +197,35 @@ class Scratch3GoForceBlocks { return Promise.resolve(); } + /** + * Formats menus into a format suitable for block menus, and loading previously + * saved projects: + * [ + * { + * text: label, + * value: index + * }, + * { + * text: label, + * value: index + * }, + * etc... + * ] + * + * @param {array} menu - a menu to format. + * @return {object} - a formatted menu as an object. + * @private + */ + _formatMenu (menu) { + const m = []; + for (let i = 0; i < menu.length; i++) { + const obj = {}; + obj.text = menu[i]; + obj.value = i.toString(); + m.push(obj); + } + return m; + } } module.exports = Scratch3GoForceBlocks;