2017-10-12 14:00:04 -05:00
|
|
|
/*jslint es6: true*/
|
2017-10-13 17:30:57 -05:00
|
|
|
/*global window, browser, chrome, Vue*/
|
2017-10-12 14:00:04 -05:00
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
2017-10-13 17:30:57 -05:00
|
|
|
const rootObject = (window.browser || window.chrome);
|
2017-10-12 14:00:04 -05:00
|
|
|
const doc = window.document;
|
|
|
|
const standards = window.WEB_API_MANAGER.standards;
|
|
|
|
const {storageLib, stateLib} = window.WEB_API_MANAGER;
|
|
|
|
const defaultDomain = "(default)";
|
|
|
|
|
|
|
|
const state = stateLib.generateStateObject(defaultDomain, standards);
|
|
|
|
|
2017-10-14 23:23:40 -05:00
|
|
|
const onSettingsLoaded = function (storedSettings) {
|
2017-10-12 14:00:04 -05:00
|
|
|
|
2017-10-14 23:23:40 -05:00
|
|
|
state.populateFromStorage(storedSettings);
|
2017-10-14 15:24:18 -05:00
|
|
|
|
2017-10-12 14:00:04 -05:00
|
|
|
const vm = new Vue({
|
|
|
|
el: doc.body,
|
|
|
|
data: state
|
|
|
|
});
|
|
|
|
|
|
|
|
const updateStoredSettings = function () {
|
2017-10-14 23:23:40 -05:00
|
|
|
storageLib.set(state.toStorage(), function () {
|
|
|
|
rootObject.runtime.sendMessage(["stateUpdate", state.toStorage()]);
|
2017-10-13 17:30:57 -05:00
|
|
|
});
|
2017-10-12 14:00:04 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
vm.$watch("selectedStandards", updateStoredSettings);
|
|
|
|
vm.$watch("domainNames", updateStoredSettings);
|
2017-10-14 23:23:40 -05:00
|
|
|
vm.$watch("shouldLog", updateStoredSettings);
|
2017-10-12 14:00:04 -05:00
|
|
|
};
|
|
|
|
|
2017-10-14 23:23:40 -05:00
|
|
|
window.onload = function () {
|
2017-10-12 14:00:04 -05:00
|
|
|
storageLib.get(onSettingsLoaded);
|
|
|
|
};
|
|
|
|
}());
|