@@ -9,8 +9,8 @@ import { isAuthenticated } from "../firebase";
99import * as CustomTextState from "../states/custom-text-name" ;
1010import { getLanguageDisplayString } from "../utils/strings" ;
1111import Format from "../utils/format" ;
12- import { getActiveFunboxNames } from "../test/funbox/list" ;
13- import { escapeHTML } from "../utils/misc" ;
12+ import { getActiveFunboxes , getActiveFunboxNames } from "../test/funbox/list" ;
13+ import { escapeHTML , getMode2 } from "../utils/misc" ;
1414
1515ConfigEvent . subscribe ( ( eventKey ) => {
1616 const configKeys : ConfigEvent . ConfigEventKey [ ] = [
@@ -26,6 +26,7 @@ ConfigEvent.subscribe((eventKey) => {
2626 "confidenceMode" ,
2727 "layout" ,
2828 "showAverage" ,
29+ "showPb" ,
2930 "typingSpeedUnit" ,
3031 "quickRestart" ,
3132 "customPolyglot" ,
@@ -191,6 +192,36 @@ export async function update(): Promise<void> {
191192 }
192193 }
193194
195+ if ( Config . showPb ) {
196+ if ( ! isAuthenticated ( ) ) {
197+ return ;
198+ }
199+ const mode2 = getMode2 ( Config , TestWords . currentQuote ) ;
200+ const pb = await DB . getLocalPB (
201+ Config . mode ,
202+ mode2 ,
203+ Config . punctuation ,
204+ Config . numbers ,
205+ Config . language ,
206+ Config . difficulty ,
207+ Config . lazyMode ,
208+ getActiveFunboxes ( )
209+ ) ;
210+
211+ let str = "no pb" ;
212+
213+ if ( pb !== undefined ) {
214+ str = `${ Format . typingSpeed ( pb . wpm , {
215+ showDecimalPlaces : true ,
216+ suffix : ` ${ Config . typingSpeedUnit } ` ,
217+ } ) } ${ pb ?. acc } % acc`;
218+ }
219+
220+ $ ( ".pageTest #testModesNotice" ) . append (
221+ `<button class="textButton" commands="showPb"><i class="fas fa-crown"></i>${ str } </button>`
222+ ) ;
223+ }
224+
194225 if ( Config . minWpm !== "off" ) {
195226 $ ( ".pageTest #testModesNotice" ) . append (
196227 `<button class="textButton" commands="minWpm"><i class="fas fa-bomb"></i>min ${ Format . typingSpeed (
@@ -277,15 +308,3 @@ export async function update(): Promise<void> {
277308 }
278309 } catch { }
279310}
280-
281- if ( import . meta. hot !== undefined ) {
282- import . meta. hot . dispose ( ( ) => {
283- //
284- } ) ;
285- import . meta. hot . accept ( ( ) => {
286- //
287- } ) ;
288- import . meta. hot . on ( "vite:afterUpdate" , ( ) => {
289- void update ( ) ;
290- } ) ;
291- }
0 commit comments