Merge pull request #1517 from Jo-IE/edit-tooltip-html

remove HTML entities from tooltip
This commit is contained in:
luke crouch 2019-10-16 10:42:38 -05:00 committed by GitHub
commit d04252a5ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,7 +32,7 @@ const P_CONTAINERS_ACHIEVEMENT = "containersAchievement";
* @return {string} The escaped string.
*/
function escapeXML(str) {
const replacements = {"&": "&amp;", "\"": "&quot;", "'": "&apos;", "<": "&lt;", ">": "&gt;", "/": "&#x2F;"};
const replacements = { "&": "&amp;", "\"": "&quot;", "'": "&apos;", "<": "&lt;", ">": "&gt;", "/": "&#x2F;" };
return String(str).replace(/[&"'<>/]/g, m => replacements[m]);
}
@ -85,7 +85,7 @@ const Logic = {
try {
await identitiesPromise;
} catch(e) {
} catch (e) {
throw new Error("Failed to retrieve the identities or variation. We cannot continue. ", e.message);
}
@ -125,7 +125,7 @@ const Logic = {
async showAchievementOrContainersListPanel() {
// Do we need to show an achievement panel?
let showAchievements = false;
const achievementsStorage = await browser.storage.local.get({achievements: []});
const achievementsStorage = await browser.storage.local.get({ achievements: [] });
for (const achievement of achievementsStorage.achievements) {
if (!achievement.done) {
showAchievements = true;
@ -142,7 +142,7 @@ const Logic = {
// they have to click the "Done" button to stop the panel
// from showing
async setAchievementDone(achievementName) {
const achievementsStorage = await browser.storage.local.get({achievements: []});
const achievementsStorage = await browser.storage.local.get({ achievements: [] });
const achievements = achievementsStorage.achievements;
achievements.forEach((achievement, index, achievementsArray) => {
if (achievement.name === achievementName) {
@ -150,7 +150,7 @@ const Logic = {
achievementsArray[index] = achievement;
}
});
browser.storage.local.set({achievements});
browser.storage.local.set({ achievements });
},
setOnboardingStage(stage) {
@ -161,9 +161,9 @@ const Logic = {
async clearBrowserActionBadge() {
const extensionInfo = await getExtensionInfo();
const storage = await browser.storage.local.get({browserActionBadgesClicked: []});
browser.browserAction.setBadgeBackgroundColor({color: null});
browser.browserAction.setBadgeText({text: ""});
const storage = await browser.storage.local.get({ browserActionBadgesClicked: [] });
browser.browserAction.setBadgeBackgroundColor({ color: null });
browser.browserAction.setBadgeText({ text: "" });
storage.browserActionBadgesClicked.push(extensionInfo.version);
// use set and spread to create a unique array
const browserActionBadgesClicked = [...new Set(storage.browserActionBadgesClicked)];
@ -184,7 +184,7 @@ const Logic = {
// Handle old style rejection with null and also Promise.reject new style
try {
return await browser.contextualIdentities.get(cookieStoreId) || defaultContainer;
} catch(e) {
} catch (e) {
return defaultContainer;
}
},
@ -207,7 +207,7 @@ const Logic = {
},
async currentTab() {
const activeTabs = await browser.tabs.query({active: true, windowId: browser.windows.WINDOW_ID_CURRENT});
const activeTabs = await browser.tabs.query({ active: true, windowId: browser.windows.WINDOW_ID_CURRENT });
if (activeTabs.length > 0) {
return activeTabs[0];
}
@ -215,7 +215,7 @@ const Logic = {
},
async numTabs() {
const activeTabs = await browser.tabs.query({windowId: browser.windows.WINDOW_ID_CURRENT});
const activeTabs = await browser.tabs.query({ windowId: browser.windows.WINDOW_ID_CURRENT });
return activeTabs.length;
},
@ -333,7 +333,7 @@ const Logic = {
return browser.runtime.sendMessage({
method: "deleteContainer",
message: {userContextId}
message: { userContextId }
});
},
@ -347,7 +347,7 @@ const Logic = {
getAssignmentObjectByContainer(userContextId) {
return browser.runtime.sendMessage({
method: "getAssignmentObjectByContainer",
message: {userContextId}
message: { userContextId }
});
},
@ -376,7 +376,7 @@ const Logic = {
});
// Here we find the first valid id.
for (let id = 1;; ++id) {
for (let id = 1; ; ++id) {
if (ids.indexOf(id) === -1) {
return defaultName + (id < 10 ? "0" : "") + id;
}
@ -511,7 +511,7 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
});
Logic.addEnterHandler(document.querySelector("#edit-containers-link"), (e) => {
if (!e.target.classList.contains("disable-edit-containers")){
if (!e.target.classList.contains("disable-edit-containers")) {
Logic.showPanel(P_CONTAINERS_EDIT);
}
});
@ -637,9 +637,9 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
context.classList.add("userContext-wrapper", "open-newtab", "clickable");
manage.classList.add("show-tabs", "pop-button");
manage.title = escaped`View ${identity.name} container`;
manage.setAttribute("title", `View ${identity.name} container`);
context.setAttribute("tabindex", "0");
context.title = escaped`Create ${identity.name} tab`;
context.setAttribute("title", `Create ${identity.name} tab`);
context.innerHTML = escaped`
<div class="userContext-icon-wrapper open-newtab">
<div class="usercontext-icon"
@ -830,7 +830,7 @@ Logic.registerPanel(P_CONTAINER_INFO, {
tr.classList.add("clickable");
Logic.addEnterHandler(tr, async () => {
await browser.tabs.update(tab.id, {active: true});
await browser.tabs.update(tab.id, { active: true });
window.close();
});
@ -1018,7 +1018,7 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
return escaped`<input type="radio" value="${containerColor}" name="container-color" id="edit-container-panel-choose-color-${containerColor}" />
<label for="edit-container-panel-choose-color-${containerColor}" class="usercontext-icon choose-color-icon" data-identity-icon="circle" data-identity-color="${containerColor}">`;
};
const colors = ["blue", "turquoise", "green", "yellow", "orange", "red", "pink", "purple" ];
const colors = ["blue", "turquoise", "green", "yellow", "orange", "red", "pink", "purple"];
const colorRadioFieldset = document.getElementById("edit-container-panel-choose-color");
colors.forEach((containerColor) => {
const templateInstance = document.createElement("div");
@ -1093,7 +1093,7 @@ Logic.registerPanel(P_CONTAINER_DELETE, {
await Logic.removeIdentity(Logic.userContextId(Logic.currentIdentity().cookieStoreId));
await Logic.refreshIdentities();
Logic.showPreviousPanel();
} catch(e) {
} catch (e) {
Logic.showPanel(P_CONTAINERS_LIST);
}
});