openwebrxplus-plugins

This utility plugin will give a function wrapping method and will send some events.
This plugin is a dependency for almost all plugins.

Features

Load

Add this lines in your init.js file (await ensures it finishes before dependents):

await Plugins.load('https://0xaf.github.io/openwebrxplus-plugins/receiver/utils/utils.js');
// load the rest of your plugins here

init.js

Learn how to load plugins.

API

Plugins.utils.wrap_func(name, before_cb, after_cb, obj)

Wrap a function and intercept calls before and/or after execution.

Plugins.utils.on_ready(callback)

Run callback once OpenWebRX+ has completed initialization.

Plugins.utils.deepMerge(target, ...sources)

Deeply merge one or more source objects into target and return the mutated target.

var defaults = {
	open: false,
	colors: {background: 'black', foreground: 'white'},
	steps: [100, 1000]
};
var options = {
	open: true,
	colors: {foreground: 'yellow'}
};

var settings = Plugins.utils.deepMerge({}, defaults, options);
// {
//   open: true,
//   colors: {background: 'black', foreground: 'yellow'},
//   steps: [100, 1000]
// }

Plugins.utils.observe_mutations(targets, options, callback, run_now)

Create one or more MutationObserver instances with a shared callback.

Returns an array of handles: { observer, target, disconnect }.

Example:

var handles = Plugins.utils.observe_mutations(
  [tabEl, rootEl],
  { attributes: true, attributeFilter: ['class'] },
  function () {
    refreshVisibility();
  },
  true
);

Plugins.utils.disconnect_observers(handles)

Disconnect handles returned by observe_mutations().

Plugins.utils.disconnect_observers(handles);

Code

Code is in the Github repo.