зеркало из https://github.com/mozilla/email-tabs.git
fix js lint errors
This commit is contained in:
Родитель
449297d369
Коммит
c7c83e2fe3
|
@ -1,16 +1,18 @@
|
|||
/* globals TestPilotGA, emailTemplates */
|
||||
|
||||
browser.runtime.onMessage.addListener((message, source) => {
|
||||
if (message.type === "sendEmail") {
|
||||
sendEmail(message.tabIds).catch((e) => {
|
||||
console.error("Error sending email:", e, String(e), e.stack);
|
||||
})
|
||||
});
|
||||
// Note we don't need the popup to wait for us to send the email, so we return immediately:
|
||||
return Promise.resolve();
|
||||
} else if (message.type == "copyTabHtml") {
|
||||
} else if (message.type === "copyTabHtml") {
|
||||
return copyTabHtml(message.tabIds);
|
||||
} else if (message.type === "clearSelectionCache") {
|
||||
localStorage.removeItem("selectionCache");
|
||||
return null;
|
||||
} else if (message.type == "sendFailed") {
|
||||
} else if (message.type === "sendFailed") {
|
||||
loginInterrupt();
|
||||
return null;
|
||||
} else if (message.type === "closeComposeTab") {
|
||||
|
@ -28,7 +30,7 @@ browser.runtime.onMessage.addListener((message, source) => {
|
|||
|
||||
const manifest = browser.runtime.getManifest();
|
||||
|
||||
const is_production = ! manifest.version_name.includes("dev");
|
||||
const is_production = !manifest.version_name.includes("dev");
|
||||
|
||||
const ga = new TestPilotGA({
|
||||
an: "email-tabs",
|
||||
|
@ -118,32 +120,31 @@ async function copyTabHtml(tabIds) {
|
|||
|
||||
function copyHtmlToClipboard(html) {
|
||||
let container = document.createElement("div");
|
||||
container.innerHTML = html;
|
||||
container.innerHTML = html; // eslint-disable-line no-unsanitized/property
|
||||
document.body.appendChild(container);
|
||||
window.getSelection().removeAllRanges();
|
||||
let range = document.createRange();
|
||||
range.selectNode(container);
|
||||
window.getSelection().addRange(range)
|
||||
document.execCommand('copy');
|
||||
window.getSelection().addRange(range);
|
||||
document.execCommand("copy");
|
||||
}
|
||||
|
||||
let loginInterruptedTime;
|
||||
|
||||
function loginInterrupt() {
|
||||
// Note: this is a dumb flag for the popup:
|
||||
if (loginInterruptedTime && Date.now() - loginInterruptedTime < 30*1000) {
|
||||
if (loginInterruptedTime && Date.now() - loginInterruptedTime < 30 * 1000) {
|
||||
// We notified the user recently
|
||||
return;
|
||||
}
|
||||
loginInterruptedTime = Date.now();
|
||||
localStorage.setItem("loginInterrupt", String(Date.now()));
|
||||
return browser.notifications.create("notify-no-login", {
|
||||
browser.notifications.create("notify-no-login", {
|
||||
type: "basic",
|
||||
// iconUrl: "...",
|
||||
title: "Email sending failed",
|
||||
message: "Please try again after logging into your email"
|
||||
});
|
||||
console.error("Sending failed, probably due to login");
|
||||
}
|
||||
|
||||
async function closeManyTabs(composeTabId, otherTabInfo) {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* globals React, ReactDOMServer */
|
||||
|
||||
const { Fragment } = React;
|
||||
|
||||
this.emailTemplates = (function () {
|
||||
let exports = {};
|
||||
const SELECTION_TEXT_LIMIT = 1000; // 1000 characters max
|
||||
|
@ -8,7 +12,7 @@ this.emailTemplates = (function () {
|
|||
tab => <EmailTab key={tab.id} tab={tab} />
|
||||
);
|
||||
// Note that <React.Fragment> elements do not show up in the final HTML
|
||||
return <React.Fragment>{tabList}</React.Fragment>;
|
||||
return <Fragment>{tabList}</Fragment>;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +29,7 @@ this.emailTemplates = (function () {
|
|||
text = text.substr(0, SELECTION_TEXT_LIMIT) + "...";
|
||||
}
|
||||
text = `"${text}"`;
|
||||
selection = <React.Fragment>{text} <br /></React.Fragment>;
|
||||
selection = <Fragment>{text} <br /></Fragment>;
|
||||
}
|
||||
if (tab.screenshot) {
|
||||
// Note: the alt attribute is searched by gmail, but the title attribute is NOT searched
|
||||
|
@ -37,17 +41,17 @@ this.emailTemplates = (function () {
|
|||
domain = domain.replace(/^www\d?\./i, "");
|
||||
imgAlt = `Screenshot of ${domain}`;
|
||||
}
|
||||
img = <React.Fragment>
|
||||
img = <Fragment>
|
||||
<img style={{border: "1px solid #999"}} height={tab.screenshot.height} width={tab.screenshot.width} src={tab.screenshot.url} alt={imgAlt} />
|
||||
<br />
|
||||
</React.Fragment>;
|
||||
</Fragment>;
|
||||
}
|
||||
return <React.Fragment>
|
||||
return <Fragment>
|
||||
<a href={tab.url}>{tab.title}</a> <br />
|
||||
{ selection }
|
||||
{ img }
|
||||
<br />
|
||||
</React.Fragment>;
|
||||
</Fragment>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class Page extends React.Component {
|
|||
<TabList tabs={this.props.tabs} selected={this.props.selected} />
|
||||
</div>
|
||||
|
||||
<footer class="panel-footer toggle-enabled">
|
||||
<footer className="panel-footer toggle-enabled">
|
||||
<button onClick={this.copyTabs.bind(this)}>
|
||||
Copy Tabs to Clipboard
|
||||
</button>
|
||||
|
@ -131,7 +131,7 @@ class Page extends React.Component {
|
|||
sendTabs = sendTabs.map(tab => tab.id);
|
||||
await browser.runtime.sendMessage({
|
||||
type: "copyTabHtml",
|
||||
tabIds: sendTabs,
|
||||
tabIds: sendTabs
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.close();
|
||||
|
@ -142,7 +142,7 @@ class Page extends React.Component {
|
|||
class LoginError extends React.Component {
|
||||
render() {
|
||||
return <div id="login-error">
|
||||
Last attempt to send an email failed, probably because you weren't logged into your email.
|
||||
Last attempt to send an email failed, probably because you weren't logged into your email.
|
||||
Please make sure you are logged in, then try again.
|
||||
</div>;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ async function render(firstRun) {
|
|||
}
|
||||
|
||||
const selectionCache = {
|
||||
timeout: 30*60*1000, // 30 minutes
|
||||
timeout: 30 * 60 * 1000, // 30 minutes
|
||||
|
||||
key: "selectionCache",
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ function setHtml(html) {
|
|||
}
|
||||
// FIXME: if there are no good images in the email, then this will never be reached
|
||||
// (which is okay, nothing to fixup then, but...)
|
||||
for (let i=0; i<surlImages.length; i++) {
|
||||
for (let i = 0; i < surlImages.length; i++) {
|
||||
let image = surlImages[i];
|
||||
let savedAttributes = imageAttributeFixups[i];
|
||||
if (!savedAttributes || !savedAttributes.length) {
|
||||
|
@ -116,7 +116,7 @@ function showCloseButtons() {
|
|||
type: "closeTabs",
|
||||
closeTabInfo,
|
||||
composeTabId: thisTabId
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ function createIframe() {
|
|||
initPromise = new Promise((resolve, reject) => {
|
||||
let iframeUrl = browser.extension.getURL("gmail-iframe.html");
|
||||
iframe = document.createElement("iframe");
|
||||
iframe.id = "mozilla-email-tabs"
|
||||
iframe.id = "mozilla-email-tabs";
|
||||
iframe.src = iframeUrl;
|
||||
iframe.style.zIndex = "99999999999";
|
||||
iframe.style.border = "none";
|
||||
|
|
Загрузка…
Ссылка в новой задаче