diff --git a/gui/scripts/read.JS b/gui/scripts/read.JS index 76ef4a7..38fda2c 100644 --- a/gui/scripts/read.JS +++ b/gui/scripts/read.JS @@ -20,8 +20,8 @@ function load() { export default class texts { static universal (message_name) { /* Read a universal message name. */ - - // Load the strings here to avoid loading inside another web page, where it is not permitted. + + // Load the strings here to avoid loading inside another web page, where it is not permitted. load(); let message_name_valid = messages.universal.hasOwnProperty(message_name); @@ -44,28 +44,27 @@ export default class texts { } } -export function read(source, message_name, params) { - /* This reads the message from its source. This is a fallback for the content scripts, who doesn't appear to read classes. - - Parameters: - source: the source name, with accepted parameters "localized" and "fallback" - message: the message name - Returns: (string) the message - */ +/* This reads the message from its source. This is a fallback for the content scripts, who doesn't appear to read classes. - let message; +@param {string} source the source name, with accepted parameters "localized" and "fallback" +@param {string} message the message name +@return {string} the message +*/ +export function read(source, message_name, params) { + + let message; // Determine if a fallback is requested switch (source) { - case "universal": - case "fallback": + case "universal": + case "fallback": message = texts.universal(message_name); break; - default: + default: message = texts.localized(message_name, params); break; }; return (message); -} \ No newline at end of file +} diff --git a/scripts/fc.js b/scripts/fc.js index fa9859a..7b505be 100644 --- a/scripts/fc.js +++ b/scripts/fc.js @@ -8,9 +8,8 @@ let config = chrome.runtime.getURL('config/config.json'); export default class fc { + /* Start the out of the box experience. */ static hello() { - /* Start the out of the box experience. - */ // the OOBE must be in the config. fetch(config) @@ -29,11 +28,8 @@ export default class fc { }); }; + /* Initialize the configuration. */ static setup() { - /* Initialize the configuration. - - Returns: the initialization result - */ // the OOBE must be in the config. fetch(config) @@ -58,8 +54,8 @@ export default class fc { }); } + /* main function */ static run() { - /* main function */ fc.trigger(); } diff --git a/scripts/secretariat.js b/scripts/secretariat.js index ff7b8b4..4a4f7d6 100644 --- a/scripts/secretariat.js +++ b/scripts/secretariat.js @@ -2,14 +2,13 @@ Manage the local cache. */ -export function read(prefname, cloud = 0) { - /* Read all storeed data in the browser cache. +/* Read all storeed data in the browser cache. - Parameters: - prefname: (string) the preference name - cloud: (bool) determine cloud reading, which is otherwise set to automatic (0) - Returns: (Object) the preferences - */ +@param {string} prefname the preference name +@param {int} cloud determine cloud reading, which is otherwise set to automatic (0) +@return {dictionary} the preferences +*/ +export function read(prefname, cloud = 0) { // Initialize the selected pref data. let pref_data; @@ -38,14 +37,13 @@ export function read(prefname, cloud = 0) { return(pref_data); } -export function specifics(WHERE, domain) { - /* List the matching rule or memory for a particular domain. +/* List the matching rule or memory for a particular domain. - Parameters: - WHERE: the data source - domain: the website to check, which --- by default --- is the current website - Returns: (dictionary) the rules - */ +@param {string} WHERE the data source +@param {string} the data to check +@return {dictionary} the rules +*/ +export function specifics(WHERE, domain) { let result; @@ -106,15 +104,14 @@ export function specifics(WHERE, domain) { return(result); } -export function write(PREFERENCE, SUBPREFERENCE, DATA, CLOUD = 0) { - /* Write the data on the selected prefname. +/* Write the data on the selected prefname. - Parameters: - PREFERENCE: the preference name - DATA: the new data to be written - SUBPREFERENCE: the intermediate data - CLOUD: store in the cloud; otherwise set to automatic - */ +@param {string} PREFERENCE the preference name +@param {string} SUBPREFERENCE the subpreference +@param {object} DATA the new data to be written +@param {int} CLOUD store in the cloud; otherwise set to automatic +*/ +export function write(PREFERENCE, SUBPREFERENCE, DATA, CLOUD = 0) { let DATA_INJECTED = DATA; @@ -141,15 +138,14 @@ export function write(PREFERENCE, SUBPREFERENCE, DATA, CLOUD = 0) { }; } -export function forget(preference, subpreference, CLOUD = 0) { - /* Dangerous: Resets all data or a domain's data. +/* Dangerous: Resets all data or a domain's data. - Parameters: - prefernece: the preference name to delete - subpreference: the subpreference name to delete - CLOUD: the storage of the data - Returns: the user's confirmation - */ +@param {string} preference the preference name to delete +@param {string} subpreference the subpreference name to delete +@param {int} CLOUD the storage of the data +@return {boolean} the user's confirmation +*/ +export function forget(preference, subpreference, CLOUD = 0) { let forget_action = false; @@ -199,12 +195,11 @@ export function forget(preference, subpreference, CLOUD = 0) { return (forget_action); } -export function init(data) { - /* Initialize the storage. +/* Initialize the storage. - Parameters: - data: (dictionary) this build's managed data - */ +@param {dictionary} data this build's managed data +*/ +export function init(data) { let PREFERENCES_ALL = {}; PREFERENCES_ALL[`build`] = data; diff --git a/scripts/watchman.js b/scripts/watchman.js index dd25da3..fe19f14 100644 --- a/scripts/watchman.js +++ b/scripts/watchman.js @@ -8,13 +8,12 @@ Be sensitive to changes and update the state. let reader = await import(chrome.runtime.getURL("scripts/reader.js")); class watchman { - static observe(URL = window.location.href) { - /* Check the current URL. + /* Check the current URL. - Parameters: - URL: the page URL; default value is the current webpage - Returns: (dictionary) the filter to follow - */ + @param {string} URL the page URL; default value is the current webpage + @return {dictionary} the filter to follow + */ + static observe(URL = window.location.href) { // Create the variable to determine the corresponding key. let activity = false; @@ -26,21 +25,20 @@ Be sensitive to changes and update the state. return (activity); }; - static act(filters) { - /* Act on the page. + /* Act on the page. - Parameters: - filters: the filter to work with - Returns: the state - */ + @param {dictionary} filters the filter to work with + @return {boolean} the state + */ + static act(filters) { console.log("ShopAI works here! Click on the button in the toolbar or website to start."); // TODO } + /* Set the program to standby utnil next load. + */ static standby() { - /* Set the program to standby utnil next load. - */ console.log("ShopAI doesn't work here (yet). Expecting something? Try checking your filters. If you know what you're doing, feel free to create a filter yourself."); }