2018-02-14 09:05:34 +01:00
|
|
|
module.exports = (Plugin, Api, Vendor, Dependencies) => {
|
2018-01-16 02:45:23 +01:00
|
|
|
|
2018-02-11 23:07:23 +01:00
|
|
|
const { $, moment, _ } = Vendor;
|
|
|
|
const { Events, Logger } = Api;
|
2018-01-16 02:45:23 +01:00
|
|
|
|
2018-02-12 16:20:27 +01:00
|
|
|
return class extends Plugin {
|
2018-01-16 02:45:23 +01:00
|
|
|
onStart() {
|
2018-02-12 00:04:07 +01:00
|
|
|
Events.subscribe('TEST_EVENT', this.eventTest);
|
2018-02-11 23:07:23 +01:00
|
|
|
Logger.log('onStart');
|
2018-02-14 00:23:52 +01:00
|
|
|
|
2018-02-13 23:37:24 +01:00
|
|
|
Logger.log(`Plugin setting "default-0" value: ${this.getSetting('default-0')}`);
|
2018-02-14 00:23:52 +01:00
|
|
|
this.events.on('setting-updated', event => {
|
|
|
|
console.log('Received plugin setting update:', event);
|
|
|
|
});
|
|
|
|
this.events.on('settings-updated', event => {
|
|
|
|
console.log('Received plugin settings update:', event);
|
|
|
|
});
|
2018-02-13 23:37:24 +01:00
|
|
|
|
2018-02-14 00:23:52 +01:00
|
|
|
Logger.log(`Internal setting "core/default/test-setting" value: ${Api.Settings.get('core', 'default', 'test-setting')}`);
|
|
|
|
Events.subscribe('setting-updated', event => {
|
|
|
|
console.log('Received internal setting update:', event);
|
2018-02-13 23:37:24 +01:00
|
|
|
});
|
2018-02-13 17:26:20 +01:00
|
|
|
|
2018-02-14 09:05:34 +01:00
|
|
|
const exampleModule = new Dependencies['Example Module'];
|
2018-02-13 17:26:20 +01:00
|
|
|
Logger.log(`2+4=${exampleModule.add(2, 4)}`);
|
2018-01-31 09:32:20 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
onStop() {
|
2018-02-12 00:04:07 +01:00
|
|
|
Events.unsubscribeAll();
|
2018-02-11 23:07:23 +01:00
|
|
|
Logger.log('onStop');
|
2018-02-13 18:07:51 +01:00
|
|
|
console.log(this.showSettingsModal());
|
2018-01-23 14:19:55 +01:00
|
|
|
return true;
|
2018-01-16 02:45:23 +01:00
|
|
|
}
|
2018-02-12 00:04:07 +01:00
|
|
|
|
|
|
|
eventTest(e) {
|
|
|
|
Logger.log(e);
|
|
|
|
}
|
2018-02-12 16:20:27 +01:00
|
|
|
|
2018-02-13 17:43:44 +01:00
|
|
|
get bridge() {
|
2018-02-12 23:49:44 +01:00
|
|
|
return {
|
|
|
|
test1: this.test1.bind(this),
|
|
|
|
test2: this.test2.bind(this)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
test1() { return 'It works!'; }
|
|
|
|
test2() { return 'This works too!'; }
|
|
|
|
|
2018-02-12 16:20:27 +01:00
|
|
|
settingChanged(category, setting_id, value) {
|
|
|
|
if (!this.enabled) return;
|
|
|
|
Logger.log(`${category}/${setting_id} changed to ${value}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
settingsChanged(settings) {
|
|
|
|
if (!this.enabled) return;
|
|
|
|
Logger.log([ 'Settings updated', settings ]);
|
|
|
|
}
|
2018-01-16 02:45:23 +01:00
|
|
|
}
|
|
|
|
|
2018-02-12 16:20:27 +01:00
|
|
|
}
|