docs: add documentation

This commit is contained in:
fuwaa 2022-07-21 13:51:54 +08:00
parent e15cc4c2f8
commit 662c79e761
No known key found for this signature in database
GPG key ID: 2E4F5DC11DE1D654

View file

@ -1,5 +1,10 @@
/*global chrome*/
/**
* Set a key and autoreload
* @param {string} setting - setting to update
* @param {string} value - Color to replace the current color with
*/
export function pintSet(setting, value) {
var pintKey = {};
pintKey[`${setting}`] = value;
@ -7,43 +12,35 @@ export function pintSet(setting, value) {
chrome.tabs.reload();
}
/**
* Set a key without reloading
* @param {string} setting - setting to update
* @param {string} value - Color to replace the current color with
*/
export function pintSetNoReload(setting, value) {
var pintKey = {};
pintKey[`${setting}`] = value;
chrome.storage.local.set(pintKey);
}
export function pintGet(setting, cb) {
var output = "";
chrome.storage.local.get([`${setting}`], function (result) {
output = result[`${setting}`];
cb(output);
});
}
/**
* Gets a setting and calls it back (normally used for react useState)
* @param {string} setting - get this setting
* @param {string} func - Function to Callback
*/
export function pintGetUpdate(setting, func) {
chrome.storage.local.get([`${setting}`], function (result) {
func(result[`${setting}`]);
});
}
export function updateMultiple(array, color) {
for (var i = 0; i < array.length; i++) {
pintSetNoReload(array[i], color);
/**
* Updates multiple settings at once
* @param {array} settings - settings of settings to update
* @param {string} color - Color to replace the current color with
*/
export function updateMultiple(settings, color) {
for (var i = 0; i < settings.length; i++) {
pintSetNoReload(settings[i], color);
}
}
// export function pintGet(setting) {
// pintGetInner(setting, finalReturn);
// alert(`returned value: ${value}`);
// return value;
// }
// export function (setting, callback) {
// callback(result[setting]);
// });
// };
// function finalReturn(finalValue) {
// alert(`result is: ${finalValue}`);
// value = finalValue
// }