Replace deprecated String.substr with String.slice

This commit is contained in:
djmaze 2021-12-08 11:35:41 +01:00
parent 2719f08e26
commit b98762dd68
17 changed files with 54 additions and 54 deletions

View file

@ -140,8 +140,8 @@ export class HtmlEditor {
}
setHtmlOrPlain(text) {
if (':HTML:' === text.substr(0, 6)) {
this.setHtml(text.substr(6));
if (':HTML:' === text.slice(0, 6)) {
this.setHtml(text.slice(6));
} else {
this.setPlain(text);
}

View file

@ -81,8 +81,8 @@ export const
*/
themePreviewLink = theme => {
let prefix = VERSION_PREFIX;
if ('@custom' === theme.substr(-7)) {
theme = theme.substr(0, theme.length - 7).trim();
if ('@custom' === theme.slice(-7)) {
theme = theme.slice(0, theme.length - 7).trim();
prefix = Settings.app('webPath') || '';
}

View file

@ -10,16 +10,16 @@ const
i18nToNode = element => {
const key = element.dataset.i18n;
if (key) {
if ('[' === key.substr(0, 1)) {
switch (key.substr(0, 6)) {
if ('[' === key.slice(0, 1)) {
switch (key.slice(0, 6)) {
case '[html]':
element.innerHTML = i18n(key.substr(6));
element.innerHTML = i18n(key.slice(6));
break;
case '[place':
element.placeholder = i18n(key.substr(13));
element.placeholder = i18n(key.slice(13));
break;
case '[title':
element.title = i18n(key.substr(7));
element.title = i18n(key.slice(7));
break;
// no default
}

View file

@ -104,7 +104,7 @@ htmlToPlain = (html) => {
iP3 = text.indexOf('__bq__end__', iP1 + 5);
if ((-1 === iP2 || iP3 < iP2) && iP1 < iP3) {
text = text.substr(0, iP1) + convertBlockquote(text.substring(iP1 + 13, iP3)) + text.substr(iP3 + 11);
text = text.slice(0, iP1) + convertBlockquote(text.slice(iP1 + 13, iP3)) + text.slice(iP3 + 11);
pos = 0;
} else if (-1 < iP2 && iP2 < iP3) {
pos = iP2 - 1;
@ -135,12 +135,12 @@ plainToHtml = (plain) => {
bDo = false;
aNextText = [];
aText.forEach(sLine => {
bStart = '>' === sLine.substr(0, 1);
bStart = '>' === sLine.slice(0, 1);
if (bStart && !bIn) {
bDo = true;
bIn = true;
aNextText.push('~~~blockquote~~~');
aNextText.push(sLine.substr(1));
aNextText.push(sLine.slice(1));
} else if (!bStart && bIn) {
if (sLine) {
bIn = false;
@ -150,7 +150,7 @@ plainToHtml = (plain) => {
aNextText.push(sLine);
}
} else if (bStart && bIn) {
aNextText.push(sLine.substr(1));
aNextText.push(sLine.slice(1));
} else {
aNextText.push(sLine);
}
@ -344,10 +344,10 @@ mailToHelper = (mailToUrl) => {
'mailto:' ===
mailToUrl
.toString()
.substr(0, 7)
.slice(0, 7)
.toLowerCase()
) {
mailToUrl = mailToUrl.toString().substr(7);
mailToUrl = mailToUrl.toString().slice(7);
let to = [],
params = {};

View file

@ -142,7 +142,7 @@ export class EmailAddressesComponent {
values = [];
const v = val.trim(),
hook = (v && [',', ';', '\n'].includes(v.substr(-1)))
hook = (v && [',', ';', '\n'].includes(v.slice(-1)))
? EmailModel.splitEmailLine(val)
: null;

View file

@ -91,7 +91,7 @@ export class AbstractModel {
}
forEachObjectEntry(json, (key, value) => {
if ('@' !== key[0]) try {
key = key[0].toLowerCase() + key.substr(1);
key = key[0].toLowerCase() + key.slice(1);
switch (typeof this[key])
{
case 'function':

View file

@ -175,7 +175,7 @@ export class AttachmentModel extends AbstractModel {
const localEvent = event.originalEvent || event;
if (attachment && localEvent && localEvent.dataTransfer && localEvent.dataTransfer.setData) {
let link = this.linkDownload();
if ('http' !== link.substr(0, 4)) {
if ('http' !== link.slice(0, 4)) {
link = location.protocol + '//' + location.host + location.pathname + link;
}
localEvent.dataTransfer.setData('DownloadURL', this.mimeType + ':' + this.fileName + ':' + link);

View file

@ -104,8 +104,8 @@ export class AbstractFetchRemote
reader.read().then(processText);
return;
}
fCallback(buffer.substring(0, result.index));
buffer = buffer.substring(result.index + 1);
fCallback(buffer.slice(0, result.index));
buffer = buffer.slice(result.index + 1);
re.lastIndex = 0;
}
if (buffer.length) {

View file

@ -681,10 +681,10 @@ class ComposePopupView extends AbstractViewPopup {
if (identity) {
this.editor(editor => {
let signature = identity.signature(),
isHtml = signature && ':HTML:' === signature.substr(0, 6);
isHtml = signature && ':HTML:' === signature.slice(0, 6);
editor.setSignature(
this.convertSignature(isHtml ? signature.substr(6) : signature),
this.convertSignature(isHtml ? signature.slice(6) : signature),
isHtml, !!identity.signatureInsertBefore());
});
}
@ -1293,7 +1293,7 @@ class ComposePopupView extends AbstractViewPopup {
addMessageAsAttachment(message) {
if (message) {
let temp = message.subject();
temp = '.eml' === temp.substr(-4).toLowerCase() ? temp : temp + '.eml';
temp = '.eml' === temp.slice(-4).toLowerCase() ? temp : temp + '.eml';
const attachment = new ComposeAttachmentModel(message.requestHash, temp, message.size());

View file

@ -51,7 +51,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
}
return oKey.users.map(user => ({
id: oKey.guid,
name: '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
name: '(' + oKey.id.slice(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
key: oKey
}));
});
@ -66,7 +66,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
}
return oKey.users.map(user => ({
id: oKey.guid,
name: '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
name: '(' + oKey.id.slice(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
key: oKey
}));
});
@ -241,7 +241,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
empty: !option.key,
selected: ko.observable(!!option.key),
users: option.key.users,
hash: option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(),
hash: option.key.id.slice(KEY_NAME_SUBSTR).toUpperCase(),
key: option.key
});
}
@ -257,7 +257,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
selected: ko.observable(!!option.key),
removable: ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== option.key.id),
users: option.key.users,
hash: option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(),
hash: option.key.id.slice(KEY_NAME_SUBSTR).toUpperCase(),
key: option.key
});
}
@ -345,7 +345,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
if (keys && keys[0]) {
this.signKey({
users: keys[0].users || [emailLine],
hash: keys[0].id.substr(KEY_NAME_SUBSTR).toUpperCase(),
hash: keys[0].id.slice(KEY_NAME_SUBSTR).toUpperCase(),
key: keys[0]
});
}
@ -367,7 +367,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
!this.sign() || !this.signKey() || this.signKey().key.id !== publicKey.id
),
users: publicKey ? publicKey.users || [recEmail] : [recEmail],
hash: publicKey ? publicKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() : '',
hash: publicKey ? publicKey.id.slice(KEY_NAME_SUBSTR).toUpperCase() : '',
key: publicKey
}))
: [];

View file

@ -34,7 +34,7 @@ class FolderCreatePopupView extends AbstractViewPopup {
oItem =>
oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : '',
FolderUserStore.namespace
? item => FolderUserStore.namespace !== item.fullName.substr(0, FolderUserStore.namespace.length)
? item => FolderUserStore.namespace !== item.fullName.slice(0, FolderUserStore.namespace.length)
: null,
true
)
@ -50,7 +50,7 @@ class FolderCreatePopupView extends AbstractViewPopup {
createFolderCommand() {
let parentFolderName = this.selectedParentValue();
if (!parentFolderName && 1 < FolderUserStore.namespace.length) {
parentFolderName = FolderUserStore.namespace.substr(0, FolderUserStore.namespace.length - 1);
parentFolderName = FolderUserStore.namespace.slice(0, FolderUserStore.namespace.length - 1);
}
Remote.abort('Folders').post('FolderCreate', FolderUserStore.foldersCreating, {

View file

@ -99,7 +99,7 @@ try {
css.href = css.dataset.href;
loadScript(`./?/${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().substr(2)}/`)
loadScript(`./?/${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().slice(2)}/`)
.then(() => 0);
})(this);