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 = {};