From bc9ca38d7f4c56f7ce4b192e60456e84e8a5c025 Mon Sep 17 00:00:00 2001 From: mmuffins Date: Sun, 26 May 2019 10:09:19 +0200 Subject: [PATCH] Renamed all references from addon to extension --- README.md | 44 ++++++++++++++++++++++---------------------- actions_add.js | 32 ++++++++++++++++---------------- info.json | 6 +++--- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index bcafda6..f3aeb3b 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ -# Addons Menu for MediaMonkey -[![Build status](https://dev.azure.com/mmuffins/github/_apis/build/status/MediaMonkey.AddonsMenu)](https://dev.azure.com/mmuffins/github/_build/latest?definitionId=79) +# Extensions Menu for MediaMonkey +[![Build status](https://dev.azure.com/mmuffins/github/_apis/build/status/MediaMonkey.ExtensionsMenu)](https://dev.azure.com/mmuffins/github/_build/latest?definitionId=79) This extension adds an additional item to the MediaMonkey 5 main menu bar that allows extension developers to present an entry point or functionality of their extension in a central and consistent way to the user. ## Installation -Download the latest release from the releases section and double click addonsMenu.mmip. An MediaMonkey dialog will automatically pop up, prompting you to confirm the installation. +Download the latest release from the releases section and double click extensionsMenu.mmip. An MediaMonkey dialog will automatically pop up, prompting you to confirm the installation. ## Registering actions -To add an action to the addons menu, follow the steps below. -Create an action for the function of the calling addon +To add an action to the Extensions menu, follow the steps below. +Create an action for the function of the calling Extensions ```javascript -actions.testAddon = { +actions.testExtensions = { create: { title: function() { - return _('&TestAddon Create Action') + return _('&TestExtension Create Action') }, hotkeyAble: false, - category: actionCategories.addons, + category: actionCategories.extensions, icon: 'createIcon', execute: function() { ... @@ -25,10 +25,10 @@ actions.testAddon = { delete: { title: function() { - return _('&TestAddon Delete Action') + return _('&TestExtension Delete Action') }, hotkeyAble: false, - category: actionCategories.addons, + category: actionCategories.extensions, icon: 'deleteIcon', execute: function() { ... @@ -36,30 +36,30 @@ actions.testAddon = { }, } ``` -Since it's not possible to enforce a load order for extensions or otherwise ensure that the Addons Menu extension is loaded before an extension wants to register an action, new menu items are added indirectly by pushing them into an import queue, which is picked up and processed once the Addons Menu extension is loaded. +Since it's not possible to enforce a load order for extensions or otherwise ensure that the Extensions Menu extension is loaded before an extension wants to register an action, new menu items are added indirectly by pushing them into an import queue, which is picked up and processed once the Extensions Menu extension is loaded. ```javascript -// Add global section to register addon actions if it doesn't exist yet -if (typeof addons == "undefined") - var addons = {} +// Add global section to register extension actions if it doesn't exist yet +if (typeof extensions == "undefined") + var extensions = {} -// If the Addons Menu was not loaded yet, not import queue exists. -if (!addons.hasOwnProperty('addonsMenuImportQueue')) - addons.addonsMenuImportQueue = [] +// If the Extensions Menu was not loaded yet, not import queue exists. +if (!extensions.hasOwnProperty('extensionsMenuImportQueue')) + extensions.extensionsMenuImportQueue = [] // Push actions that should be added to the menu to the import queue. // Do not replace the import queue with a new array as this might remove already queued actions from other extensions -testAddonActions.push({action:actions.testAddon.create, order: 10, category:'TestAddon'}) -testAddonActions.push({action:actions.testAddon.delete, order: 20, category:'TestAddon'}) +extensions.extensionsMenuImportQueue.push({action:actions.testExtension.create, order: 10, category:'TestExtension'}) +extensions.extensionsMenuImportQueue.push({action:actions.testExtension.delete, order: 20, category:'TestExtension'}) // Refresh the menu to import actions that were added to the queue. // No need to worry if the menu can't be refreshed at this point because it's not loaded yet. // It will automatically import all pending entries in the import queue as soon as its loaded. -if(addons.addonsMenu != null) - addons.addonsMenu.refresh(); +if(extensions.extensionsMenu != null) + extensions.extensionsMenu.refresh(); ``` Each pushed to the import queue needs to have three properties: * action: Contains the action to be executed. -* category: Category/Grouping name for all entries. This should usually be the name of the addon. +* category: Category/Grouping name for all entries. This should usually be the name of the extension. * order: Sort order for the respective entry within its category. \ No newline at end of file diff --git a/actions_add.js b/actions_add.js index e20355f..78bb70f 100644 --- a/actions_add.js +++ b/actions_add.js @@ -1,30 +1,30 @@ "use strict"; -window.actionCategories.addons = function(){ +window.actionCategories.extensions = function(){ return _('Extensions'); } -// Add global section to register addon actions if it doesn't exist yet -if (typeof addons == "undefined") - var addons = {} +// Add global section to register extension actions if it doesn't exist yet +if (typeof extensions == "undefined") + var extensions = {} -addons.addonsMenu = { +extensions.extensionsMenu = { menuOrder: 55, menuGrouporder: 10, menu: [], refresh: async function(){ let _this = this; - if (!addons.hasOwnProperty('addonsMenuImportQueue') || !addons.addonsMenuImportQueue instanceof Array) { - addons.addonsMenuImportQueue = []; + if (!extensions.hasOwnProperty('extensionsMenuImportQueue') || !extensions.extensionsMenuImportQueue instanceof Array) { + extensions.extensionsMenuImportQueue = []; return; } - if(addons.addonsMenuImportQueue.length == 0) + if(extensions.extensionsMenuImportQueue.length == 0) return; - let importItems = addons.addonsMenuImportQueue; - addons.addonsMenuImportQueue = []; + let importItems = extensions.extensionsMenuImportQueue; + extensions.extensionsMenuImportQueue = []; // filter out items with missing properties importItems = importItems.filter(menuItm => { @@ -40,12 +40,12 @@ addons.addonsMenu = { }); // Add imported entries to menu, but skip duplicates - importItems.forEach(addonItm => { - if (typeof (_this.menu.find(item => item.action.title() == addonItm.action.title() && item.category == addonItm.category)) != "undefined") { + importItems.forEach(extensionItm => { + if (typeof (_this.menu.find(item => item.action.title() == extensionItm.action.title() && item.category == extensionItm.category)) != "undefined") { return Promise.reject('Item already exists'); } - _this.menu.push({action: addonItm.action, order: addonItm.order, category: addonItm.category, grouporder: 100}); + _this.menu.push({action: extensionItm.action, order: extensionItm.order, category: extensionItm.category, grouporder: 100}); }) _this.sortMenu(); @@ -63,7 +63,7 @@ addons.addonsMenu = { for (let i = 0; i < window.mainMenuItems.length; i++) { const itm = window.mainMenuItems[i].action; - if(itm.hasOwnProperty('title') && itm.title instanceof Function && itm.title() == '&Addons'){ + if(itm.hasOwnProperty('title') && itm.title instanceof Function && itm.title() == '&Extensions'){ itm.submenu = _this.menu; return; } @@ -72,7 +72,7 @@ addons.addonsMenu = { let newMenu = { action: { title: function () { - return _('&Addons'); + return _('&Extensions'); }, visible: !webApp, submenu: _this.menu @@ -108,4 +108,4 @@ addons.addonsMenu = { } } -addons.addonsMenu.refresh() +extensions.extensionsMenu.refresh() diff --git a/info.json b/info.json index a77f145..26f5573 100644 --- a/info.json +++ b/info.json @@ -1,7 +1,7 @@ { - "title": "Addons Menu", - "id": "AddonsMenu", - "description": "Adds an Addons Section to the Main Menu", + "title": "Extensions Menu", + "id": "extensionsMenu", + "description": "Adds an Extensions Section to the Main Menu", "version": "1.0.0", "type": "general", "author": "Michael Kellner"