make dashboard accesible from everywhere to Plugin Click, ctrl + enter just in domainspace
This commit is contained in:
parent
0c8ce940a8
commit
07f663abb0
5 changed files with 54 additions and 20 deletions
24
dashboard.js
24
dashboard.js
|
|
@ -1,9 +1,18 @@
|
|||
var buttonsize = 250;
|
||||
var baseUrl="";
|
||||
|
||||
document.addEventListener("keyup", (event) => {
|
||||
if (event.ctrlKey && event.code == "Enter") {
|
||||
console.log("pressed");
|
||||
var dashboard = document.querySelector('#lit-dashboard');
|
||||
if(document.location.host.includes(baseUrl))
|
||||
{
|
||||
doStuff();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function doStuff()
|
||||
{
|
||||
var dashboard = document.querySelector('#lit-dashboard');
|
||||
isFront = dashboard.style.display === 'block';
|
||||
viewportWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
|
||||
viewportHeight = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
|
||||
|
|
@ -13,8 +22,7 @@ document.addEventListener("keyup", (event) => {
|
|||
dashboard.style.position = "fixed";
|
||||
dashboard.style.zIndex = "3000";
|
||||
dashboard.style.display = isFront ? 'none' : 'block';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
|
|
@ -64,7 +72,6 @@ function createButtons(baseUrl, dashboard)
|
|||
|
||||
function setDashboard(baseUrl)
|
||||
{
|
||||
console.log(baseUrl);
|
||||
if (document.getElementById('lit-dashboard'))
|
||||
{
|
||||
dashboard = document.getElementById('lit-dashboard');
|
||||
|
|
@ -92,7 +99,7 @@ function setDashboard(baseUrl)
|
|||
// und gib ihm etwas Inhalt
|
||||
}
|
||||
function onGot(item) {
|
||||
let baseUrl = "demo.local-it.org";
|
||||
baseUrl = "demo.local-it.org";
|
||||
if (item.baseUrl) {
|
||||
baseUrl = item.baseUrl;
|
||||
}
|
||||
|
|
@ -101,3 +108,8 @@ function onGot(item) {
|
|||
|
||||
let getting = browser.storage.sync.get("baseUrl");
|
||||
getting.then(onGot, onError);
|
||||
|
||||
browser.runtime.onMessage.addListener(request => {
|
||||
doStuff();
|
||||
return Promise.resolve({response: ""});
|
||||
});
|
||||
Reference in a new issue