diff --git a/src/browser-action-assets/userSurvey.popupNoPrompt.html b/src/browser-action-assets/userSurvey.popupNoPrompt.html new file mode 100644 index 00000000..32332e28 --- /dev/null +++ b/src/browser-action-assets/userSurvey.popupNoPrompt.html @@ -0,0 +1,27 @@ + + + + + + + + +
+ +
+
+ + + diff --git a/src/browser-action-assets/userSurvey.popupNoPrompt.js b/src/browser-action-assets/userSurvey.popupNoPrompt.js new file mode 100644 index 00000000..4e5f7d4b --- /dev/null +++ b/src/browser-action-assets/userSurvey.popupNoPrompt.js @@ -0,0 +1,18 @@ +(async function() { + // Load the message from storage + const messageStorageKey = "webScience.userSurvey.popupNoPromptMessage"; + const messageResults = await browser.storage.local.get(messageStorageKey); + if(messageResults[messageStorageKey]) { + const contentElement = document.getElementById("content"); + contentElement.textContent = messageResults[messageStorageKey]; + } + + // Load icon URL from storage + const iconUrlStorageKey = "webScience.userSurvey.popupIconUrl"; + const iconUrlResults = await browser.storage.local.get(iconUrlStorageKey); + if(iconUrlResults[iconUrlStorageKey]) { + const iconElement = document.getElementById("icon"); + iconElement.src = iconUrlResults[iconUrlStorageKey]; + iconElement.style.display = "block"; + } +})(); diff --git a/src/html/userSurvey.popupPrompt.html b/src/browser-action-assets/userSurvey.popupPrompt.html similarity index 58% rename from src/html/userSurvey.popupPrompt.html rename to src/browser-action-assets/userSurvey.popupPrompt.html index 5bf76835..78565679 100644 --- a/src/html/userSurvey.popupPrompt.html +++ b/src/browser-action-assets/userSurvey.popupPrompt.html @@ -76,39 +76,6 @@ Never Continue - + diff --git a/src/browser-action-assets/userSurvey.popupPrompt.js b/src/browser-action-assets/userSurvey.popupPrompt.js new file mode 100644 index 00000000..1fef19a1 --- /dev/null +++ b/src/browser-action-assets/userSurvey.popupPrompt.js @@ -0,0 +1,32 @@ +(async function() { + // Load the message from storage + const messageStorageKey = "webScience.userSurvey.popupPromptMessage"; + const messageResults = await browser.storage.local.get(messageStorageKey); + if(messageResults[messageStorageKey]) { + const contentElement = document.getElementById("content"); + contentElement.textContent = messageResults[messageStorageKey]; + } + + // Load icon URL from storage + const iconUrlStorageKey = "webScience.userSurvey.popupIconUrl"; + const iconUrlResults = await browser.storage.local.get(iconUrlStorageKey); + if(iconUrlResults[iconUrlStorageKey]) { + const iconElement = document.getElementById("icon"); + iconElement.src = iconUrlResults[iconUrlStorageKey]; + iconElement.style.display = "block"; + } + + // Listen for clicks on the buttons + document.addEventListener("click", async (e) => { + if (e.target.name === "agree") { + await browser.runtime.sendMessage({ type: "webScience.userSurvey.openSurvey" }); + } + else if (e.target.name === "later") { + window.close(); + } + else if (e.target.name === "never") { + await browser.runtime.sendMessage({ type: "webScience.userSurvey.cancelSurvey" }); + window.close(); + } + }); +})(); diff --git a/src/html/userSurvey.popupNoPrompt.html b/src/html/userSurvey.popupNoPrompt.html deleted file mode 100644 index 1fea8d16..00000000 --- a/src/html/userSurvey.popupNoPrompt.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - -
- -
-
- - - diff --git a/src/userSurvey.js b/src/userSurvey.js index 9ac04d96..3d3eb5e8 100644 --- a/src/userSurvey.js +++ b/src/userSurvey.js @@ -36,8 +36,8 @@ import * as timing from "./timing.js"; import * as storage from "./storage.js"; import * as messaging from "./messaging.js"; import * as permissions from "./permissions.js"; -import popupPromptPage from "include:./html/userSurvey.popupPrompt.html"; -import popupNoPromptPage from "include:./html/userSurvey.popupNoPrompt.html"; +import popupPromptPage from "include:./browser-action-assets/userSurvey.popupPrompt.html"; +import popupNoPromptPage from "include:./browser-action-assets/userSurvey.popupNoPrompt.html"; /** * A persistent storage space for data about surveys.