mirror of
https://github.com/ryanamay/pint.git
synced 2024-09-20 01:50:34 +00:00
docs: add documentation
This commit is contained in:
parent
e15cc4c2f8
commit
662c79e761
1 changed files with 23 additions and 26 deletions
|
@ -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
|
||||
// }
|
||||
|
|
Loading…
Reference in a new issue