Last active
August 15, 2018 04:54
-
-
Save oshliaer/4af2eb6ebfc548a737ed13289fcdccb7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function updateMenu_(menu, items) { | |
| var menuIterator = makeIterator_(items); | |
| while (true) { | |
| menu.addItem(menuIterator.get().name, menuIterator.get().fn); | |
| if (menuIterator.next().done) break; | |
| }; | |
| } | |
| function getScriptFunctionsAsMenuItems_(context) { | |
| return Object.keys(context).filter(function (key) { return key.slice(-1) !== "_" && key !== "onOpen" && typeof this[key] === "function" }, context).map(function (item) { | |
| return { name: item, fn: item }; | |
| }); | |
| } | |
| function L() { | |
| Browser.msgBox("L"); | |
| } | |
| function f1() { | |
| Browser.msgBox("f1"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function makeIterator_(array) { | |
| var nextIndex = 0; | |
| return { | |
| next: function () { | |
| nextIndex++; | |
| return nextIndex < array.length ? | |
| { value: array[nextIndex], done: false } : | |
| { done: true }; | |
| }, | |
| get: function () { | |
| return nextIndex < array.length ? array[nextIndex] : undefined; | |
| } | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function onOpen() { | |
| var self = this; | |
| var menu = SpreadsheetApp.getUi().createMenu("All script functions"); | |
| updateMenu_(menu, getScriptFunctionsAsMenuItems_(self)); | |
| menu.addToUi(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment