diff --git a/scripts/actions/tabs.js b/scripts/actions/tabs.js index 936e2ad..2fde241 100644 --- a/scripts/actions/tabs.js +++ b/scripts/actions/tabs.js @@ -1,12 +1,8 @@ import Tabs from "/scripts/GUI/tabs.js"; -import Entry_Manager from "/scripts/external/entries/manager.js" +import EntryManager from "/scripts/external/entries/manager.js" export default class Watcher_Tabs { constructor () { - new Entry_Manager(); - Tabs.addActionListener(`update`, this.check); + new EntryManager(); }; - - check(data) { - } } \ No newline at end of file diff --git a/scripts/external/entries/manager.js b/scripts/external/entries/manager.js new file mode 100644 index 0000000..e81913f --- /dev/null +++ b/scripts/external/entries/manager.js @@ -0,0 +1,49 @@ +// Manage all entries. + +import {read} from '../../secretariat.js'; +import Tabs from "/scripts/GUI/tabs.js"; +import MenuEntry from "./menu.js"; +import ManagedSidebar from "./sidebar.js"; +import IconIndicator from "./icons.js"; +import filters from '../../filters.js'; + +export default class EntryManager { + constructor () { + this.instances = {}; + this.instances.menu = new MenuEntry(); + Tabs.addActionListener(`onActivated`, (data) => {this.check(data)}); + } + + async check(data) { + console.error(JSON.stringify(data)); + ((data != null && (typeof data).includes(`obj`)) ? ((data.tab) ? data.tab.url : false) : false) + ? (!!await ((new filters).select(data.tab.url))) + ? (this.enable()) + : (this.disable()) + : false; + } + + /* + Enable the entries. + */ + enable () { + this.instances.menu.enable(); + IconIndicator.enable(); + + // Open the side panel, if supported. + read([`settings`,`behavior`,`autoOpen`]).then((result) => { + result = (result == null) ? false : result; + if (result) { + new ManagedSidebar(); + } + }); + } + + /* + Disable the entries and the existing opened side panel. + */ + disable () { + this.instances.menu.disable(); + IconIndicator.disable(); + } +} \ No newline at end of file diff --git a/scripts/external/entries/menu.js b/scripts/external/entries/menu.js new file mode 100644 index 0000000..845debd --- /dev/null +++ b/scripts/external/entries/menu.js @@ -0,0 +1,27 @@ +import Menu from '/scripts/GUI/context_menus.js'; +import texts from "/scripts/strings/read.js"; +import ManagedSidebar from "./sidebar.js"; + +export default class MenuEntry { + /* Create all entries. */ + constructor() { + // Add the context menu. + this.menu = new Menu({title: (new texts(`entry_contextMenu`)).localized, contexts: [`all`], event: {"onClicked": MenuEntry.onclick}, hidden: true}); + }; + + /* + Enable the sidebar. + */ + enable () { + this.menu.show(); + } + + /* Disable. */ + disable () { + this.menu.remove(); + } + + static onclick() { + new ManagedSidebar(); + }; +} \ No newline at end of file diff --git a/scripts/external/entries/sidebar.js b/scripts/external/entries/sidebar.js new file mode 100644 index 0000000..8de51f0 --- /dev/null +++ b/scripts/external/entries/sidebar.js @@ -0,0 +1,12 @@ +import Sidebar from '/scripts/GUI/sidepanel.js' + +export default class ManagedSidebar { + constructor () { + // WIP + console.warn(`hello world`); + } + + manage() { + + } +} \ No newline at end of file