From ddfe2039b1733264277daeef49f9eb535bab3eb0 Mon Sep 17 00:00:00 2001 From: Xmader Date: Tue, 24 Nov 2020 02:06:46 -0500 Subject: [PATCH] refactor: scoreinfo --- src/scoreinfo.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/scoreinfo.ts b/src/scoreinfo.ts index 172e15e..c1b6304 100644 --- a/src/scoreinfo.ts +++ b/src/scoreinfo.ts @@ -11,19 +11,11 @@ export const scoreinfo = { return +m[1] }, - get idLastDigit (this: typeof scoreinfo): number { - return (+this.id) % RADIX - }, - get title (this: typeof scoreinfo): string { const el = document.querySelector("meta[property='og:title']") as HTMLMetaElement return el.content }, - get fileName (this: typeof scoreinfo): string { - return this.title.replace(/[\s<>:{}"/\\|?*~.\0\cA-\cZ]+/g, '_') - }, - get pageCount (this: typeof scoreinfo): number { return document.querySelectorAll('.gXB83').length }, @@ -37,14 +29,6 @@ export const scoreinfo = { return origin + pathname.split('/').slice(0, -1).join('/') + '/' }, - get msczIpfsRef (this: typeof scoreinfo): string { - return `/ipns/${IPNS_KEY}/${this.idLastDigit}/${this.id}.mscz` - }, - - get msczCidUrl (this: typeof scoreinfo): string { - return `https://ipfs.infura.io:5001/api/v0/block/stat?arg=${this.msczIpfsRef}` - }, - get sheetImgType (): 'svg' | 'png' { try { const imgE = document.querySelector('img[src*=score_]') as HTMLImageElement @@ -57,6 +41,22 @@ export const scoreinfo = { return 'svg' } }, + + get idLastDigit (this: typeof scoreinfo): number { + return (+this.id) % RADIX + }, + + get fileName (this: typeof scoreinfo): string { + return this.title.replace(/[\s<>:{}"/\\|?*~.\0\cA-\cZ]+/g, '_') + }, + + get msczIpfsRef (this: typeof scoreinfo): string { + return `/ipns/${IPNS_KEY}/${this.idLastDigit}/${this.id}.mscz` + }, + + get msczCidUrl (this: typeof scoreinfo): string { + return `https://ipfs.infura.io:5001/api/v0/block/stat?arg=${this.msczIpfsRef}` + }, } export default scoreinfo