From e0486e49c6fc940d5478ea3fea017df881dd03b9 Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Thu, 21 Apr 2022 18:42:42 +0200 Subject: [PATCH] Replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher --- src/components/cardbuilder/cardBuilder.js | 4 ++-- src/plugins/bookPlayer/tableOfContents.js | 2 +- src/plugins/pdfPlayer/plugin.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/cardbuilder/cardBuilder.js b/src/components/cardbuilder/cardBuilder.js index c9c7b8ac04..be0df0e512 100644 --- a/src/components/cardbuilder/cardBuilder.js +++ b/src/components/cardbuilder/cardBuilder.js @@ -657,12 +657,12 @@ import { appRouter } from '../appRouter'; if (str) { const charIndex = Math.floor(str.length / 2); - const character = String(str.substr(charIndex, 1).charCodeAt()); + const character = String(str.slice(charIndex, charIndex + 1).charCodeAt()); let sum = 0; for (let i = 0; i < character.length; i++) { sum += parseInt(character.charAt(i)); } - const index = String(sum).substr(-1); + const index = String(sum).slice(-1); return (index % numRandomColors) + 1; } else { diff --git a/src/plugins/bookPlayer/tableOfContents.js b/src/plugins/bookPlayer/tableOfContents.js index 7736891e02..efbb533b22 100644 --- a/src/plugins/bookPlayer/tableOfContents.js +++ b/src/plugins/bookPlayer/tableOfContents.js @@ -70,7 +70,7 @@ export default class TableOfContents { tocHtml += '
  • '; // remove parent directory reference from href to fix certain books - const link = chapter.href.startsWith('../') ? chapter.href.substr(3) : chapter.href; + const link = chapter.href.startsWith('../') ? chapter.href.slice(3) : chapter.href; tocHtml += `${chapter.label}`; tocHtml += '
  • '; }); diff --git a/src/plugins/pdfPlayer/plugin.js b/src/plugins/pdfPlayer/plugin.js index 7532b5f062..35afc52a0a 100644 --- a/src/plugins/pdfPlayer/plugin.js +++ b/src/plugins/pdfPlayer/plugin.js @@ -263,7 +263,7 @@ export class PdfPlayer { for (const page of pages) { if (!this.pages[page]) { this.pages[page] = document.createElement('canvas'); - this.renderPage(this.pages[page], parseInt(page.substr(4))); + this.renderPage(this.pages[page], parseInt(page.slice(4))); } }