Merge pull request #3582 from CommanderRoot/refactor/rm-deprecated-substr

Replace deprecated String.prototype.substr()
This commit is contained in:
Bill Thornton 2022-04-25 17:11:32 -04:00 committed by GitHub
commit 3b343276cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -657,12 +657,12 @@ import { appRouter } from '../appRouter';
if (str) { if (str) {
const charIndex = Math.floor(str.length / 2); 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; let sum = 0;
for (let i = 0; i < character.length; i++) { for (let i = 0; i < character.length; i++) {
sum += parseInt(character.charAt(i)); sum += parseInt(character.charAt(i));
} }
const index = String(sum).substr(-1); const index = String(sum).slice(-1);
return (index % numRandomColors) + 1; return (index % numRandomColors) + 1;
} else { } else {

View File

@ -70,7 +70,7 @@ export default class TableOfContents {
tocHtml += '<li>'; tocHtml += '<li>';
// remove parent directory reference from href to fix certain books // 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 += `<a href="${rendition.book.path.directory + link}">${chapter.label}</a>`; tocHtml += `<a href="${rendition.book.path.directory + link}">${chapter.label}</a>`;
tocHtml += '</li>'; tocHtml += '</li>';
}); });

View File

@ -263,7 +263,7 @@ export class PdfPlayer {
for (const page of pages) { for (const page of pages) {
if (!this.pages[page]) { if (!this.pages[page]) {
this.pages[page] = document.createElement('canvas'); this.pages[page] = document.createElement('canvas');
this.renderPage(this.pages[page], parseInt(page.substr(4))); this.renderPage(this.pages[page], parseInt(page.slice(4)));
} }
} }