forked from akai/readest
09e65211b4
* feat: added percentage option and set by default * feat: added decimal percentaje * fix: fixed issue that the function of format didn't look for typeof * fix: Added revision fixes * fix: Added revision fixes and changes * fix: solved about styling code * fix: solved about styling code on book.ts and translation.json * fix: changed lines useEffect line that is escencial to Layoutpanel.tsx, and ProgressInfo.tsx has correct render like last version (Loc.) nd its separator * fix: correct SUPPORTED_LANGS key and disable style reapplication in saveViewSettings * i18n for the progress style config --------- Co-authored-by: Huang Xin <chrox.huang@gmail.com>
14 lines
410 B
TypeScript
14 lines
410 B
TypeScript
export function formatReadingProgress(
|
|
current: number | undefined,
|
|
total: number | undefined,
|
|
template: string,
|
|
): string {
|
|
if (current === undefined || total === undefined || total <= 0 || current < 0) {
|
|
return '';
|
|
}
|
|
return template
|
|
.replace('{current}', String(current + 1))
|
|
.replace('{total}', String(total))
|
|
.replace('{percent}', (((current + 1) / total) * 100).toFixed(1));
|
|
}
|