PageAction: create settings input
This commit is contained in:
parent
56131220a2
commit
308d958578
|
@ -37,9 +37,7 @@ function shareCurrentTab(tab) {
|
||||||
*/
|
*/
|
||||||
function showPageAction(tabId){
|
function showPageAction(tabId){
|
||||||
browser.storage.local.get().then((storage) => {
|
browser.storage.local.get().then((storage) => {
|
||||||
if(storage.pageAction){
|
storage.pageAction ? browser.pageAction.show(tabId) : browser.pageAction.hide(tabId);
|
||||||
browser.pageAction.show(tabId);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div>URL: <input id="url" type="text"/></div>
|
<div>URL: <input id="url" type="text"/></div>
|
||||||
|
<div>Address Bar: <input id="pageAction" type="checkbox"/></div>
|
||||||
<input type="button" value="Save preferences" id="save-button"/>
|
<input type="button" value="Save preferences" id="save-button"/>
|
||||||
|
|
||||||
<script src="options.js"></script>
|
<script src="options.js"></script>
|
||||||
|
|
|
@ -1,26 +1,40 @@
|
||||||
/*
|
/**
|
||||||
Store options UI using browser.storage.local.
|
* Store options UI using browser.storage.local.
|
||||||
|
* @return {void} -
|
||||||
*/
|
*/
|
||||||
function storeSettings() {
|
function storeSettings() {
|
||||||
const url = document.querySelector("#url");
|
const settings = {
|
||||||
// console.log('storeSettings url');
|
url: document.querySelector("#url").value,
|
||||||
// console.log(url);
|
pageAction: document.querySelector("#pageAction").checked,
|
||||||
browser.storage.local.set({
|
};
|
||||||
url: url.value,
|
// console.log('storeSettings settings');
|
||||||
});
|
// console.log(settings);
|
||||||
|
browser.storage.local.set(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Update the options UI with the settings values retrieved from storage,
|
* Update the options UI with the settings values retrieved from storage,
|
||||||
or the default settings if the stored settings are empty.
|
* or the default settings if the stored settings are empty.
|
||||||
|
* @param {object} restoredSettings -
|
||||||
|
* @return {void} -
|
||||||
*/
|
*/
|
||||||
function updateUI(restoredSettings) {
|
function updateUI(restoredSettings) {
|
||||||
const url = document.querySelector("#url");
|
const url = document.querySelector("#url");
|
||||||
|
url.value = restoredSettings.url;
|
||||||
// console.log('restoredSettings url');
|
// console.log('restoredSettings url');
|
||||||
// console.log(url);
|
// console.log(url);
|
||||||
url.value = restoredSettings.url || "";
|
|
||||||
|
const pageAction = document.querySelector("#pageAction");
|
||||||
|
pageAction.checked = restoredSettings.pageAction;
|
||||||
|
// console.log('restoredSettings pageAction');
|
||||||
|
// console.log(pageAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display on error
|
||||||
|
* @param {object} error -
|
||||||
|
* @return {void} -
|
||||||
|
*/
|
||||||
function onError(e) {
|
function onError(e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue