🚧 Make it work with async work
This commit is contained in:
parent
21d1e6f0ef
commit
e7aee8fbaa
@ -7,25 +7,19 @@ ext.runtime.onMessage.addListener(
|
|||||||
var data = JSON.parse(request.data);
|
var data = JSON.parse(request.data);
|
||||||
var url;
|
var url;
|
||||||
var token;
|
var token;
|
||||||
storage.get('url', function(resp) {
|
storage.get(['url', 'token'], function(resp) {
|
||||||
url = resp.url;
|
url = resp.url;
|
||||||
storage.get('token', function(resp) {
|
|
||||||
token = resp.token;
|
token = resp.token;
|
||||||
console.log("Extension Type: ", "/* @echo extension */");
|
|
||||||
console.log("PERFORM AJAX", request.data);
|
|
||||||
var destination = url+"?v=1&u="+encodeURIComponent(data.url)+"&t="+encodeURIComponent(data.title)+"&m="+encodeURIComponent(token);
|
var destination = url+"?v=1&u="+encodeURIComponent(data.url)+"&t="+encodeURIComponent(data.title)+"&m="+encodeURIComponent(token);
|
||||||
|
|
||||||
console.log("Destination: ", destination);
|
console.log("Destination: ", destination);
|
||||||
fetch(destination)
|
fetch(destination).then(function(response) {
|
||||||
.then(function(response) {
|
|
||||||
console.log(response);
|
console.log(response);
|
||||||
});
|
|
||||||
|
|
||||||
sendResponse({ action: "saved" });
|
sendResponse({ action: "saved" });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return true; // https://stackoverflow.com/a/20077854
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
@ -21,11 +21,11 @@ var template = (data) => {
|
|||||||
<button data-bookmark='${json}' id="save-btn" class="btn btn-primary">Save</button>
|
<button data-bookmark='${json}' id="save-btn" class="btn btn-primary">Save</button>
|
||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
}
|
};
|
||||||
var renderMessage = (message) => {
|
var renderMessage = (message) => {
|
||||||
var displayContainer = document.getElementById("display-container");
|
var displayContainer = document.getElementById("display-container");
|
||||||
displayContainer.innerHTML = `<p class='message'>${message}</p>`;
|
displayContainer.innerHTML = `<p class='message'>${message}</p>`;
|
||||||
}
|
};
|
||||||
|
|
||||||
var renderBookmark = (data) => {
|
var renderBookmark = (data) => {
|
||||||
var displayContainer = document.getElementById("display-container")
|
var displayContainer = document.getElementById("display-container")
|
||||||
@ -52,7 +52,7 @@ popup.addEventListener("click", function(e) {
|
|||||||
} else {
|
} else {
|
||||||
renderMessage("Sorry, there was an error while saving your bookmark.");
|
renderMessage("Sorry, there was an error while saving your bookmark.");
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -60,4 +60,4 @@ var optionsLink = document.querySelector(".js-options");
|
|||||||
optionsLink.addEventListener("click", function(e) {
|
optionsLink.addEventListener("click", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ext.tabs.create({'url': ext.extension.getURL('options.html')});
|
ext.tabs.create({'url': ext.extension.getURL('options.html')});
|
||||||
})
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user