Optimizations.
This commit is contained in:
parent
399fb099dc
commit
4b5cfb1832
@ -5,12 +5,8 @@ var windowHeight
|
||||
function shareURL(){
|
||||
browser.tabs.query({active: true},function(tabs){
|
||||
|
||||
var gettingUrl = browser.storage.local.get("instance_url");
|
||||
gettingUrl.then(onGotUrl, onError);
|
||||
var gettingWidth = browser.storage.local.get("window_width");
|
||||
gettingWidth.then(onGotWidth, onError);
|
||||
var gettingHeight = browser.storage.local.get("window_height");
|
||||
gettingHeight.then(onGotHeight, onError);
|
||||
let gettingPrefs = browser.storage.local.get(["instance_url","window_width","window_height"]);
|
||||
gettingPrefs.then(onGot, onError);
|
||||
|
||||
var tab = tabs[0];
|
||||
|
||||
@ -51,22 +47,10 @@ function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
function onGotUrl(item) {
|
||||
if (item.instance_url) {
|
||||
instance = item.instance_url;
|
||||
}
|
||||
}
|
||||
|
||||
function onGotWidth(item) {
|
||||
if (item.window_width) {
|
||||
windowWidth = item.window_width;
|
||||
}
|
||||
}
|
||||
|
||||
function onGotHeight(item) {
|
||||
if (item.window_height) {
|
||||
windowHeight = item.window_height;
|
||||
}
|
||||
function onGot(item) {
|
||||
instance = item["instance_url"];
|
||||
windowWidth = item["window_width"];
|
||||
windowHeight = item["window_height"];
|
||||
}
|
||||
|
||||
browser.contextMenus.create({
|
||||
|
32
options.js
32
options.js
@ -1,42 +1,26 @@
|
||||
function saveOptions(e) {
|
||||
e.preventDefault();
|
||||
browser.storage.local.set({
|
||||
instance_url: document.querySelector("#instance_url").value
|
||||
});
|
||||
browser.storage.local.set({
|
||||
window_width: document.querySelector("#window_width").value
|
||||
});
|
||||
browser.storage.local.set({
|
||||
instance_url: document.querySelector("#instance_url").value ,
|
||||
window_width: document.querySelector("#window_width").value ,
|
||||
window_height: document.querySelector("#window_height").value
|
||||
});
|
||||
}
|
||||
|
||||
function restoreOptions() {
|
||||
|
||||
function setCurrentChoiceUrl(result) {
|
||||
document.querySelector("#instance_url").value = result.instance_url || "http://semanticscuttle.sourceforge.net/";
|
||||
}
|
||||
|
||||
function setCurrentChoiceWidth(result) {
|
||||
document.querySelector("#window_width").value = result.window_width || "640";
|
||||
}
|
||||
|
||||
function setCurrentChoiceHeight(result) {
|
||||
document.querySelector("#window_height").value = result.window_height || "480";
|
||||
function setCurrentChoices(result) {
|
||||
document.querySelector("#instance_url").value = result["instance_url"] || "http://semanticscuttle.sourceforge.net/";
|
||||
document.querySelector("#window_width").value = result["window_width"] || "640";
|
||||
document.querySelector("#window_height").value = result["window_height"] || "480";
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
var gettingUrl = browser.storage.local.get("instance_url");
|
||||
gettingUrl.then(setCurrentChoiceUrl, onError);
|
||||
|
||||
var gettingWidth = browser.storage.local.get("window_width");
|
||||
gettingWidth.then(setCurrentChoiceWidth, onError);
|
||||
|
||||
var gettingHeight = browser.storage.local.get("window_height");
|
||||
gettingHeight.then(setCurrentChoiceHeight, onError);
|
||||
var getting = browser.storage.local.get(["instance_url","window_width","window_height"]);
|
||||
getting.then(setCurrentChoices, onError);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user