mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Made eslint using 'browser' environment and added globals, because RainLoop is used in browsers.
This also allowed to remove all webpack 'externals' overhead.
This commit is contained in:
parent
c3a213802d
commit
e7180a86ce
81 changed files with 1857 additions and 1259 deletions
|
|
@ -1,7 +1,4 @@
|
|||
import window from 'window';
|
||||
import ko from 'ko';
|
||||
import key from 'key';
|
||||
import ssm from 'ssm';
|
||||
|
||||
import {
|
||||
$win,
|
||||
|
|
@ -35,7 +32,7 @@ class AbstractApp extends AbstractBoot {
|
|||
this.isLocalAutocomplete = true;
|
||||
this.lastErrorTime = 0;
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
addEventListener('resize', () => {
|
||||
Events.pub('window.resize');
|
||||
});
|
||||
|
||||
|
|
@ -64,14 +61,14 @@ class AbstractApp extends AbstractBoot {
|
|||
// DEBUG
|
||||
// Events.sub({
|
||||
// 'window.resize': function() {
|
||||
// window.console.log('window.resize');
|
||||
// console.log('window.resize');
|
||||
// },
|
||||
// 'window.resize.real': function() {
|
||||
// window.console.log('window.resize.real');
|
||||
// console.log('window.resize.real');
|
||||
// }
|
||||
// });
|
||||
|
||||
const $doc = window.document;
|
||||
const $doc = document;
|
||||
$doc.addEventListener('keydown', (event) => {
|
||||
if (event && event.ctrlKey) {
|
||||
$htmlCL.add('rl-ctrl-key-pressed');
|
||||
|
|
@ -117,14 +114,14 @@ class AbstractApp extends AbstractBoot {
|
|||
*/
|
||||
download(link) {
|
||||
if (bMobileDevice) {
|
||||
window.open(link, '_self');
|
||||
window.focus();
|
||||
open(link, '_self');
|
||||
focus();
|
||||
} else {
|
||||
const oLink = window.document.createElement('a');
|
||||
const oLink = document.createElement('a');
|
||||
oLink.href = link;
|
||||
window.document.body.appendChild(oLink).click();
|
||||
document.body.appendChild(oLink).click();
|
||||
oLink.remove();
|
||||
// window.open(link, '_self');
|
||||
// open(link, '_self');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -138,18 +135,18 @@ class AbstractApp extends AbstractBoot {
|
|||
title += (title ? ' - ' : '') + Settings.settingsGet('Title');
|
||||
}
|
||||
|
||||
window.document.title = title;
|
||||
document.title = title;
|
||||
}
|
||||
|
||||
redirectToAdminPanel() {
|
||||
setTimeout(() => {
|
||||
window.location.href = rootAdmin();
|
||||
location.href = rootAdmin();
|
||||
}, Magics.Time100ms);
|
||||
}
|
||||
|
||||
clearClientSideToken() {
|
||||
if (window.__rlah_clear) {
|
||||
window.__rlah_clear();
|
||||
__rlah_clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +155,7 @@ class AbstractApp extends AbstractBoot {
|
|||
*/
|
||||
setClientSideToken(token) {
|
||||
if (window.__rlah_set) {
|
||||
window.__rlah_set(token);
|
||||
__rlah_set(token);
|
||||
|
||||
Settings.settingsSet('AuthAccountHash', token);
|
||||
populateAuthSuffix();
|
||||
|
|
@ -184,12 +181,12 @@ class AbstractApp extends AbstractBoot {
|
|||
|
||||
customLogoutLink = customLogoutLink || (admin ? rootAdmin() : rootUser());
|
||||
|
||||
if (logout && window.location.href !== customLogoutLink) {
|
||||
if (logout && location.href !== customLogoutLink) {
|
||||
setTimeout(() => {
|
||||
if (inIframe && window.parent) {
|
||||
window.parent.location.href = customLogoutLink;
|
||||
if (inIframe && parent) {
|
||||
parent.location.href = customLogoutLink;
|
||||
} else {
|
||||
window.location.href = customLogoutLink;
|
||||
location.href = customLogoutLink;
|
||||
}
|
||||
|
||||
$win.trigger('rl.tooltips.diactivate');
|
||||
|
|
@ -200,10 +197,10 @@ class AbstractApp extends AbstractBoot {
|
|||
routeOff();
|
||||
|
||||
setTimeout(() => {
|
||||
if (inIframe && window.parent) {
|
||||
window.parent.location.reload();
|
||||
if (inIframe && parent) {
|
||||
parent.location.reload();
|
||||
} else {
|
||||
window.location.reload();
|
||||
location.reload();
|
||||
}
|
||||
|
||||
$win.trigger('rl.tooltips.diactivate');
|
||||
|
|
@ -212,12 +209,10 @@ class AbstractApp extends AbstractBoot {
|
|||
}
|
||||
|
||||
historyBack() {
|
||||
window.history.back();
|
||||
history.back();
|
||||
}
|
||||
|
||||
bootstart() {
|
||||
// log('Ps' + 'ss, hac' + 'kers! The' + 're\'s not' + 'hing inte' + 'resting :' + ')');
|
||||
|
||||
Events.pub('rl.bootstart');
|
||||
|
||||
const mobile = Settings.appSettingsGet('mobile');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import window from 'window';
|
||||
import ko from 'ko';
|
||||
|
||||
import { root } from 'Common/Links';
|
||||
|
|
@ -110,7 +109,7 @@ class AdminApp extends AbstractApp {
|
|||
CoreStore.coreVersionCompare(-2);
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
CoreStore.coreReal(true);
|
||||
window.location.reload();
|
||||
location.reload();
|
||||
} else {
|
||||
CoreStore.coreReal(false);
|
||||
}
|
||||
|
|
@ -182,7 +181,7 @@ class AdminApp extends AbstractApp {
|
|||
|
||||
bootend(bootendCallback = null) {
|
||||
if (window.progressJs) {
|
||||
window.progressJs.end();
|
||||
progressJs.end();
|
||||
}
|
||||
|
||||
if (bootendCallback) {
|
||||
|
|
@ -204,7 +203,7 @@ class AdminApp extends AbstractApp {
|
|||
routeOff();
|
||||
|
||||
setTimeout(() =>
|
||||
window.location.href = '/'
|
||||
location.href = '/'
|
||||
, 1);
|
||||
} else {
|
||||
if (Settings.settingsGet('Auth')) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import window from 'window';
|
||||
|
||||
import {
|
||||
log,
|
||||
isNormal,
|
||||
isPosNumeric,
|
||||
isNonEmptyArray,
|
||||
|
|
@ -86,12 +83,12 @@ import { hideLoading, routeOff, routeOn, setHash, startScreens, showScreenPopup
|
|||
|
||||
import { AbstractApp } from 'App/Abstract';
|
||||
|
||||
const doc = window.document;
|
||||
const doc = document;
|
||||
|
||||
if (!window.ResizeObserver) {
|
||||
window.ResizeObserver = class {
|
||||
constructor(callback) {
|
||||
this.observer = new window.MutationObserver(mutations => {
|
||||
this.observer = new MutationObserver(mutations => {
|
||||
let entries = [];
|
||||
mutations.forEach(mutation => {
|
||||
if ('style' == mutation.attributeName) {
|
||||
|
|
@ -133,19 +130,19 @@ class AppUser extends AbstractApp {
|
|||
|
||||
this.moveOrDeleteResponseHelper = this.moveOrDeleteResponseHelper.bind(this);
|
||||
|
||||
window.setInterval(() => Events.pub('interval.30s'), Magics.Time30s);
|
||||
window.setInterval(() => Events.pub('interval.1m'), Magics.Time1m);
|
||||
window.setInterval(() => Events.pub('interval.2m'), Magics.Time2m);
|
||||
window.setInterval(() => Events.pub('interval.3m'), Magics.Time3m);
|
||||
window.setInterval(() => Events.pub('interval.5m'), Magics.Time5m);
|
||||
window.setInterval(() => Events.pub('interval.10m'), Magics.Time10m);
|
||||
window.setInterval(() => Events.pub('interval.15m'), Magics.Time15m);
|
||||
window.setInterval(() => Events.pub('interval.20m'), Magics.Time20m);
|
||||
setInterval(() => Events.pub('interval.30s'), Magics.Time30s);
|
||||
setInterval(() => Events.pub('interval.1m'), Magics.Time1m);
|
||||
setInterval(() => Events.pub('interval.2m'), Magics.Time2m);
|
||||
setInterval(() => Events.pub('interval.3m'), Magics.Time3m);
|
||||
setInterval(() => Events.pub('interval.5m'), Magics.Time5m);
|
||||
setInterval(() => Events.pub('interval.10m'), Magics.Time10m);
|
||||
setInterval(() => Events.pub('interval.15m'), Magics.Time15m);
|
||||
setInterval(() => Events.pub('interval.20m'), Magics.Time20m);
|
||||
|
||||
window.setTimeout(() => window.setInterval(() => Events.pub('interval.2m-after5m'), Magics.Time2m), Magics.Time5m);
|
||||
window.setTimeout(() => window.setInterval(() => Events.pub('interval.5m-after5m'), Magics.Time5m), Magics.Time5m);
|
||||
window.setTimeout(
|
||||
() => window.setInterval(() => Events.pub('interval.10m-after5m'), Magics.Time10m),
|
||||
setTimeout(() => setInterval(() => Events.pub('interval.2m-after5m'), Magics.Time2m), Magics.Time5m);
|
||||
setTimeout(() => setInterval(() => Events.pub('interval.5m-after5m'), Magics.Time5m), Magics.Time5m);
|
||||
setTimeout(
|
||||
() => setInterval(() => Events.pub('interval.10m-after5m'), Magics.Time10m),
|
||||
Magics.Time5m
|
||||
);
|
||||
|
||||
|
|
@ -187,10 +184,10 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
|
||||
reload() {
|
||||
if (window.parent && !!Settings.appSettingsGet('inIframe')) {
|
||||
window.parent.location.reload();
|
||||
if (parent && !!Settings.appSettingsGet('inIframe')) {
|
||||
parent.location.reload();
|
||||
} else {
|
||||
window.location.reload();
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -346,7 +343,7 @@ class AppUser extends AbstractApp {
|
|||
setFolderHash(FolderStore.currentFolderFullNameRaw(), '');
|
||||
|
||||
if (oData && [Notification.CantMoveMessage, Notification.CantCopyMessage].includes(oData.ErrorCode)) {
|
||||
window.alert(getNotification(oData.ErrorCode));
|
||||
alert(getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -917,7 +914,7 @@ class AppUser extends AbstractApp {
|
|||
source.classList.add('resizable');
|
||||
if (!source.querySelector('.resizer')) {
|
||||
const resizer = doc.createElement('div'),
|
||||
cssint = s => parseFloat(window.getComputedStyle(source, null).getPropertyValue(s).replace('px', ''));
|
||||
cssint = s => parseFloat(getComputedStyle(source, null).getPropertyValue(s).replace('px', ''));
|
||||
resizer.className = 'resizer';
|
||||
source.appendChild(resizer);
|
||||
resizer.addEventListener('mousedown', {
|
||||
|
|
@ -930,26 +927,26 @@ class AppUser extends AbstractApp {
|
|||
this.min = cssint('min-'+this.mode);
|
||||
this.max = cssint('max-'+this.mode);
|
||||
this.org = cssint(this.mode);
|
||||
window.addEventListener('mousemove', this);
|
||||
window.addEventListener('mouseup', this);
|
||||
addEventListener('mousemove', this);
|
||||
addEventListener('mouseup', this);
|
||||
} else if ('mousemove' == e.type) {
|
||||
const length = this.org + (('width' == this.mode ? e.pageX : e.pageY) - this.pos);
|
||||
if (length >= this.min && length <= this.max ) {
|
||||
this.source.style[this.mode] = length + 'px';
|
||||
}
|
||||
} else if ('mouseup' == e.type) {
|
||||
window.removeEventListener('mousemove', this);
|
||||
window.removeEventListener('mouseup', this);
|
||||
removeEventListener('mousemove', this);
|
||||
removeEventListener('mouseup', this);
|
||||
}
|
||||
}
|
||||
});
|
||||
if ('width' == mode) {
|
||||
source.observer = new window.ResizeObserver(() => {
|
||||
source.observer = new ResizeObserver(() => {
|
||||
target.style.left = source.offsetWidth + 'px';
|
||||
Local.set(sClientSideKeyName, source.offsetWidth);
|
||||
});
|
||||
} else {
|
||||
source.observer = new window.ResizeObserver(() => {
|
||||
source.observer = new ResizeObserver(() => {
|
||||
target.style.top = (4 + source.offsetTop + source.offsetHeight) + 'px';
|
||||
Local.set(sClientSideKeyName, source.offsetHeight);
|
||||
});
|
||||
|
|
@ -1032,14 +1029,14 @@ class AppUser extends AbstractApp {
|
|||
routeOff();
|
||||
|
||||
setTimeout(() =>
|
||||
window.location.href = customLoginLink
|
||||
location.href = customLoginLink
|
||||
, 1);
|
||||
}
|
||||
}
|
||||
|
||||
bootend() {
|
||||
if (window.progressJs) {
|
||||
window.progressJs.set(100).end();
|
||||
progressJs.set(100).end();
|
||||
}
|
||||
hideLoading();
|
||||
}
|
||||
|
|
@ -1058,7 +1055,7 @@ class AppUser extends AbstractApp {
|
|||
const startupUrl = pString(Settings.settingsGet('StartupUrl'));
|
||||
|
||||
if (window.progressJs) {
|
||||
window.progressJs.set(90);
|
||||
progressJs.set(90);
|
||||
}
|
||||
|
||||
leftPanelDisabled.subscribe((value) => {
|
||||
|
|
@ -1091,15 +1088,18 @@ class AppUser extends AbstractApp {
|
|||
routeOn();
|
||||
}
|
||||
|
||||
if (window.crypto && window.crypto.getRandomValues && Settings.capa(Capa.OpenPGP)) {
|
||||
const openpgpCallback = (openpgp) => {
|
||||
if (window.crypto && crypto.getRandomValues && Settings.capa(Capa.OpenPGP)) {
|
||||
const openpgpCallback = () => {
|
||||
if (!window.openpgp) {
|
||||
return false;
|
||||
}
|
||||
PgpStore.openpgp = openpgp;
|
||||
|
||||
if (window.Worker) {
|
||||
try {
|
||||
PgpStore.openpgp.initWorker({ path: openPgpWorkerJs() });
|
||||
} catch (e) {
|
||||
log(e);
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1109,22 +1109,16 @@ class AppUser extends AbstractApp {
|
|||
Events.pub('openpgp.init');
|
||||
|
||||
this.reloadOpenPgpKeys();
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
if (window.openpgp) {
|
||||
openpgpCallback(window.openpgp);
|
||||
} else {
|
||||
new window.Promise((resolve, reject) => {
|
||||
const script = doc.createElement('script');
|
||||
script.onload = () => resolve();
|
||||
script.onerror = () => reject(new Error(script.src));
|
||||
script.src = openPgpJs();
|
||||
doc.head.appendChild(script);
|
||||
}).then(() => {
|
||||
if (window.openpgp) {
|
||||
openpgpCallback(window.openpgp);
|
||||
}
|
||||
});
|
||||
if (!openpgpCallback()) {
|
||||
const script = doc.createElement('script');
|
||||
script.onload = openpgpCallback;
|
||||
script.onerror = () => console.error(script.src);
|
||||
script.src = openPgpJs();
|
||||
doc.head.appendChild(script);
|
||||
}
|
||||
} else {
|
||||
PgpStore.capaOpenPGP(false);
|
||||
|
|
@ -1154,7 +1148,7 @@ class AppUser extends AbstractApp {
|
|||
setTimeout(() => this.contactsSync(), Magics.Time10s);
|
||||
setTimeout(() => this.folderInformationMultiply(true), Magics.Time2s);
|
||||
|
||||
window.setInterval(() => this.contactsSync(), contactsSyncInterval * 60000 + 5000);
|
||||
setInterval(() => this.contactsSync(), contactsSyncInterval * 60000 + 5000);
|
||||
|
||||
this.accountsAndIdentities(true);
|
||||
|
||||
|
|
@ -1179,14 +1173,14 @@ class AppUser extends AbstractApp {
|
|||
|
||||
if (
|
||||
!!Settings.settingsGet('AccountSignMe') &&
|
||||
window.navigator.registerProtocolHandler &&
|
||||
navigator.registerProtocolHandler &&
|
||||
Settings.capa(Capa.Composer)
|
||||
) {
|
||||
setTimeout(() => {
|
||||
try {
|
||||
window.navigator.registerProtocolHandler(
|
||||
navigator.registerProtocolHandler(
|
||||
'mailto',
|
||||
window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s',
|
||||
location.protocol + '//' + location.host + location.pathname + '?mailto&to=%s',
|
||||
'' + (Settings.settingsGet('Title') || 'RainLoop')
|
||||
);
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue