ruffle/web/js-src/config.js

31 lines
1.1 KiB
JavaScript
Raw Normal View History

/**
* Retrieve the declarative configuration options of the given element.
*
* This is intended to be used with the HTML element of a page. It allows web
* pages to signal to both self-hosted and WebExtension versions of Ruffle what
* their authorial intent is.
*
* The following data attributes are recognized:
*
* * data-ruffle-optout - Signals to the Ruffle Extension that the page would
* like to opt out of having Ruffle loaded onto it. Has no effect on the
* self-hosted version of Ruffle.
* * data-ruffle-version - Indicates that this page self-hosts Ruffle, and
* optionally indicates the version of Ruffle present on the page.
*
* Defaults mentioned above are not applied by this function.
*/
export function get_config_options(elem) {
2019-10-06 16:29:15 +00:00
let values = JSON.parse(JSON.stringify(DEFAULT_CONFIG));
2019-10-06 16:29:15 +00:00
values.optout = elem.dataset.ruffleOptout !== undefined;
if (elem.dataset.ruffleVersion !== undefined) {
values.version = elem.dataset.ruffleVersion;
}
2019-10-06 16:29:15 +00:00
return values;
}
export const DEFAULT_CONFIG = {
"optout": false
};