2020-07-03 08:35:45 +08:00
$ ( ".pageLogin .register input" ) . keyup ( ( e ) => {
2020-10-16 11:37:34 +08:00
if ( $ ( ".pageLogin .register .button" ) . hasClass ( "disabled" ) ) return ;
2020-05-10 09:04:05 +08:00
if ( e . key == "Enter" ) {
2020-05-15 11:09:00 +08:00
signUp ( ) ;
}
2020-07-03 08:35:45 +08:00
} ) ;
2020-05-15 03:32:19 +08:00
2020-07-03 08:35:45 +08:00
$ ( ".pageLogin .register .button" ) . click ( ( e ) => {
2020-10-16 11:37:34 +08:00
if ( $ ( ".pageLogin .register .button" ) . hasClass ( "disabled" ) ) return ;
2020-07-03 08:35:45 +08:00
signUp ( ) ;
} ) ;
2020-05-10 09:04:05 +08:00
2020-07-03 08:35:45 +08:00
$ ( ".pageLogin .login input" ) . keyup ( ( e ) => {
2020-05-15 11:09:00 +08:00
if ( e . key == "Enter" ) {
2020-10-25 05:38:37 +08:00
configChangedBeforeDb = false ;
2020-05-15 11:09:00 +08:00
signIn ( ) ;
}
2020-07-03 08:35:45 +08:00
} ) ;
2020-05-13 03:40:16 +08:00
2020-07-03 08:35:45 +08:00
$ ( ".pageLogin .login .button" ) . click ( ( e ) => {
2020-10-25 05:38:37 +08:00
configChangedBeforeDb = false ;
2020-05-15 11:09:00 +08:00
signIn ( ) ;
2020-07-03 08:35:45 +08:00
} ) ;
2020-05-15 03:32:19 +08:00
2020-07-03 08:35:45 +08:00
$ ( ".signOut" ) . click ( ( e ) => {
2020-05-15 11:09:00 +08:00
signOut ( ) ;
2020-07-03 08:35:45 +08:00
} ) ;
2020-05-15 11:09:00 +08:00
2020-07-03 08:35:45 +08:00
$ ( ".pageAccount .loadMoreButton" ) . click ( ( e ) => {
2020-05-30 07:21:39 +08:00
loadMoreLines ( ) ;
2020-07-03 08:35:45 +08:00
} ) ;
2020-05-30 07:21:39 +08:00
2020-07-03 08:35:45 +08:00
$ ( ".pageLogin #forgotPasswordButton" ) . click ( ( e ) => {
2020-06-10 01:02:03 +08:00
let email = prompt ( "Email address" ) ;
2020-07-03 08:35:45 +08:00
if ( email ) {
firebase
. auth ( )
. sendPasswordResetEmail ( email )
. then ( function ( ) {
// Email sent.
showNotification ( "Email sent" , 2000 ) ;
} )
. catch ( function ( error ) {
// An error happened.
showNotification ( error . message , 5000 ) ;
} ) ;
2020-06-10 01:02:03 +08:00
}
2020-07-03 08:35:45 +08:00
} ) ;
2020-06-10 01:02:03 +08:00
2020-05-15 11:09:00 +08:00
function showSignOutButton ( ) {
2020-07-03 08:35:45 +08:00
$ ( ".signOut" ) . removeClass ( "hidden" ) . css ( "opacity" , 1 ) ;
2020-05-15 11:09:00 +08:00
}
function hideSignOutButton ( ) {
2020-07-03 08:35:45 +08:00
$ ( ".signOut" ) . css ( "opacity" , 0 ) . addClass ( "hidden" ) ;
2020-05-15 11:09:00 +08:00
}
function signIn ( ) {
2020-07-03 08:35:45 +08:00
$ ( ".pageLogin .preloader" ) . removeClass ( "hidden" ) ;
2020-05-15 11:09:00 +08:00
let email = $ ( ".pageLogin .login input" ) [ 0 ] . value ;
let password = $ ( ".pageLogin .login input" ) [ 1 ] . value ;
2020-07-03 08:35:45 +08:00
if ( $ ( ".pageLogin .login #rememberMe input" ) . prop ( "checked" ) ) {
2020-06-10 01:02:03 +08:00
//remember me
2020-07-03 08:35:45 +08:00
firebase
. auth ( )
. setPersistence ( firebase . auth . Auth . Persistence . LOCAL )
. then ( function ( ) {
return firebase
. auth ( )
. signInWithEmailAndPassword ( email , password )
. then ( ( e ) => {
changePage ( "test" ) ;
} )
. catch ( function ( error ) {
showNotification ( error . message , 5000 ) ;
$ ( ".pageLogin .preloader" ) . addClass ( "hidden" ) ;
} ) ;
2020-06-10 01:02:03 +08:00
} ) ;
2020-07-03 08:35:45 +08:00
} else {
2020-06-10 01:02:03 +08:00
//dont remember
2020-07-03 08:35:45 +08:00
firebase
. auth ( )
. setPersistence ( firebase . auth . Auth . Persistence . SESSION )
. then ( function ( ) {
return firebase
. auth ( )
. signInWithEmailAndPassword ( email , password )
. then ( ( e ) => {
changePage ( "test" ) ;
} )
. catch ( function ( error ) {
showNotification ( error . message , 5000 ) ;
$ ( ".pageLogin .preloader" ) . addClass ( "hidden" ) ;
} ) ;
2020-06-10 01:02:03 +08:00
} ) ;
}
2020-05-15 11:09:00 +08:00
}
2020-05-10 09:04:05 +08:00
2020-06-28 22:27:52 +08:00
let dontCheckUserName = false ;
2020-05-15 11:09:00 +08:00
function signUp ( ) {
2020-10-16 11:37:34 +08:00
$ ( ".pageLogin .register .button" ) . addClass ( "disabled" ) ;
2020-07-03 08:35:45 +08:00
$ ( ".pageLogin .preloader" ) . removeClass ( "hidden" ) ;
2020-06-06 23:48:22 +08:00
let nname = $ ( ".pageLogin .register input" ) [ 0 ] . value ;
2020-05-15 11:09:00 +08:00
let email = $ ( ".pageLogin .register input" ) [ 1 ] . value ;
let password = $ ( ".pageLogin .register input" ) [ 2 ] . value ;
let passwordVerify = $ ( ".pageLogin .register input" ) [ 3 ] . value ;
2020-05-10 09:04:05 +08:00
2020-10-27 03:24:37 +08:00
if ( password != passwordVerify ) {
showNotification ( "Passwords do not match" , 3000 ) ;
$ ( ".pageLogin .preloader" ) . addClass ( "hidden" ) ;
$ ( ".pageLogin .register .button" ) . removeClass ( "disabled" ) ;
return ;
}
2020-07-03 08:35:45 +08:00
const namecheck = firebase . functions ( ) . httpsCallable ( "checkNameAvailability" ) ;
2020-05-10 01:39:23 +08:00
2020-07-03 08:35:45 +08:00
namecheck ( { name : nname } ) . then ( ( d ) => {
if ( d . data === - 1 ) {
2020-06-06 23:48:22 +08:00
showNotification ( "Name unavailable" , 3000 ) ;
2020-07-03 08:35:45 +08:00
$ ( ".pageLogin .preloader" ) . addClass ( "hidden" ) ;
2020-10-16 11:37:34 +08:00
$ ( ".pageLogin .register .button" ) . removeClass ( "disabled" ) ;
2020-06-06 23:48:22 +08:00
return ;
2020-07-03 08:35:45 +08:00
} else if ( d . data === - 2 ) {
showNotification (
2020-07-26 22:20:49 +08:00
"Name cannot contain special characters or contain more than 14 characters. Can include _ . and -" ,
2020-07-03 08:35:45 +08:00
8000
) ;
$ ( ".pageLogin .preloader" ) . addClass ( "hidden" ) ;
2020-10-16 11:37:34 +08:00
$ ( ".pageLogin .register .button" ) . removeClass ( "disabled" ) ;
2020-06-22 06:00:33 +08:00
return ;
2020-07-03 08:35:45 +08:00
} else if ( d . data === 1 ) {
firebase
. auth ( )
. createUserWithEmailAndPassword ( email , password )
. then ( ( user ) => {
// Account has been created here.
dontCheckUserName = true ;
let usr = user . user ;
usr
. updateProfile ( {
displayName : nname ,
} )
2020-10-27 03:49:36 +08:00
. then ( async function ( ) {
2020-07-03 08:35:45 +08:00
// Update successful.
2020-10-27 03:49:36 +08:00
await firebase
2020-07-04 20:08:37 +08:00
. firestore ( )
. collection ( "users" )
. doc ( usr . uid )
. set ( { name : nname } , { merge : true } ) ;
2020-10-27 03:49:36 +08:00
reserveName ( { name : nname , uid : usr . uid } ) ;
2020-07-22 05:50:38 +08:00
usr . sendEmailVerification ( ) ;
2020-09-06 22:17:26 +08:00
clearGlobalStats ( ) ;
2020-07-03 08:35:45 +08:00
showNotification ( "Account created" , 2000 ) ;
$ ( "#menu .icon-button.account .text" ) . text ( nname ) ;
try {
firebase . analytics ( ) . logEvent ( "accountCreated" , usr . uid ) ;
} catch ( e ) {
console . log ( "Analytics unavailable" ) ;
}
$ ( ".pageLogin .preloader" ) . addClass ( "hidden" ) ;
2020-08-19 08:32:30 +08:00
dbSnapshot = {
results : [ ] ,
personalBests : { } ,
tags : [ ] ,
2020-09-06 22:17:26 +08:00
globalStats : {
time : undefined ,
started : undefined ,
2020-09-17 00:29:39 +08:00
completed : undefined ,
} ,
2020-08-19 08:32:30 +08:00
} ;
2020-08-30 13:32:22 +08:00
if ( notSignedInLastResult !== null ) {
notSignedInLastResult . uid = usr . uid ;
testCompleted ( {
uid : usr . uid ,
obj : notSignedInLastResult ,
} ) ;
dbSnapshot . results . push ( notSignedInLastResult ) ;
config . resultFilters = defaultAccountFilters ;
}
2020-07-03 08:35:45 +08:00
changePage ( "account" ) ;
2020-09-06 20:26:29 +08:00
usr . sendEmailVerification ( ) ;
2020-10-16 11:37:34 +08:00
$ ( ".pageLogin .register .button" ) . removeClass ( "disabled" ) ;
2020-07-03 08:35:45 +08:00
} )
. catch ( function ( error ) {
// An error happened.
2020-10-16 11:37:34 +08:00
$ ( ".pageLogin .register .button" ) . removeClass ( "disabled" ) ;
2020-07-04 20:08:37 +08:00
console . error ( error ) ;
2020-07-03 08:35:45 +08:00
usr
. delete ( )
. then ( function ( ) {
// User deleted.
2020-08-19 08:32:30 +08:00
showNotification (
"An error occured. Account not created." ,
2000
) ;
2020-07-03 08:35:45 +08:00
$ ( ".pageLogin .preloader" ) . addClass ( "hidden" ) ;
} )
. catch ( function ( error ) {
// An error happened.
$ ( ".pageLogin .preloader" ) . addClass ( "hidden" ) ;
} ) ;
} ) ;
} )
. catch ( function ( error ) {
// Handle Errors here.
2020-10-16 11:37:34 +08:00
$ ( ".pageLogin .register .button" ) . removeClass ( "disabled" ) ;
2020-07-03 08:35:45 +08:00
var errorCode = error . code ;
var errorMessage = error . message ;
showNotification ( errorMessage , 5000 ) ;
$ ( ".pageLogin .preloader" ) . addClass ( "hidden" ) ;
2020-06-06 23:48:22 +08:00
} ) ;
}
2020-07-03 08:35:45 +08:00
} ) ;
2020-05-15 11:09:00 +08:00
}
2020-05-10 06:33:48 +08:00
function signOut ( ) {
2020-07-03 08:35:45 +08:00
firebase
. auth ( )
. signOut ( )
. then ( function ( ) {
showNotification ( "Signed out" , 2000 ) ;
2020-09-06 22:17:26 +08:00
clearGlobalStats ( ) ;
2020-09-01 02:15:10 +08:00
hideAccountSettingsSection ( ) ;
2020-07-03 08:35:45 +08:00
updateAccountLoginButton ( ) ;
changePage ( "login" ) ;
dbSnapshot = null ;
} )
. catch ( function ( error ) {
showNotification ( error . message , 5000 ) ;
} ) ;
2020-05-10 06:33:48 +08:00
}
2020-07-22 05:50:38 +08:00
function sendVerificationEmail ( ) {
2020-07-22 06:33:21 +08:00
let cu = firebase . auth ( ) . currentUser ;
cu . sendEmailVerification ( )
2020-07-22 05:50:38 +08:00
. then ( ( e ) => {
2020-07-22 06:33:21 +08:00
showNotification ( "Email sent to " + cu . email , 4000 ) ;
2020-07-22 05:50:38 +08:00
} )
. catch ( ( e ) => {
showNotification ( "Error: " + e . message , 3000 ) ;
console . error ( e . message ) ;
} ) ;
}
2020-07-03 08:35:45 +08:00
firebase . auth ( ) . onAuthStateChanged ( function ( user ) {
2020-05-10 09:04:05 +08:00
if ( user ) {
// User is signed in.
2020-07-22 06:33:21 +08:00
if ( user . emailVerified === false ) {
$ ( ".pageAccount .content" ) . prepend (
` <p style="text-align:center">Your account is not verified. Click <a onClick="sendVerificationEmail()">here</a> to resend the verification email. `
) ;
}
2020-06-09 03:01:04 +08:00
updateAccountLoginButton ( ) ;
2020-06-09 03:35:50 +08:00
accountIconLoading ( true ) ;
2020-10-07 00:10:24 +08:00
getAccountDataAndInit ( ) ;
2020-05-10 09:04:05 +08:00
var displayName = user . displayName ;
var email = user . email ;
var emailVerified = user . emailVerified ;
var photoURL = user . photoURL ;
var isAnonymous = user . isAnonymous ;
var uid = user . uid ;
var providerData = user . providerData ;
2020-06-09 02:51:13 +08:00
// showNotification('Signed in', 1000);
2020-07-03 08:35:45 +08:00
$ ( ".pageLogin .preloader" ) . addClass ( "hidden" ) ;
2020-07-03 01:39:24 +08:00
$ ( "#menu .icon-button.account .text" ) . text ( displayName ) ;
2020-10-10 22:48:08 +08:00
if ( verifyUserWhenLoggedIn !== null ) {
2020-10-27 04:28:25 +08:00
showNotification ( "Verifying" , 1000 ) ;
2020-10-10 22:48:08 +08:00
verifyUserWhenLoggedIn . uid = user . uid ;
2020-10-27 04:28:25 +08:00
verifyUser ( verifyUserWhenLoggedIn ) . then ( ( data ) => {
2020-10-10 22:48:08 +08:00
showNotification ( data . data . message , 3000 ) ;
if ( data . data . status === 1 ) {
dbSnapshot . discordId = data . data . did ;
2020-10-27 04:28:25 +08:00
updateDiscordSettingsSection ( ) ;
2020-10-10 22:48:08 +08:00
}
2020-10-27 04:28:25 +08:00
} ) ;
2020-10-10 22:48:08 +08:00
}
2020-05-10 09:04:05 +08:00
}
} ) ;
2020-10-07 00:10:24 +08:00
function getAccountDataAndInit ( ) {
db _getUserSnapshot ( )
. then ( ( e ) => {
if ( dbSnapshot === null ) {
2020-10-27 04:28:25 +08:00
throw "Missing db snapshot. Client likely could not connect to the backend." ;
2020-10-07 00:10:24 +08:00
}
2020-10-27 04:28:25 +08:00
initPaceCaret ( true ) ;
if ( ! configChangedBeforeDb ) {
if ( cookieConfig === null ) {
accountIconLoading ( false ) ;
applyConfig ( dbSnapshot . config ) ;
// showNotification('Applying db config',3000);
updateSettingsPage ( ) ;
saveConfigToCookie ( true ) ;
restartTest ( false , true ) ;
} else if ( dbSnapshot . config !== undefined ) {
let configsDifferent = false ;
Object . keys ( config ) . forEach ( ( key ) => {
if ( ! configsDifferent ) {
try {
if ( key !== "resultFilters" ) {
if ( Array . isArray ( config [ key ] ) ) {
config [ key ] . forEach ( ( arrval , index ) => {
if ( arrval != dbSnapshot . config [ key ] [ index ] ) {
configsDifferent = true ;
console . log (
` .config is different: ${ arrval } != ${ dbSnapshot . config [ key ] [ index ] } `
) ;
}
} ) ;
} else {
if ( config [ key ] != dbSnapshot . config [ key ] ) {
2020-10-07 00:10:24 +08:00
configsDifferent = true ;
2020-10-27 04:28:25 +08:00
console . log (
` ..config is different ${ key } : ${ config [ key ] } != ${ dbSnapshot . config [ key ] } `
) ;
2020-10-23 21:49:07 +08:00
}
}
2020-10-07 00:10:24 +08:00
}
2020-10-27 04:28:25 +08:00
} catch ( e ) {
console . log ( e ) ;
configsDifferent = true ;
console . log ( ` ...config is different: ${ e . message } ` ) ;
2020-10-07 00:10:24 +08:00
}
}
2020-10-27 04:28:25 +08:00
} ) ;
if ( configsDifferent ) {
console . log ( "applying config from db" ) ;
accountIconLoading ( false ) ;
config = dbSnapshot . config ;
applyConfig ( config ) ;
updateSettingsPage ( ) ;
saveConfigToCookie ( true ) ;
restartTest ( false , true ) ;
2020-10-07 00:10:24 +08:00
}
}
2020-10-27 04:28:25 +08:00
dbConfigLoaded = true ;
} else {
accountIconLoading ( false ) ;
2020-10-07 00:10:24 +08:00
}
2020-10-27 04:28:25 +08:00
try {
2020-10-07 00:10:24 +08:00
if (
2020-10-27 04:28:25 +08:00
config . resultFilters === undefined ||
config . resultFilters === null ||
config . resultFilters . difficulty === undefined
2020-10-07 00:10:24 +08:00
) {
2020-10-27 04:28:25 +08:00
if (
dbSnapshot . config . resultFilters == null ||
dbSnapshot . config . resultFilters . difficulty === undefined
) {
config . resultFilters = defaultAccountFilters ;
} else {
config . resultFilters = dbSnapshot . config . resultFilters ;
}
2020-10-07 00:10:24 +08:00
}
2020-10-27 04:28:25 +08:00
} catch ( e ) {
config . resultFilters = defaultAccountFilters ;
2020-10-07 00:10:24 +08:00
}
2020-10-27 04:28:25 +08:00
if ( $ ( ".pageLogin" ) . hasClass ( "active" ) ) {
changePage ( "account" ) ;
}
refreshThemeButtons ( ) ;
accountIconLoading ( false ) ;
updateFilterTags ( ) ;
updateCommandsTagsList ( ) ;
loadActiveTagsFromCookie ( ) ;
updateResultEditTagsPanelButtons ( ) ;
showAccountSettingsSection ( ) ;
} )
. catch ( ( e ) => {
accountIconLoading ( false ) ;
console . error ( e ) ;
showNotification (
"Error downloading user data. Refresh to try again. If error persists contact Miodec." ,
5000
) ;
$ ( "#top #menu .account .icon" ) . html ( '<i class="fas fa-fw fa-times"></i>' ) ;
$ ( "#top #menu .account" ) . css ( "opacity" , 1 ) ;
} ) ;
2020-10-07 00:10:24 +08:00
}
2020-05-10 09:04:05 +08:00
var resultHistoryChart = new Chart ( $ ( ".pageAccount #resultHistoryChart" ) , {
2020-05-20 07:11:57 +08:00
animationSteps : 60 ,
2020-07-03 08:35:45 +08:00
type : "line" ,
2020-05-10 09:04:05 +08:00
data : {
datasets : [
{
2020-09-06 22:17:26 +08:00
yAxisID : "wpm" ,
2020-05-20 07:11:57 +08:00
label : "wpm" ,
2020-05-10 09:04:05 +08:00
fill : false ,
data : [ ] ,
2020-07-03 08:35:45 +08:00
borderColor : "#f44336" ,
2020-05-10 09:04:05 +08:00
borderWidth : 2 ,
// trendlineLinear: {
// style: "rgba(244,67,54,.25)",
// lineStyle: "solid",
// width: 1
// }
2020-05-27 00:51:48 +08:00
trendlineLinear : {
style : "rgba(255,105,180, .8)" ,
lineStyle : "dotted" ,
2020-07-03 08:35:45 +08:00
width : 4 ,
} ,
2020-05-10 09:04:05 +08:00
} ,
2020-09-06 22:17:26 +08:00
{
yAxisID : "acc" ,
label : "acc" ,
fill : false ,
data : [ ] ,
borderColor : "#cccccc" ,
borderWidth : 2 ,
} ,
2020-05-10 09:04:05 +08:00
] ,
} ,
options : {
2020-05-12 07:59:12 +08:00
tooltips : {
2020-05-20 07:11:57 +08:00
// Disable the on-canvas tooltip
enabled : true ,
2020-05-12 07:59:12 +08:00
titleFontFamily : "Roboto Mono" ,
2020-05-20 07:11:57 +08:00
bodyFontFamily : "Roboto Mono" ,
intersect : false ,
2020-07-03 08:35:45 +08:00
custom : function ( tooltip ) {
2020-05-20 07:11:57 +08:00
if ( ! tooltip ) return ;
// disable displaying the color box;
tooltip . displayColors = false ;
2020-07-03 08:35:45 +08:00
} ,
callbacks : {
// HERE YOU CUSTOMIZE THE LABELS
title : function ( ) {
2020-05-20 07:11:57 +08:00
return ;
} ,
2020-07-03 08:35:45 +08:00
beforeLabel : function ( tooltipItem , data ) {
let resultData =
data . datasets [ tooltipItem . datasetIndex ] . data [ tooltipItem . index ] ;
2020-09-12 08:27:14 +08:00
if ( tooltipItem . datasetIndex !== 0 ) {
return ` acc: ${ resultData . y } % ` ;
}
2020-07-03 08:35:45 +08:00
let label =
` ${ data . datasets [ tooltipItem . datasetIndex ] . label } : ${
tooltipItem . yLabel
} ` +
"\n" +
2020-09-12 08:27:14 +08:00
` raw: ${ resultData . raw } ` +
"\n" +
2020-07-03 08:35:45 +08:00
` acc: ${ resultData . acc } ` +
"\n\n" +
` mode: ${ resultData . mode } ` ;
if ( resultData . mode == "time" ) {
2020-05-20 07:11:57 +08:00
label += resultData . mode2 ;
2020-07-03 08:35:45 +08:00
} else if ( resultData . mode == "words" ) {
2020-05-20 07:11:57 +08:00
label += resultData . mode2 ;
}
2020-05-29 22:58:01 +08:00
let diff = resultData . difficulty ;
2020-07-03 08:35:45 +08:00
if ( diff == undefined ) {
diff = "normal" ;
2020-05-29 22:58:01 +08:00
}
2020-07-03 08:35:45 +08:00
label += "\n" + ` difficulty: ${ diff } ` ;
label +=
"\n" +
` punctuation: ${ resultData . punctuation } ` +
"\n" +
` language: ${ resultData . language } ` +
"\n\n" +
` date: ${ moment ( resultData . timestamp ) . format ( "DD MMM YYYY HH:mm" ) } ` ;
2020-05-20 07:11:57 +08:00
return label ;
} ,
2020-07-03 08:35:45 +08:00
label : function ( tooltipItem , data ) {
return ;
2020-05-20 07:11:57 +08:00
} ,
2020-07-03 08:35:45 +08:00
afterLabel : function ( tooltipItem , data ) {
2020-05-20 07:11:57 +08:00
return ;
} ,
2020-07-03 08:35:45 +08:00
} ,
2020-05-20 07:11:57 +08:00
} ,
animation : {
2020-07-03 08:35:45 +08:00
duration : 250 ,
2020-05-12 07:59:12 +08:00
} ,
2020-05-10 09:04:05 +08:00
legend : {
2020-05-27 02:59:26 +08:00
display : false ,
2020-05-10 09:04:05 +08:00
labels : {
2020-05-12 07:59:12 +08:00
fontFamily : "Roboto Mono" ,
2020-07-03 08:35:45 +08:00
fontColor : "#ffffff" ,
} ,
2020-05-10 09:04:05 +08:00
} ,
responsive : true ,
2020-09-12 08:27:14 +08:00
maintainAspectRatio : false ,
2020-05-10 09:04:05 +08:00
// tooltips: {
// mode: 'index',
// intersect: false,
// },
hover : {
2020-07-03 08:35:45 +08:00
mode : "nearest" ,
2020-09-12 08:27:14 +08:00
intersect : false ,
2020-05-10 09:04:05 +08:00
} ,
scales : {
2020-07-03 08:35:45 +08:00
xAxes : [
{
ticks : {
fontFamily : "Roboto Mono" ,
} ,
type : "time" ,
bounds : "ticks" ,
distribution : "series" ,
display : false ,
2020-09-10 03:14:56 +08:00
offset : true ,
2020-07-03 08:35:45 +08:00
scaleLabel : {
2020-09-10 03:10:25 +08:00
display : false ,
2020-07-03 08:35:45 +08:00
labelString : "Date" ,
} ,
2020-05-12 07:59:12 +08:00
} ,
2020-07-03 08:35:45 +08:00
] ,
yAxes : [
{
2020-09-06 22:17:26 +08:00
id : "wpm" ,
2020-07-03 08:35:45 +08:00
ticks : {
fontFamily : "Roboto Mono" ,
beginAtZero : true ,
2020-09-12 08:27:14 +08:00
min : 0 ,
2020-09-17 00:29:39 +08:00
stepSize : 10 ,
2020-07-03 08:35:45 +08:00
} ,
2020-05-10 09:04:05 +08:00
display : true ,
2020-07-03 08:35:45 +08:00
scaleLabel : {
2020-09-06 22:17:26 +08:00
display : true ,
2020-07-03 08:35:45 +08:00
labelString : "Words per Minute" ,
2020-09-06 22:17:26 +08:00
fontFamily : "Roboto Mono" ,
} ,
} ,
{
id : "acc" ,
ticks : {
fontFamily : "Roboto Mono" ,
beginAtZero : true ,
2020-09-17 00:29:39 +08:00
max : 100 ,
2020-09-06 22:17:26 +08:00
} ,
2020-09-12 08:27:14 +08:00
display : true ,
2020-09-06 22:17:26 +08:00
position : "right" ,
scaleLabel : {
2020-09-12 08:27:14 +08:00
display : true ,
2020-09-06 22:17:26 +08:00
labelString : "Accuracy" ,
fontFamily : "Roboto Mono" ,
} ,
gridLines : {
display : false ,
2020-07-03 08:35:45 +08:00
} ,
2020-05-10 09:04:05 +08:00
} ,
2020-07-03 08:35:45 +08:00
] ,
2020-05-27 00:51:48 +08:00
} ,
2020-07-03 08:35:45 +08:00
} ,
2020-05-10 09:04:05 +08:00
} ) ;
2020-09-10 03:10:25 +08:00
let activityChart = new Chart ( $ ( ".pageAccount #activityChart" ) , {
animationSteps : 60 ,
type : "bar" ,
data : {
datasets : [
{
yAxisID : "count" ,
label : "Tests Completed" ,
data : [ ] ,
trendlineLinear : {
style : "rgba(255,105,180, .8)" ,
lineStyle : "dotted" ,
2020-09-10 07:43:31 +08:00
width : 2 ,
2020-09-10 03:10:25 +08:00
} ,
2020-10-27 04:28:25 +08:00
order : 3 ,
2020-10-09 23:40:55 +08:00
} ,
{
yAxisID : "avgWpm" ,
label : "Average Wpm" ,
data : [ ] ,
type : "line" ,
order : 2 ,
lineTension : 0 ,
fill : false ,
2020-09-10 03:10:25 +08:00
} ,
] ,
} ,
options : {
2020-09-10 07:13:05 +08:00
tooltips : {
callbacks : {
// HERE YOU CUSTOMIZE THE LABELS
title : function ( tooltipItem , data ) {
let resultData =
2020-09-17 00:29:39 +08:00
data . datasets [ tooltipItem [ 0 ] . datasetIndex ] . data [
tooltipItem [ 0 ] . index
] ;
return moment ( resultData . x ) . format ( "DD MMM YYYY" ) ;
2020-09-10 07:13:05 +08:00
} ,
} ,
} ,
2020-09-10 03:10:25 +08:00
animation : {
duration : 250 ,
} ,
legend : {
display : false ,
labels : {
fontFamily : "Roboto Mono" ,
fontColor : "#ffffff" ,
} ,
} ,
responsive : true ,
maintainAspectRatio : false ,
hover : {
mode : "nearest" ,
2020-09-12 08:27:14 +08:00
intersect : false ,
2020-09-10 03:10:25 +08:00
} ,
scales : {
xAxes : [
{
ticks : {
fontFamily : "Roboto Mono" ,
autoSkip : true ,
autoSkipPadding : 40 ,
} ,
type : "time" ,
time : {
2020-09-17 00:29:39 +08:00
unit : "day" ,
2020-09-10 07:13:05 +08:00
displayFormats : {
2020-09-17 00:29:39 +08:00
day : "D MMM" ,
} ,
2020-09-10 03:10:25 +08:00
} ,
bounds : "ticks" ,
distribution : "series" ,
display : true ,
scaleLabel : {
display : false ,
labelString : "Date" ,
} ,
2020-09-17 00:29:39 +08:00
offset : true ,
2020-09-10 03:10:25 +08:00
} ,
] ,
yAxes : [
{
id : "count" ,
ticks : {
fontFamily : "Roboto Mono" ,
beginAtZero : true ,
min : 0 ,
autoSkip : true ,
stepSize : 1 ,
autoSkipPadding : 40 ,
2020-09-17 00:29:39 +08:00
stepSize : 10 ,
2020-09-10 03:10:25 +08:00
} ,
display : true ,
scaleLabel : {
display : true ,
labelString : "Tests Completed" ,
fontFamily : "Roboto Mono" ,
} ,
} ,
2020-10-09 23:40:55 +08:00
{
id : "avgWpm" ,
ticks : {
fontFamily : "Roboto Mono" ,
beginAtZero : true ,
min : 0 ,
autoSkip : true ,
stepSize : 1 ,
autoSkipPadding : 40 ,
stepSize : 10 ,
} ,
display : true ,
position : "right" ,
scaleLabel : {
display : true ,
labelString : "Average Wpm" ,
fontFamily : "Roboto Mono" ,
} ,
gridLines : {
display : false ,
} ,
} ,
2020-09-10 03:10:25 +08:00
] ,
} ,
} ,
} ) ;
2020-08-25 11:57:43 +08:00
let hoverChart = new Chart ( $ ( ".pageAccount #hoverChart" ) , {
type : "line" ,
data : {
labels : [ ] ,
datasets : [
{
label : "wpm" ,
data : [ ] ,
// backgroundColor: 'rgba(255, 255, 255, 0.25)',
borderColor : "rgba(125, 125, 125, 1)" ,
borderWidth : 2 ,
yAxisID : "wpm" ,
order : 2 ,
radius : 2 ,
} ,
{
label : "raw" ,
data : [ ] ,
// backgroundColor: 'rgba(255, 255, 255, 0.25)',
borderColor : "rgba(125, 125, 125, 1)" ,
borderWidth : 2 ,
yAxisID : "raw" ,
order : 3 ,
radius : 2 ,
} ,
{
label : "errors" ,
data : [ ] ,
// backgroundColor: 'rgba(255, 255, 255, 0.25)',
borderColor : "rgba(255, 125, 125, 1)" ,
pointBackgroundColor : "rgba(255, 125, 125, 1)" ,
borderWidth : 2 ,
order : 1 ,
yAxisID : "error" ,
// barPercentage: 0.1,
maxBarThickness : 10 ,
type : "scatter" ,
pointStyle : "crossRot" ,
radius : function ( context ) {
var index = context . dataIndex ;
var value = context . dataset . data [ index ] ;
return value . y <= 0 ? 0 : 3 ;
} ,
pointHoverRadius : function ( context ) {
var index = context . dataIndex ;
var value = context . dataset . data [ index ] ;
return value . y <= 0 ? 0 : 5 ;
} ,
} ,
] ,
} ,
options : {
tooltips : {
titleFontFamily : "Roboto Mono" ,
bodyFontFamily : "Roboto Mono" ,
mode : "index" ,
intersect : false ,
} ,
legend : {
display : false ,
labels : {
defaultFontFamily : "Roboto Mono" ,
} ,
} ,
responsive : true ,
maintainAspectRatio : false ,
// hover: {
// mode: 'x',
// intersect: false
// },
scales : {
xAxes : [
{
ticks : {
fontFamily : "Roboto Mono" ,
autoSkip : true ,
autoSkipPadding : 40 ,
} ,
display : true ,
scaleLabel : {
display : false ,
labelString : "Seconds" ,
fontFamily : "Roboto Mono" ,
} ,
} ,
] ,
yAxes : [
{
id : "wpm" ,
display : true ,
scaleLabel : {
display : true ,
labelString : "Words per Minute" ,
fontFamily : "Roboto Mono" ,
} ,
ticks : {
fontFamily : "Roboto Mono" ,
beginAtZero : true ,
min : 0 ,
autoSkip : true ,
autoSkipPadding : 40 ,
} ,
gridLines : {
display : true ,
} ,
} ,
{
id : "raw" ,
display : false ,
scaleLabel : {
display : true ,
labelString : "Raw Words per Minute" ,
fontFamily : "Roboto Mono" ,
} ,
ticks : {
fontFamily : "Roboto Mono" ,
beginAtZero : true ,
min : 0 ,
autoSkip : true ,
autoSkipPadding : 40 ,
} ,
gridLines : {
display : false ,
} ,
} ,
{
id : "error" ,
display : true ,
position : "right" ,
scaleLabel : {
display : true ,
labelString : "Errors" ,
fontFamily : "Roboto Mono" ,
} ,
ticks : {
precision : 0 ,
fontFamily : "Roboto Mono" ,
beginAtZero : true ,
autoSkip : true ,
autoSkipPadding : 40 ,
} ,
gridLines : {
display : false ,
} ,
} ,
] ,
} ,
annotation : {
annotations : [
{
enabled : false ,
type : "line" ,
mode : "horizontal" ,
scaleID : "wpm" ,
value : "-30" ,
borderColor : "red" ,
borderWidth : 1 ,
borderDash : [ 2 , 2 ] ,
label : {
// Background color of label, default below
backgroundColor : "blue" ,
fontFamily : "Roboto Mono" ,
// Font size of text, inherits from global
fontSize : 11 ,
// Font style of text, default below
fontStyle : "normal" ,
// Font color of text, default below
fontColor : "#fff" ,
// Padding of label to add left/right, default below
xPadding : 6 ,
// Padding of label to add top/bottom, default below
yPadding : 6 ,
// Radius of label rectangle, default below
cornerRadius : 3 ,
// Anchor position of label on line, can be one of: top, bottom, left, right, center. Default below.
position : "center" ,
// Whether the label is enabled and should be displayed
enabled : true ,
// Text to display in label - default is null. Provide an array to display values on a new line
content : "PB" ,
} ,
} ,
] ,
} ,
} ,
} ) ;
function updateHoverChart ( filteredId ) {
2020-08-26 00:36:56 +08:00
let data = filteredResults [ filteredId ] . chartData ;
2020-08-25 11:57:43 +08:00
let labels = [ ] ;
2020-08-26 00:36:56 +08:00
for ( let i = 1 ; i <= data . wpm . length ; i ++ ) {
2020-08-25 11:57:43 +08:00
labels . push ( i . toString ( ) ) ;
}
hoverChart . data . labels = labels ;
2020-08-26 00:36:56 +08:00
hoverChart . data . datasets [ 0 ] . data = data . wpm ;
hoverChart . data . datasets [ 1 ] . data = data . raw ;
hoverChart . data . datasets [ 2 ] . data = data . err ;
2020-08-25 11:57:43 +08:00
hoverChart . options . scales . xAxes [ 0 ] . ticks . minor . fontColor = themeColors . sub ;
hoverChart . options . scales . xAxes [ 0 ] . scaleLabel . fontColor = themeColors . sub ;
hoverChart . options . scales . yAxes [ 0 ] . ticks . minor . fontColor = themeColors . sub ;
hoverChart . options . scales . yAxes [ 2 ] . ticks . minor . fontColor = themeColors . sub ;
hoverChart . options . scales . yAxes [ 0 ] . scaleLabel . fontColor = themeColors . sub ;
hoverChart . options . scales . yAxes [ 2 ] . scaleLabel . fontColor = themeColors . sub ;
hoverChart . data . datasets [ 0 ] . borderColor = themeColors . main ;
hoverChart . data . datasets [ 0 ] . pointBackgroundColor = themeColors . main ;
hoverChart . data . datasets [ 1 ] . borderColor = themeColors . sub ;
hoverChart . data . datasets [ 1 ] . pointBackgroundColor = themeColors . sub ;
hoverChart . options . annotation . annotations [ 0 ] . borderColor = themeColors . sub ;
hoverChart . options . annotation . annotations [ 0 ] . label . backgroundColor =
themeColors . sub ;
hoverChart . options . annotation . annotations [ 0 ] . label . fontColor = themeColors . bg ;
2020-08-26 00:36:56 +08:00
let maxChartVal = Math . max ( ... [ Math . max ( ... data . wpm ) , Math . max ( ... data . raw ) ] ) ;
2020-09-17 00:29:39 +08:00
let minChartVal = Math . min ( ... [ Math . min ( ... data . wpm ) , Math . min ( ... data . raw ) ] ) ;
2020-08-26 00:36:56 +08:00
hoverChart . options . scales . yAxes [ 0 ] . ticks . max = Math . round ( maxChartVal ) ;
hoverChart . options . scales . yAxes [ 1 ] . ticks . max = Math . round ( maxChartVal ) ;
2020-09-09 22:56:30 +08:00
if ( ! config . startGraphsAtZero ) {
hoverChart . options . scales . yAxes [ 0 ] . ticks . min = Math . round ( minChartVal ) ;
hoverChart . options . scales . yAxes [ 1 ] . ticks . min = Math . round ( minChartVal ) ;
2020-10-09 22:58:04 +08:00
} else {
hoverChart . options . scales . yAxes [ 0 ] . ticks . min = 0 ;
hoverChart . options . scales . yAxes [ 1 ] . ticks . min = 0 ;
2020-09-09 22:56:30 +08:00
}
2020-08-25 11:57:43 +08:00
hoverChart . update ( { duration : 0 } ) ;
}
function showHoverChart ( ) {
$ ( ".pageAccount .hoverChartWrapper" ) . stop ( true , true ) . fadeIn ( 125 ) ;
$ ( ".pageAccount .hoverChartBg" ) . stop ( true , true ) . fadeIn ( 125 ) ;
}
function hideHoverChart ( ) {
$ ( ".pageAccount .hoverChartWrapper" ) . stop ( true , true ) . fadeOut ( 125 ) ;
$ ( ".pageAccount .hoverChartBg" ) . stop ( true , true ) . fadeOut ( 125 ) ;
}
function updateHoverChartPosition ( x , y ) {
$ ( ".pageAccount .hoverChartWrapper" ) . css ( { top : y , left : x } ) ;
}
$ ( document ) . on ( "click" , ".pageAccount .hoverChartButton" , ( event ) => {
console . log ( "updating" ) ;
let filterid = $ ( event . currentTarget ) . attr ( "filteredResultsId" ) ;
if ( filterid === undefined ) return ;
updateHoverChart ( filterid ) ;
showHoverChart ( ) ;
updateHoverChartPosition (
event . pageX - $ ( ".pageAccount .hoverChartWrapper" ) . outerWidth ( ) ,
event . pageY + 30
) ;
} ) ;
$ ( document ) . on ( "click" , ".pageAccount .hoverChartBg" , ( event ) => {
hideHoverChart ( ) ;
} ) ;
// $(document).on("mouseleave", ".pageAccount .hoverChartButton", (event) => {
// hideHoverChart();
// });
2020-08-10 02:52:00 +08:00
let defaultAccountFilters = {
difficulty : {
normal : true ,
expert : true ,
master : true ,
} ,
mode : {
words : true ,
time : true ,
quote : true ,
custom : true ,
} ,
words : {
10 : true ,
25 : true ,
50 : true ,
100 : true ,
200 : true ,
custom : true ,
} ,
time : {
15 : true ,
30 : true ,
60 : true ,
120 : true ,
custom : true ,
} ,
punctuation : {
on : true ,
off : true ,
} ,
2020-09-04 05:05:15 +08:00
numbers : {
on : true ,
off : true ,
} ,
2020-08-10 02:52:00 +08:00
date : {
last _day : false ,
last _week : false ,
last _month : false ,
all : true ,
} ,
tags : {
none : true ,
} ,
language : { } ,
funbox : {
none : true ,
} ,
} ;
2020-10-27 04:28:25 +08:00
getLanguageList ( ) . then ( ( languages ) => {
2020-10-23 21:49:07 +08:00
languages . forEach ( ( language ) => {
2020-08-10 02:52:00 +08:00
$ (
".pageAccount .content .filterButtons .buttonsAndTitle.languages .buttons"
2020-10-23 21:49:07 +08:00
) . append (
` <div class="button" filter=" ${ language } "> ${ language . replace (
"_" ,
" "
) } < / d i v > `
) ;
defaultAccountFilters . language [ language ] = true ;
} ) ;
2020-10-27 04:28:25 +08:00
} ) ;
2020-05-20 07:11:57 +08:00
2020-08-10 02:52:00 +08:00
$ (
".pageAccount .content .filterButtons .buttonsAndTitle.funbox .buttons"
) . append ( ` <div class="button" filter="none">none</div> ` ) ;
2020-08-05 02:38:04 +08:00
getFunboxList ( ) . then ( ( funboxModes ) => {
funboxModes . forEach ( ( funbox ) => {
2020-08-10 02:52:00 +08:00
$ (
".pageAccount .content .filterButtons .buttonsAndTitle.funbox .buttons"
) . append (
` <div class="button" filter=" ${ funbox . name } "> ${ funbox . name . replace (
2020-08-05 02:38:04 +08:00
/_/g ,
" "
) } < / d i v > `
) ;
2020-08-10 02:52:00 +08:00
defaultAccountFilters . funbox [ funbox . name ] = true ;
2020-08-05 02:38:04 +08:00
} ) ;
} ) ;
2020-07-03 08:35:45 +08:00
function updateFilterTags ( ) {
2020-08-10 02:52:00 +08:00
$ (
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
) . empty ( ) ;
2020-07-03 08:35:45 +08:00
if ( dbSnapshot . tags . length > 0 ) {
$ ( ".pageAccount .content .filterButtons .buttonsAndTitle.tags" ) . removeClass (
"hidden"
) ;
2020-08-10 02:52:00 +08:00
$ (
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
) . append ( ` <div class="button" filter="none">no tag</div> ` ) ;
2020-07-03 08:35:45 +08:00
dbSnapshot . tags . forEach ( ( tag ) => {
2020-08-10 02:52:00 +08:00
defaultAccountFilters . tags [ tag . id ] = true ;
$ (
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
) . append ( ` <div class="button" filter=" ${ tag . id } "> ${ tag . name } </div> ` ) ;
2020-07-03 08:35:45 +08:00
} ) ;
} else {
$ ( ".pageAccount .content .filterButtons .buttonsAndTitle.tags" ) . addClass (
"hidden"
) ;
2020-06-12 05:31:06 +08:00
}
2020-08-19 05:56:21 +08:00
// showActiveFilters();
2020-06-12 05:31:06 +08:00
}
2020-05-20 07:11:57 +08:00
2020-08-10 02:52:00 +08:00
function toggleFilter ( group , filter ) {
if ( group === "date" ) {
Object . keys ( config . resultFilters . date ) . forEach ( ( date ) => {
setFilter ( "date" , date , false ) ;
} ) ;
2020-05-20 07:11:57 +08:00
}
2020-08-10 02:52:00 +08:00
config . resultFilters [ group ] [ filter ] = ! config . resultFilters [ group ] [ filter ] ;
2020-05-20 07:11:57 +08:00
}
2020-08-10 02:52:00 +08:00
function setFilter ( group , filter , set ) {
config . resultFilters [ group ] [ filter ] = set ;
2020-05-20 07:11:57 +08:00
}
2020-08-10 02:52:00 +08:00
// function toggleFilterButton(filter) {
// const element = $(
// `.pageAccount .content .filterButtons .button[filter=${filter}]`
// );
// if (element.hasClass("active")) {
// //disable that filter
// if (filter == "all" || filter == "none") {
// return;
// } else if (filter == "mode_words") {
// // $.each($(`.pageAccount .content .filterButtons .buttons.wordsFilter .button`),(index,obj)=>{
// // let f = $(obj).attr('filter')
// // disableFilterButton(f)
// // })
// } else if (filter == "mode_time") {
// // $.each($(`.pageAccount .content .filterButtons .buttons.timeFilter .button`),(index,obj)=>{
// // let f = $(obj).attr('filter')
// // disableFilterButton(f)
// // })
// } else if (filter == "punc_off") {
// enableFilterButton("punc_on");
// } else if (filter == "punc_on") {
// enableFilterButton("punc_off");
// }
// disableFilterButton(filter);
// disableFilterButton("all");
// } else {
// //enable that filter
// disableFilterButton("none");
// if (filter == "all") {
// $.each(
// $(`.pageAccount .content .filterButtons .button`),
// (index, obj) => {
// let f = $(obj).attr("filter");
// if (
// f != "none" &&
// f != "date_month" &&
// f != "date_week" &&
// f != "date_day"
// ) {
// enableFilterButton(f);
// }
// }
// );
// } else if (filter == "none") {
// disableFilterButton("all");
// $.each(
// $(`.pageAccount .content .filterButtons .button`),
// (index, obj) => {
// let f = $(obj).attr("filter");
// if (f != "none") {
// disableFilterButton(f);
// }
// }
// );
// } else if (
// filter == "date_all" ||
// filter == "date_month" ||
// filter == "date_week" ||
// filter == "date_day"
// ) {
// disableFilterButton("date_all");
// disableFilterButton("date_month");
// disableFilterButton("date_week");
// disableFilterButton("date_day");
// enableFilterButton(filter);
// }
// // else if(filter == "mode_words"){
// // $.each($(`.pageAccount .content .filterButtons .buttons.wordsFilter .button`),(index,obj)=>{
// // let f = $(obj).attr('filter');
// // enableFilterButton(f);
// // })
// // }else if(filter == "mode_time"){
// // $.each($(`.pageAccount .content .filterButtons .buttons.timeFilter .button`),(index,obj)=>{
// // let f = $(obj).attr('filter');
// // enableFilterButton(f);
// // })
// // }else if(['10','25','50','100','200'].includes(filter)){
// // enableFilterButton('words');
// // }else if(['15','30','60','120'].includes(filter)){
// // enableFilterButton('time');
// // }
// enableFilterButton(filter);
// }
// showActiveFilters();
// }
// function disableFilterButton(filter) {
// const element = $(
// `.pageAccount .content .filterButtons .button[filter=${filter}]`
// );
// element.removeClass("active");
// }
// function enableFilterButton(filter) {
// const element = $(
// `.pageAccount .content .filterButtons .button[filter=${filter}]`
// );
// element.addClass("active");
// }
function showActiveFilters ( ) {
// activeFilters = [];
// $.each($(".pageAccount .filterButtons .button"), (i, obj) => {
// if ($(obj).hasClass("active")) {
// activeFilters.push($(obj).attr("filter"));
// }
// });
let aboveChartDisplay = { } ;
Object . keys ( config . resultFilters ) . forEach ( ( group ) => {
aboveChartDisplay [ group ] = {
all : true ,
array : [ ] ,
} ;
Object . keys ( config . resultFilters [ group ] ) . forEach ( ( filter ) => {
if ( config . resultFilters [ group ] [ filter ] ) {
aboveChartDisplay [ group ] . array . push ( filter ) ;
} else {
aboveChartDisplay [ group ] . all = false ;
}
2020-09-25 23:21:09 +08:00
let buttonEl ;
if ( group === "date" ) {
buttonEl = $ (
` .pageAccount .group.topFilters .filterGroup[group=" ${ group } "] .button[filter=" ${ filter } "] `
) ;
} else {
buttonEl = $ (
` .pageAccount .group.filterButtons .filterGroup[group=" ${ group } "] .button[filter=" ${ filter } "] `
) ;
}
2020-08-10 02:52:00 +08:00
if ( config . resultFilters [ group ] [ filter ] ) {
buttonEl . addClass ( "active" ) ;
} else {
buttonEl . removeClass ( "active" ) ;
}
} ) ;
} ) ;
2020-09-14 04:21:01 +08:00
function addText ( group ) {
let ret = "" ;
ret += "<div class='group'>" ;
if ( group == "difficulty" ) {
ret += ` <span aria-label="Difficulty" data-balloon-pos="up"><i class="fas fa-fw fa-star"></i> ` ;
} else if ( group == "mode" ) {
ret += ` <span aria-label="Mode" data-balloon-pos="up"><i class="fas fa-fw fa-bars"></i> ` ;
} else if ( group == "punctuation" ) {
ret += ` <span aria-label="Punctuation" data-balloon-pos="up"><span class="punc" style="font-weight: 900;
width : 1.25 rem ;
text - align : center ;
display : inline - block ;
letter - spacing : - . 1 rem ; " > ! ? < / s p a n > ` ;
} else if ( group == "numbers" ) {
ret += ` <span aria-label="Numbers" data-balloon-pos="up"><span class="numbers" style="font-weight: 900;
2020-08-10 02:52:00 +08:00
width : 1.25 rem ;
text - align : center ;
2020-09-14 04:21:01 +08:00
margin - right : . 1 rem ;
2020-08-10 02:52:00 +08:00
display : inline - block ;
2020-09-14 04:21:01 +08:00
letter - spacing : - . 1 rem ; " > 15 < / s p a n > ` ;
} else if ( group == "words" ) {
ret += ` <span aria-label="Words" data-balloon-pos="up"><i class="fas fa-fw fa-font"></i> ` ;
} else if ( group == "time" ) {
ret += ` <span aria-label="Time" data-balloon-pos="up"><i class="fas fa-fw fa-clock"></i> ` ;
} else if ( group == "date" ) {
ret += ` <span aria-label="Date" data-balloon-pos="up"><i class="fas fa-fw fa-calendar"></i> ` ;
} else if ( group == "tags" ) {
ret += ` <span aria-label="Tags" data-balloon-pos="up"><i class="fas fa-fw fa-tags"></i> ` ;
} else if ( group == "language" ) {
ret += ` <span aria-label="Language" data-balloon-pos="up"><i class="fas fa-fw fa-globe-americas"></i> ` ;
} else if ( group == "funbox" ) {
ret += ` <span aria-label="Funbox" data-balloon-pos="up"><i class="fas fa-fw fa-gamepad"></i> ` ;
}
if ( aboveChartDisplay [ group ] . all ) {
ret += "all" ;
} else {
allall = false ;
if ( group === "tags" ) {
ret += aboveChartDisplay . tags . array
. map ( ( id ) => {
if ( id == "none" ) return id ;
let name = dbSnapshot . tags . filter ( ( t ) => t . id == id ) [ 0 ] ;
if ( name !== undefined ) {
return dbSnapshot . tags . filter ( ( t ) => t . id == id ) [ 0 ] . name ;
}
} )
. join ( ", " ) ;
2020-08-10 02:52:00 +08:00
} else {
2020-09-17 00:29:39 +08:00
ret += aboveChartDisplay [ group ] . array . join ( ", " ) . replace ( /_/g , " " ) ;
2020-08-10 02:52:00 +08:00
}
2020-05-20 07:11:57 +08:00
}
2020-09-14 04:21:01 +08:00
ret += "</span></div>" ;
return ret ;
}
let chartString = "" ;
2020-09-17 00:29:39 +08:00
//date
2020-09-14 04:21:01 +08:00
chartString += addText ( "date" ) ;
chartString += ` <div class="spacer"></div> ` ;
//mode
chartString += addText ( "mode" ) ;
chartString += ` <div class="spacer"></div> ` ;
//time
if ( aboveChartDisplay . mode . array . includes ( "time" ) ) {
chartString += addText ( "time" ) ;
chartString += ` <div class="spacer"></div> ` ;
}
//words
if ( aboveChartDisplay . mode . array . includes ( "words" ) ) {
chartString += addText ( "words" ) ;
chartString += ` <div class="spacer"></div> ` ;
}
//diff
chartString += addText ( "difficulty" ) ;
chartString += ` <div class="spacer"></div> ` ;
//punc
chartString += addText ( "punctuation" ) ;
chartString += ` <div class="spacer"></div> ` ;
2020-09-17 00:29:39 +08:00
//numbers
2020-09-14 04:21:01 +08:00
chartString += addText ( "numbers" ) ;
chartString += ` <div class="spacer"></div> ` ;
//language
chartString += addText ( "language" ) ;
chartString += ` <div class="spacer"></div> ` ;
2020-09-17 00:29:39 +08:00
//funbox
2020-09-14 04:21:01 +08:00
chartString += addText ( "funbox" ) ;
chartString += ` <div class="spacer"></div> ` ;
2020-09-17 00:29:39 +08:00
2020-09-14 04:21:01 +08:00
//tags
chartString += addText ( "tags" ) ;
// chartString += `<div class="spacer"></div>`;
// let allall = true;
// let count = 0;
// Object.keys(aboveChartDisplay).forEach((group) => {
// count++;
// if (group === "time" && !aboveChartDisplay.mode.array.includes("time"))
// return;
// if (group === "words" && !aboveChartDisplay.mode.array.includes("words"))
// return;
// if (aboveChartDisplay[group].array.length > 0) {
// chartString += "<div class='group'>";
// if (group == "difficulty") {
// chartString += `<span aria-label="Difficulty" data-balloon-pos="up"><i class="fas fa-fw fa-star"></i>`;
// } else if (group == "mode") {
// chartString += `<span aria-label="Mode" data-balloon-pos="up"><i class="fas fa-fw fa-bars"></i>`;
// } else if (group == "punctuation") {
// chartString += `<span aria-label="Punctuation" data-balloon-pos="up"><span class="punc" style="font-weight: 900;
// width: 1.25rem;
// text-align: center;
// display: inline-block;
// letter-spacing: -.1rem;">!?</span>`;
// } else if (group == "numbers") {
// chartString += `<span aria-label="Numbers" data-balloon-pos="up"><span class="numbers" style="font-weight: 900;
// width: 1.25rem;
// text-align: center;
// margin-right: .1rem;
// display: inline-block;
// letter-spacing: -.1rem;">15</span>`;
// } else if (group == "words") {
// chartString += `<span aria-label="Words" data-balloon-pos="up"><i class="fas fa-fw fa-font"></i>`;
// } else if (group == "time") {
// chartString += `<span aria-label="Time" data-balloon-pos="up"><i class="fas fa-fw fa-clock"></i>`;
// } else if (group == "date") {
// chartString += `<span aria-label="Date" data-balloon-pos="up"><i class="fas fa-fw fa-calendar"></i>`;
// } else if (group == "tags") {
// chartString += `<span aria-label="Tags" data-balloon-pos="up"><i class="fas fa-fw fa-tags"></i>`;
// } else if (group == "language") {
// chartString += `<span aria-label="Language" data-balloon-pos="up"><i class="fas fa-fw fa-globe-americas"></i>`;
// } else if (group == "funbox") {
// chartString += `<span aria-label="Funbox" data-balloon-pos="up"><i class="fas fa-fw fa-gamepad"></i>`;
// }
// if (aboveChartDisplay[group].all) {
// chartString += "all";
// } else {
// allall = false;
// if (group === "tags") {
// chartString += aboveChartDisplay.tags.array
// .map((id) => {
// if (id == "none") return id;
// let name = dbSnapshot.tags.filter((t) => t.id == id)[0];
// if (name !== undefined) {
// return dbSnapshot.tags.filter((t) => t.id == id)[0].name;
// }
// })
// .join(", ");
// } else {
// chartString += aboveChartDisplay[group].array
// .join(", ")
// .replace(/_/g, " ");
// }
// }
// chartString += "</span></div>";
// if (Object.keys(aboveChartDisplay).length !== count)
// chartString += `<div class="spacer"></div>`;
// }
// });
// if (allall) chartString = `<i class="fas fa-fw fa-filter"></i>all`;
2020-08-10 02:52:00 +08:00
$ ( ".pageAccount .group.chart .above" ) . html ( chartString ) ;
2020-08-19 06:19:40 +08:00
refreshAccountPage ( ) ;
2020-05-20 07:11:57 +08:00
}
2020-07-03 08:35:45 +08:00
function showChartPreloader ( ) {
$ ( ".pageAccount .group.chart .preloader" ) . stop ( true , true ) . animate (
{
opacity : 1 ,
} ,
125
) ;
2020-05-25 04:58:13 +08:00
}
2020-07-03 08:35:45 +08:00
function hideChartPreloader ( ) {
$ ( ".pageAccount .group.chart .preloader" ) . stop ( true , true ) . animate (
{
opacity : 0 ,
} ,
125
) ;
2020-05-25 04:58:13 +08:00
}
2020-09-14 04:21:01 +08:00
$ ( ".pageAccount .topFilters .button.allFilters" ) . click ( ( e ) => {
Object . keys ( config . resultFilters ) . forEach ( ( group ) => {
Object . keys ( config . resultFilters [ group ] ) . forEach ( ( filter ) => {
if ( group === "date" ) {
config . resultFilters [ group ] [ filter ] = false ;
2020-08-10 02:52:00 +08:00
} else {
2020-09-14 04:21:01 +08:00
config . resultFilters [ group ] [ filter ] = true ;
2020-08-10 02:52:00 +08:00
}
2020-09-14 04:21:01 +08:00
} ) ;
} ) ;
config . resultFilters . date . all = true ;
showActiveFilters ( ) ;
saveConfigToCookie ( ) ;
2020-09-17 00:29:39 +08:00
} ) ;
2020-08-10 02:52:00 +08:00
2020-09-14 04:21:01 +08:00
$ ( ".pageAccount .topFilters .button.currentConfigFilter" ) . click ( ( e ) => {
2020-08-10 02:52:00 +08:00
Object . keys ( config . resultFilters ) . forEach ( ( group ) => {
Object . keys ( config . resultFilters [ group ] ) . forEach ( ( filter ) => {
config . resultFilters [ group ] [ filter ] = false ;
} ) ;
2020-07-14 06:28:33 +08:00
} ) ;
2020-08-10 02:52:00 +08:00
config . resultFilters . difficulty [ config . difficulty ] = true ;
config . resultFilters . mode [ config . mode ] = true ;
2020-07-15 04:44:31 +08:00
if ( config . mode === "time" ) {
2020-08-10 02:52:00 +08:00
config . resultFilters . time [ config . time ] = true ;
2020-07-15 04:44:31 +08:00
} else if ( config . mode === "words" ) {
2020-08-10 02:52:00 +08:00
config . resultFilters . words [ config . words ] = true ;
2020-07-15 04:44:31 +08:00
}
2020-08-10 02:52:00 +08:00
if ( config . punctuation ) {
config . resultFilters . punctuation . on = true ;
2020-07-15 04:42:48 +08:00
} else {
2020-08-10 02:52:00 +08:00
config . resultFilters . punctuation . off = true ;
2020-07-15 04:42:48 +08:00
}
2020-09-03 17:19:53 +08:00
if ( config . numbers ) {
config . resultFilters . numbers . on = true ;
} else {
config . resultFilters . numbers . off = true ;
}
2020-08-10 02:52:00 +08:00
config . resultFilters . language [ config . language ] = true ;
config . resultFilters . funbox [ activeFunBox ] = true ;
config . resultFilters . tags . none = true ;
dbSnapshot . tags . forEach ( ( tag ) => {
if ( tag . active === true ) {
config . resultFilters . tags . none = false ;
config . resultFilters . tags [ tag . id ] = true ;
}
} ) ;
2020-07-14 06:28:33 +08:00
2020-08-10 02:52:00 +08:00
config . resultFilters . date . all = true ;
showActiveFilters ( ) ;
2020-07-14 06:28:33 +08:00
saveConfigToCookie ( ) ;
2020-09-17 00:29:39 +08:00
} ) ;
2020-09-14 04:21:01 +08:00
$ ( ".pageAccount .topFilters .button.toggleAdvancedFilters" ) . click ( ( e ) => {
$ ( ".pageAccount .filterButtons" ) . slideToggle ( 250 ) ;
2020-10-27 04:28:25 +08:00
$ ( ".pageAccount .topFilters .button.toggleAdvancedFilters" ) . toggleClass (
"active"
) ;
2020-09-17 00:29:39 +08:00
} ) ;
2020-09-14 04:21:01 +08:00
2020-10-27 04:28:25 +08:00
$ (
".pageAccount .filterButtons .buttonsAndTitle .buttons, .pageAccount .group.topFilters .buttonsAndTitle.testDate .buttons"
) . click ( ".button" , ( e ) => {
const filter = $ ( e . target ) . attr ( "filter" ) ;
const group = $ ( e . target ) . parents ( ".buttons" ) . attr ( "group" ) ;
// toggleFilterButton(filter);
if ( $ ( e . target ) . hasClass ( "allFilters" ) ) {
Object . keys ( config . resultFilters ) . forEach ( ( group ) => {
Object . keys ( config . resultFilters [ group ] ) . forEach ( ( filter ) => {
if ( group === "date" ) {
2020-09-14 04:21:01 +08:00
config . resultFilters [ group ] [ filter ] = false ;
2020-10-27 04:28:25 +08:00
} else {
config . resultFilters [ group ] [ filter ] = true ;
}
2020-09-14 04:21:01 +08:00
} ) ;
2020-10-27 04:28:25 +08:00
} ) ;
config . resultFilters . date . all = true ;
} else if ( $ ( e . target ) . hasClass ( "noFilters" ) ) {
Object . keys ( config . resultFilters ) . forEach ( ( group ) => {
Object . keys ( config . resultFilters [ group ] ) . forEach ( ( filter ) => {
config . resultFilters [ group ] [ filter ] = false ;
} ) ;
} ) ;
} else {
if ( e . shiftKey ) {
Object . keys ( config . resultFilters [ group ] ) . forEach ( ( filter ) => {
config . resultFilters [ group ] [ filter ] = false ;
} ) ;
setFilter ( group , filter , true ) ;
2020-09-14 04:21:01 +08:00
} else {
2020-10-27 04:28:25 +08:00
toggleFilter ( group , filter ) ;
2020-09-14 04:21:01 +08:00
}
}
2020-10-27 04:28:25 +08:00
showActiveFilters ( ) ;
saveConfigToCookie ( ) ;
} ) ;
2020-07-14 06:28:33 +08:00
2020-09-14 05:48:32 +08:00
function fillPbTables ( ) {
$ ( ".pageAccount .timePbTable tbody" ) . html ( `
< tr >
< td > 15 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r >
< tr >
< td > 30 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r >
< tr >
< td > 60 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r >
< tr >
< td > 120 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r >
` );
$ ( ".pageAccount .wordsPbTable tbody" ) . html ( `
< tr >
< td > 10 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r >
< tr >
< td > 25 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r >
< tr >
< td > 50 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r >
< tr >
< td > 100 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r >
` );
const pb = dbSnapshot . personalBests ;
let pbData ;
let text ;
text = "" ;
try {
pbData = pb . time [ 15 ] . sort ( ( a , b ) => b . wpm - a . wpm ) [ 0 ] ;
text += ` <tr>
< td > 15 < / t d >
< td > $ { pbData . wpm } < / t d >
2020-09-17 00:29:39 +08:00
< td > $ { pbData . raw === undefined ? "-" : pbData . raw } < / t d >
< td > $ { pbData . acc === undefined ? "-" : pbData . acc + "%" } < / t d >
2020-10-12 08:12:25 +08:00
< td >
$ { pbData . consistency === undefined ? "-" : pbData . consistency + "%" }
< / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
} catch ( e ) {
text += ` <tr>
< td > 15 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
}
try {
pbData = pb . time [ 30 ] . sort ( ( a , b ) => b . wpm - a . wpm ) [ 0 ] ;
text += ` <tr>
< td > 30 < / t d >
< td > $ { pbData . wpm } < / t d >
2020-09-17 00:29:39 +08:00
< td > $ { pbData . raw === undefined ? "-" : pbData . raw } < / t d >
< td > $ { pbData . acc === undefined ? "-" : pbData . acc + "%" } < / t d >
2020-10-12 08:12:25 +08:00
< td >
$ { pbData . consistency === undefined ? "-" : pbData . consistency + "%" }
< / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
} catch ( e ) {
text += ` <tr>
< td > 30 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
}
try {
pbData = pb . time [ 60 ] . sort ( ( a , b ) => b . wpm - a . wpm ) [ 0 ] ;
text += ` <tr>
< td > 60 < / t d >
< td > $ { pbData . wpm } < / t d >
2020-09-17 00:29:39 +08:00
< td > $ { pbData . raw === undefined ? "-" : pbData . raw } < / t d >
< td > $ { pbData . acc === undefined ? "-" : pbData . acc + "%" } < / t d >
2020-10-12 08:12:25 +08:00
< td >
$ { pbData . consistency === undefined ? "-" : pbData . consistency + "%" }
< / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
} catch ( e ) {
text += ` <tr>
< td > 60 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
}
try {
pbData = pb . time [ 120 ] . sort ( ( a , b ) => b . wpm - a . wpm ) [ 0 ] ;
text += ` <tr>
< td > 120 < / t d >
< td > $ { pbData . wpm } < / t d >
2020-09-17 00:29:39 +08:00
< td > $ { pbData . raw === undefined ? "-" : pbData . raw } < / t d >
< td > $ { pbData . acc === undefined ? "-" : pbData . acc + "%" } < / t d >
2020-10-12 08:12:25 +08:00
< td >
$ { pbData . consistency === undefined ? "-" : pbData . consistency + "%" }
< / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
} catch ( e ) {
text += ` <tr>
< td > 120 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
}
$ ( ".pageAccount .timePbTable tbody" ) . html ( text ) ;
text = "" ;
try {
pbData = pb . words [ 10 ] . sort ( ( a , b ) => b . wpm - a . wpm ) [ 0 ] ;
text += ` <tr>
< td > 10 < / t d >
< td > $ { pbData . wpm } < / t d >
2020-09-17 00:29:39 +08:00
< td > $ { pbData . raw === undefined ? "-" : pbData . raw } < / t d >
< td > $ { pbData . acc === undefined ? "-" : pbData . acc + "%" } < / t d >
2020-10-12 08:12:25 +08:00
< td >
$ { pbData . consistency === undefined ? "-" : pbData . consistency + "%" }
< / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
} catch ( e ) {
text += ` <tr>
< td > 10 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
}
try {
pbData = pb . words [ 25 ] . sort ( ( a , b ) => b . wpm - a . wpm ) [ 0 ] ;
text += ` <tr>
< td > 25 < / t d >
< td > $ { pbData . wpm } < / t d >
2020-09-17 00:29:39 +08:00
< td > $ { pbData . raw === undefined ? "-" : pbData . raw } < / t d >
< td > $ { pbData . acc === undefined ? "-" : pbData . acc + "%" } < / t d >
2020-10-12 08:12:25 +08:00
< td >
$ { pbData . consistency === undefined ? "-" : pbData . consistency + "%" }
< / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
} catch ( e ) {
text += ` <tr>
< td > 25 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
}
try {
pbData = pb . words [ 50 ] . sort ( ( a , b ) => b . wpm - a . wpm ) [ 0 ] ;
text += ` <tr>
< td > 50 < / t d >
< td > $ { pbData . wpm } < / t d >
2020-09-17 00:29:39 +08:00
< td > $ { pbData . raw === undefined ? "-" : pbData . raw } < / t d >
< td > $ { pbData . acc === undefined ? "-" : pbData . acc + "%" } < / t d >
2020-10-12 08:12:25 +08:00
< td >
$ { pbData . consistency === undefined ? "-" : pbData . consistency + "%" }
< / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
} catch ( e ) {
text += ` <tr>
< td > 50 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
}
try {
pbData = pb . words [ 100 ] . sort ( ( a , b ) => b . wpm - a . wpm ) [ 0 ] ;
text += ` <tr>
< td > 100 < / t d >
< td > $ { pbData . wpm } < / t d >
2020-09-17 00:29:39 +08:00
< td > $ { pbData . raw === undefined ? "-" : pbData . raw } < / t d >
< td > $ { pbData . acc === undefined ? "-" : pbData . acc + "%" } < / t d >
2020-10-12 08:12:25 +08:00
< td >
$ { pbData . consistency === undefined ? "-" : pbData . consistency + "%" }
< / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
} catch ( e ) {
text += ` <tr>
< td > 100 < / t d >
< td > - < / t d >
< td > - < / t d >
< td > - < / t d >
2020-10-12 08:12:25 +08:00
< td > - < / t d >
2020-09-14 05:48:32 +08:00
< / t r > ` ;
}
$ ( ".pageAccount .wordsPbTable tbody" ) . html ( text ) ;
}
2020-05-30 07:21:39 +08:00
let filteredResults = [ ] ;
let visibleTableLines = 0 ;
2020-07-03 08:35:45 +08:00
function loadMoreLines ( ) {
if ( filteredResults == [ ] || filteredResults . length == 0 ) return ;
for ( let i = visibleTableLines ; i < visibleTableLines + 10 ; i ++ ) {
2020-05-30 07:21:39 +08:00
result = filteredResults [ i ] ;
2020-07-03 08:35:45 +08:00
if ( result == undefined ) continue ;
let withpunc = "" ;
2020-06-24 07:56:55 +08:00
// if (result.punctuation) {
// withpunc = '<br>punctuation';
// }
// if (result.blindMode) {
// withpunc = '<br>blind';
// }
2020-05-30 07:21:39 +08:00
let diff = result . difficulty ;
2020-07-03 08:35:45 +08:00
if ( diff == undefined ) {
diff = "normal" ;
2020-05-30 07:21:39 +08:00
}
2020-05-30 20:59:45 +08:00
2020-09-24 05:34:52 +08:00
let raw ;
2020-10-27 04:28:25 +08:00
try {
2020-09-24 05:34:52 +08:00
raw = result . rawWpm . toFixed ( 2 ) ;
if ( raw == undefined ) {
raw = "-" ;
}
} catch ( e ) {
2020-07-03 08:35:45 +08:00
raw = "-" ;
2020-05-30 20:59:45 +08:00
}
2020-06-24 07:55:15 +08:00
2020-07-03 08:35:45 +08:00
let icons = ` <span aria-label=" ${ result . language . replace (
"_" ,
" "
) } " data-balloon-pos=" up "><i class=" fas fa - fw fa - globe - americas " > < / i > < / s p a n > ` ;
2020-06-24 07:55:15 +08:00
2020-07-03 08:35:45 +08:00
if ( diff === "normal" ) {
2020-06-24 07:55:15 +08:00
icons += ` <span aria-label=" ${ result . difficulty } " data-balloon-pos="up"><i class="far fa-fw fa-star"></i></span> ` ;
2020-07-03 08:35:45 +08:00
} else if ( diff === "expert" ) {
2020-06-24 07:55:15 +08:00
icons += ` <span aria-label=" ${ result . difficulty } " data-balloon-pos="up"><i class="fas fa-fw fa-star-half-alt"></i></span> ` ;
2020-07-03 08:35:45 +08:00
} else if ( diff === "master" ) {
2020-06-24 07:55:15 +08:00
icons += ` <span aria-label=" ${ result . difficulty } " data-balloon-pos="up"><i class="fas fa-fw fa-star"></i></span> ` ;
}
2020-07-03 08:35:45 +08:00
if ( result . punctuation ) {
2020-07-18 00:01:34 +08:00
icons += ` <span aria-label="punctuation" data-balloon-pos="up" style="font-weight:900">!?</span> ` ;
2020-06-24 07:55:15 +08:00
}
2020-09-04 05:14:39 +08:00
if ( result . numbers ) {
icons += ` <span aria-label="numbers" data-balloon-pos="up" style="font-weight:900">15</span> ` ;
}
2020-07-03 08:35:45 +08:00
if ( result . blindMode ) {
2020-06-24 07:55:15 +08:00
icons += ` <span aria-label="blind mode" data-balloon-pos="up"><i class="fas fa-fw fa-eye-slash"></i></span> ` ;
}
2020-08-05 02:38:04 +08:00
if ( result . funbox !== "none" && result . funbox !== undefined ) {
icons += ` <span aria-label=" ${ result . funbox . replace (
/_/g ,
" "
) } " data-balloon-pos=" up "><i class=" fas fa - gamepad " > < / i > < / s p a n > ` ;
2020-07-21 05:51:02 +08:00
}
2020-08-25 11:57:43 +08:00
if ( result . chartData === undefined ) {
icons += ` <span class="hoverChartButton" aria-label="No chart data found" data-balloon-pos="up"><i class="fas fa-chart-line"></i></span> ` ;
} else if ( result . chartData === "toolong" ) {
icons += ` <span class="hoverChartButton" aria-label="Chart history is not available for long tests" data-balloon-pos="up"><i class="fas fa-chart-line"></i></span> ` ;
} else {
2020-10-27 04:28:25 +08:00
icons += ` <span class="hoverChartButton" filteredResultsId=" ${ i } " style="opacity: 1"><i class="fas fa-chart-line"></i></span> ` ;
2020-08-25 11:57:43 +08:00
}
2020-06-24 07:55:15 +08:00
let tagNames = "" ;
2020-07-03 08:35:45 +08:00
if ( result . tags !== undefined && result . tags . length > 0 ) {
result . tags . forEach ( ( tag ) => {
dbSnapshot . tags . forEach ( ( snaptag ) => {
if ( tag === snaptag . id ) {
2020-06-24 07:55:15 +08:00
tagNames += snaptag . name + ", " ;
}
2020-07-03 08:35:45 +08:00
} ) ;
} ) ;
2020-06-24 07:55:15 +08:00
tagNames = tagNames . substring ( 0 , tagNames . length - 2 ) ;
}
// if(tagNames !== ""){
// icons += `<span aria-label="${tagNames}" data-balloon-pos="up"><i class="fas fa-fw fa-tag"></i></span>`;
// }
2020-07-01 01:08:17 +08:00
let restags ;
2020-07-03 08:35:45 +08:00
if ( result . tags === undefined ) {
restags = "[]" ;
} else {
restags = JSON . stringify ( result . tags ) ;
2020-07-01 01:08:17 +08:00
}
2020-07-21 05:51:02 +08:00
let tagIcons = ` <span id="resultEditTags" resultId=" ${ result . id } " tags=' ${ restags } ' aria-label="no tags" data-balloon-pos="up" style="opacity: .25"><i class="fas fa-fw fa-tag"></i></span> ` ;
2020-06-24 07:55:15 +08:00
2020-07-03 08:35:45 +08:00
if ( tagNames !== "" ) {
if ( result . tags !== undefined && result . tags . length > 1 ) {
2020-07-01 01:08:17 +08:00
tagIcons = ` <span id="resultEditTags" resultId=" ${ result . id } " tags=' ${ restags } ' aria-label=" ${ tagNames } " data-balloon-pos="up"><i class="fas fa-fw fa-tags"></i></span> ` ;
2020-07-03 08:35:45 +08:00
} else {
2020-07-01 01:08:17 +08:00
tagIcons = ` <span id="resultEditTags" resultId=" ${ result . id } " tags=' ${ restags } ' aria-label=" ${ tagNames } " data-balloon-pos="up"><i class="fas fa-fw fa-tag"></i></span> ` ;
2020-06-24 07:55:15 +08:00
}
}
2020-09-12 08:34:56 +08:00
let consistency = result . consistency ;
2020-07-31 06:03:47 +08:00
if ( consistency === undefined ) {
consistency = "-" ;
} else {
2020-09-12 08:34:56 +08:00
consistency = consistency . toFixed ( 2 ) + "%" ;
2020-07-31 06:03:47 +08:00
}
2020-09-27 07:10:30 +08:00
let pb = result . isPb ;
if ( pb ) {
2020-10-27 04:28:25 +08:00
pb = '<i class="fas fa-fw fa-crown"></i>' ;
2020-09-27 07:10:30 +08:00
} else {
2020-10-27 04:28:25 +08:00
pb = "" ;
2020-09-27 07:10:30 +08:00
}
2020-05-30 07:21:39 +08:00
$ ( ".pageAccount .history table tbody" ) . append ( `
< tr >
2020-09-27 07:10:30 +08:00
< td > $ { pb } < / t d >
2020-09-12 08:27:14 +08:00
< td > $ { result . wpm . toFixed ( 2 ) } < / t d >
2020-09-24 05:34:52 +08:00
< td > $ { raw } < / t d >
2020-09-12 08:27:14 +08:00
< td > $ { result . acc . toFixed ( 2 ) } % < / t d >
2020-05-30 07:21:39 +08:00
< td > $ { result . correctChars } < / t d >
< td > $ { result . incorrectChars } < / t d >
2020-07-31 06:03:47 +08:00
< td > $ { consistency } < / t d >
2020-05-31 02:22:11 +08:00
< td > $ { result . mode } $ { result . mode2 } $ { withpunc } < / t d >
2020-06-24 07:55:15 +08:00
< td class = "infoIcons" > $ { icons } < / t d >
< td > $ { tagIcons } < / t d >
2020-07-03 08:35:45 +08:00
< td > $ { moment ( result . timestamp ) . format ( "DD MMM YYYY<br>HH:mm" ) } < / t d >
2020-05-30 07:21:39 +08:00
< / t r > ` ) ;
}
2020-07-03 08:35:45 +08:00
visibleTableLines += 10 ;
2020-07-17 07:29:28 +08:00
if ( visibleTableLines >= filteredResults . length ) {
$ ( ".pageAccount .loadMoreButton" ) . addClass ( "hidden" ) ;
} else {
$ ( ".pageAccount .loadMoreButton" ) . removeClass ( "hidden" ) ;
}
2020-05-30 07:21:39 +08:00
}
2020-09-06 22:17:26 +08:00
function clearGlobalStats ( ) {
$ ( ".pageAccount .globalTimeTyping .val" ) . text ( ` - ` ) ;
$ ( ".pageAccount .globalTestsStarted .val" ) . text ( ` - ` ) ;
$ ( ".pageAccount .globalTestsCompleted .val" ) . text ( ` - ` ) ;
}
2020-09-06 09:31:54 +08:00
function refreshGlobalStats ( ) {
2020-09-17 00:29:39 +08:00
if ( dbSnapshot . globalStats . time != undefined ) {
2020-09-06 22:17:26 +08:00
let th = Math . floor ( dbSnapshot . globalStats . time / 3600 ) ;
let tm = Math . floor ( ( dbSnapshot . globalStats . time % 3600 ) / 60 ) ;
let ts = Math . floor ( ( dbSnapshot . globalStats . time % 3600 ) % 60 ) ;
$ ( ".pageAccount .globalTimeTyping .val" ) . text ( `
$ { th < 10 ? "0" + th : th } : $ { tm < 10 ? "0" + tm : tm } : $ {
ts < 10 ? "0" + ts : ts
}
2020-09-06 09:31:54 +08:00
` );
2020-09-06 22:17:26 +08:00
}
if ( dbSnapshot . globalStats . started != undefined ) {
2020-09-17 00:29:39 +08:00
$ ( ".pageAccount .globalTestsStarted .val" ) . text (
dbSnapshot . globalStats . started
) ;
2020-09-06 22:17:26 +08:00
}
if ( dbSnapshot . globalStats . completed != undefined ) {
2020-09-17 00:29:39 +08:00
$ ( ".pageAccount .globalTestsCompleted .val" ) . text (
dbSnapshot . globalStats . completed
) ;
2020-09-06 22:17:26 +08:00
}
2020-09-06 09:31:54 +08:00
}
2020-08-14 04:51:23 +08:00
let totalSecondsFiltered = 0 ;
2020-05-10 09:04:05 +08:00
function refreshAccountPage ( ) {
2020-07-03 08:35:45 +08:00
function cont ( ) {
2020-08-09 02:43:55 +08:00
refreshThemeColorObject ( ) ;
2020-09-06 09:31:54 +08:00
refreshGlobalStats ( ) ;
2020-09-14 05:48:32 +08:00
fillPbTables ( ) ;
2020-08-09 02:43:55 +08:00
2020-05-20 07:11:57 +08:00
let chartData = [ ] ;
2020-09-09 22:56:30 +08:00
let wpmChartData = [ ] ;
2020-09-12 08:27:14 +08:00
let rawChartData = [ ] ;
2020-09-06 22:17:26 +08:00
let accChartData = [ ] ;
2020-05-30 20:59:45 +08:00
visibleTableLines = 0 ;
2020-07-03 08:35:45 +08:00
2020-05-10 09:04:05 +08:00
let topWpm = 0 ;
2020-07-03 08:35:45 +08:00
let topMode = "" ;
2020-05-17 20:17:08 +08:00
let testRestarts = 0 ;
2020-05-20 03:27:08 +08:00
let totalWpm = 0 ;
2020-05-20 07:11:57 +08:00
let testCount = 0 ;
2020-05-10 09:04:05 +08:00
2020-05-30 04:27:24 +08:00
let last10 = 0 ;
2020-05-20 07:11:57 +08:00
let wpmLast10total = 0 ;
2020-05-30 04:27:24 +08:00
let totalAcc = 0 ;
let totalAcc10 = 0 ;
2020-05-30 05:37:52 +08:00
let rawWpm = {
total : 0 ,
count : 0 ,
last10Total : 0 ,
last10Count : 0 ,
2020-07-03 08:35:45 +08:00
max : 0 ,
} ;
2020-05-30 05:37:52 +08:00
2020-05-30 07:21:39 +08:00
let totalSeconds = 0 ;
2020-08-14 04:51:23 +08:00
totalSecondsFiltered = 0 ;
2020-07-03 08:35:45 +08:00
2020-07-31 06:03:47 +08:00
let totalCons = 0 ;
let totalCons10 = 0 ;
let consCount = 0 ;
2020-05-30 07:21:39 +08:00
2020-09-10 03:10:25 +08:00
let dailyActivityDays = [ ] ;
2020-10-09 23:40:55 +08:00
let activityChartData = { } ;
2020-09-10 03:10:25 +08:00
2020-05-30 07:21:39 +08:00
filteredResults = [ ] ;
2020-05-12 07:59:12 +08:00
$ ( ".pageAccount .history table tbody" ) . empty ( ) ;
2020-07-03 08:35:45 +08:00
dbSnapshot . results . forEach ( ( result ) => {
2020-05-30 07:21:39 +08:00
let tt = 0 ;
2020-07-03 08:35:45 +08:00
if ( result . testDuration == undefined ) {
2020-06-05 07:01:05 +08:00
//test finished before testDuration field was introduced - estimate
2020-07-03 08:35:45 +08:00
if ( result . mode == "time" ) {
2020-05-30 07:21:39 +08:00
tt = parseFloat ( result . mode2 ) ;
2020-07-03 08:35:45 +08:00
} else if ( result . mode == "words" ) {
tt = ( parseFloat ( result . mode2 ) / parseFloat ( result . wpm ) ) * 60 ;
2020-05-30 07:21:39 +08:00
}
2020-07-03 08:35:45 +08:00
} else {
2020-06-05 07:01:05 +08:00
tt = parseFloat ( result . testDuration ) ;
2020-05-30 07:21:39 +08:00
}
2020-07-03 08:35:45 +08:00
if ( result . incompleteTestSeconds != undefined ) {
2020-06-09 01:58:18 +08:00
tt += result . incompleteTestSeconds ;
2020-07-03 08:35:45 +08:00
} else if ( result . restartCount != undefined && result . restartCount > 0 ) {
tt += ( tt / 4 ) * result . restartCount ;
2020-05-30 07:21:39 +08:00
}
totalSeconds += tt ;
2020-05-25 04:58:13 +08:00
// console.log(result);
2020-05-20 07:11:57 +08:00
//apply filters
2020-09-04 05:05:15 +08:00
try {
let resdiff = result . difficulty ;
if ( resdiff == undefined ) {
resdiff = "normal" ;
2020-05-25 04:58:13 +08:00
}
2020-09-04 05:05:15 +08:00
// if (!activeFilters.includes("difficulty_" + resdiff)) return;
if ( ! config . resultFilters . difficulty [ resdiff ] ) return ;
// if (!activeFilters.includes("mode_" + result.mode)) return;
if ( ! config . resultFilters . mode [ result . mode ] ) return ;
if ( result . mode == "time" ) {
let timefilter = "custom" ;
if ( [ 15 , 30 , 60 , 120 ] . includes ( parseInt ( result . mode2 ) ) ) {
timefilter = result . mode2 ;
}
// if (!activeFilters.includes(timefilter)) return;
if ( ! config . resultFilters . time [ timefilter ] ) return ;
} else if ( result . mode == "words" ) {
let wordfilter = "custom" ;
if ( [ 10 , 25 , 50 , 100 , 200 ] . includes ( parseInt ( result . mode2 ) ) ) {
wordfilter = result . mode2 ;
}
// if (!activeFilters.includes(wordfilter)) return;
if ( ! config . resultFilters . words [ wordfilter ] ) return ;
2020-05-25 04:58:13 +08:00
}
2020-09-04 05:05:15 +08:00
// if (!activeFilters.includes("lang_" + result.language)) return;
2020-10-23 21:49:07 +08:00
let langFilter = config . resultFilters . language [ result . language ] ;
2020-10-27 04:28:25 +08:00
if (
result . language === "english_expanded" &&
config . resultFilters . language . english _1k
) {
2020-10-23 21:49:07 +08:00
langFilter = true ;
}
if ( ! langFilter ) return ;
2020-05-25 04:58:13 +08:00
2020-09-04 05:05:15 +08:00
let puncfilter = "off" ;
if ( result . punctuation ) {
puncfilter = "on" ;
}
if ( ! config . resultFilters . punctuation [ puncfilter ] ) return ;
// if (!activeFilters.includes(puncfilter)) return;
2020-05-20 07:11:57 +08:00
2020-09-04 05:05:15 +08:00
let numfilter = "off" ;
if ( result . numbers ) {
numfilter = "on" ;
}
if ( ! config . resultFilters . numbers [ numfilter ] ) return ;
2020-09-03 17:19:53 +08:00
2020-09-04 05:05:15 +08:00
if ( result . funbox === "none" || result . funbox === undefined ) {
// if (!activeFilters.includes("funbox_none")) return;
if ( ! config . resultFilters . funbox . none ) return ;
} else {
// if (!activeFilters.includes("funbox_" + result.funbox)) return;
if ( ! config . resultFilters . funbox [ result . funbox ] ) return ;
}
2020-08-05 02:38:04 +08:00
2020-09-04 05:05:15 +08:00
let tagHide = true ;
2020-08-09 02:54:30 +08:00
2020-09-04 05:05:15 +08:00
if ( result . tags === undefined || result . tags . length === 0 ) {
//no tags, show when no tag is enabled
if ( dbSnapshot . tags . length > 0 ) {
// if (activeFilters.includes("tag_notag")) tagHide = false;
if ( config . resultFilters . tags . none ) tagHide = false ;
} else {
tagHide = false ;
}
2020-08-09 09:41:52 +08:00
} else {
2020-09-04 05:05:15 +08:00
//tags exist
let validTags = dbSnapshot . tags . map ( ( t ) => t . id ) ;
result . tags . forEach ( ( tag ) => {
//check if i even need to check tags anymore
if ( ! tagHide ) return ;
//check if tag is valid
if ( validTags . includes ( tag ) ) {
//tag valid, check if filter is on
// if (activeFilters.includes("tag_" + tag)) tagHide = false;
if ( config . resultFilters . tags [ tag ] ) tagHide = false ;
2020-09-06 09:31:54 +08:00
} else {
//tag not found in valid tags, meaning probably deleted
if ( config . resultFilters . tags . none ) tagHide = false ;
2020-09-04 05:05:15 +08:00
}
} ) ;
2020-08-09 09:41:52 +08:00
}
2020-06-12 05:31:06 +08:00
2020-09-04 05:05:15 +08:00
if ( tagHide ) return ;
2020-08-09 02:54:30 +08:00
2020-09-04 05:05:15 +08:00
let timeSinceTest = Math . abs ( result . timestamp - Date . now ( ) ) / 1000 ;
2020-06-22 07:43:38 +08:00
2020-09-04 05:05:15 +08:00
let datehide = true ;
2020-06-22 07:43:38 +08:00
2020-09-04 05:05:15 +08:00
// if (
// activeFilters.includes("date_all") ||
// (activeFilters.includes("date_day") && timeSinceTest <= 86400) ||
// (activeFilters.includes("date_week") && timeSinceTest <= 604800) ||
// (activeFilters.includes("date_month") && timeSinceTest <= 18144000)
// ) {
// datehide = false;
// }
2020-08-10 02:52:00 +08:00
2020-09-04 05:05:15 +08:00
if (
config . resultFilters . date . all ||
( config . resultFilters . date . last _day && timeSinceTest <= 86400 ) ||
( config . resultFilters . date . last _week && timeSinceTest <= 604800 ) ||
( config . resultFilters . date . last _month && timeSinceTest <= 2592000 )
) {
datehide = false ;
}
2020-06-22 07:43:38 +08:00
2020-09-04 05:05:15 +08:00
if ( datehide ) return ;
2020-06-22 07:43:38 +08:00
2020-09-04 05:05:15 +08:00
filteredResults . push ( result ) ;
} catch ( e ) {
showNotification (
"Something went wrong when filtering. Resetting filters." ,
5000
) ;
config . resultFilters = defaultAccountFilters ;
saveConfigToCookie ( ) ;
}
2020-05-30 07:21:39 +08:00
//filters done
2020-06-22 07:43:38 +08:00
//=======================================
2020-05-30 07:21:39 +08:00
2020-09-10 03:10:25 +08:00
let resultDate = new Date ( result . timestamp ) ;
resultDate . setSeconds ( 0 ) ;
resultDate . setMinutes ( 0 ) ;
resultDate . setHours ( 0 ) ;
resultDate . setMilliseconds ( 0 ) ;
resultDate = resultDate . getTime ( ) ;
if ( Object . keys ( activityChartData ) . includes ( String ( resultDate ) ) ) {
2020-10-09 23:40:55 +08:00
activityChartData [ resultDate ] . amount ++ ;
activityChartData [ resultDate ] . totalWpm += result . wpm ;
2020-09-10 03:10:25 +08:00
} else {
2020-10-09 23:40:55 +08:00
activityChartData [ resultDate ] = {
amount : 1 ,
totalWpm : result . wpm ,
2020-10-27 04:28:25 +08:00
} ;
2020-09-10 03:10:25 +08:00
}
2020-05-30 07:21:39 +08:00
tt = 0 ;
2020-07-14 04:35:42 +08:00
if ( result . testDuration == undefined ) {
//test finished before testDuration field was introduced - estimate
2020-07-03 08:35:45 +08:00
if ( result . mode == "time" ) {
2020-05-30 07:21:39 +08:00
tt = parseFloat ( result . mode2 ) ;
2020-07-03 08:35:45 +08:00
} else if ( result . mode == "words" ) {
tt = ( parseFloat ( result . mode2 ) / parseFloat ( result . wpm ) ) * 60 ;
2020-05-30 07:21:39 +08:00
}
2020-07-03 08:35:45 +08:00
} else {
2020-07-14 04:35:42 +08:00
tt = parseFloat ( result . testDuration ) ;
2020-05-30 07:21:39 +08:00
}
2020-07-14 04:35:42 +08:00
if ( result . incompleteTestSeconds != undefined ) {
tt += result . incompleteTestSeconds ;
} else if ( result . restartCount != undefined && result . restartCount > 0 ) {
2020-07-03 08:35:45 +08:00
tt += ( tt / 4 ) * result . restartCount ;
2020-05-30 07:21:39 +08:00
}
totalSecondsFiltered += tt ;
2020-07-03 08:35:45 +08:00
if ( last10 < 10 ) {
2020-05-30 04:27:24 +08:00
last10 ++ ;
2020-05-20 07:11:57 +08:00
wpmLast10total += result . wpm ;
2020-05-30 04:27:24 +08:00
totalAcc10 += result . acc ;
2020-07-31 06:03:47 +08:00
result . consistency !== undefined
? ( totalCons10 += result . consistency )
: 0 ;
2020-05-20 07:11:57 +08:00
}
testCount ++ ;
2020-07-31 06:03:47 +08:00
if ( result . consistency !== undefined ) {
consCount ++ ;
totalCons += result . consistency ;
}
2020-07-03 08:35:45 +08:00
if ( result . rawWpm != null ) {
if ( rawWpm . last10Count < 10 ) {
2020-05-30 05:37:52 +08:00
rawWpm . last10Count ++ ;
rawWpm . last10Total += result . rawWpm ;
}
rawWpm . total += result . rawWpm ;
rawWpm . count ++ ;
2020-07-03 08:35:45 +08:00
if ( result . rawWpm > rawWpm . max ) {
2020-05-30 05:37:52 +08:00
rawWpm . max = result . rawWpm ;
}
}
2020-05-30 04:27:24 +08:00
totalAcc += result . acc ;
2020-05-20 07:11:57 +08:00
2020-05-17 20:17:08 +08:00
if ( result . restartCount != undefined ) {
testRestarts += result . restartCount ;
}
2020-05-30 07:21:39 +08:00
2020-05-20 07:11:57 +08:00
chartData . push ( {
x : result . timestamp ,
y : result . wpm ,
acc : result . acc ,
mode : result . mode ,
mode2 : result . mode2 ,
punctuation : result . punctuation ,
language : result . language ,
2020-05-29 22:58:01 +08:00
timestamp : result . timestamp ,
2020-07-03 08:35:45 +08:00
difficulty : result . difficulty ,
2020-09-17 00:29:39 +08:00
raw : result . rawWpm ,
2020-05-20 07:11:57 +08:00
} ) ;
2020-05-10 09:04:05 +08:00
2020-09-09 22:56:30 +08:00
wpmChartData . push ( result . wpm ) ;
2020-09-12 08:27:14 +08:00
accChartData . push ( {
x : result . timestamp ,
y : result . acc ,
2020-09-17 00:29:39 +08:00
} ) ;
2020-09-06 22:17:26 +08:00
2020-05-10 09:04:05 +08:00
if ( result . wpm > topWpm ) {
2020-05-11 23:29:18 +08:00
let puncsctring = result . punctuation ? ",<br>with punctuation" : "" ;
2020-09-04 05:05:15 +08:00
let numbsctring = result . numbers
? ",<br> " + ( result . punctuation ? "&" : "" ) + "with numbers"
: "" ;
2020-05-10 09:04:05 +08:00
topWpm = result . wpm ;
2020-09-03 17:19:53 +08:00
topMode = result . mode + " " + result . mode2 + puncsctring + numbsctring ;
2020-05-10 09:04:05 +08:00
}
2020-05-20 03:27:08 +08:00
totalWpm += result . wpm ;
2020-07-03 08:35:45 +08:00
} ) ;
2020-05-30 07:21:39 +08:00
loadMoreLines ( ) ;
2020-05-20 07:11:57 +08:00
////////
2020-09-10 03:10:25 +08:00
let thisDate = new Date ( Date . now ( ) ) ;
thisDate . setSeconds ( 0 ) ;
thisDate . setMinutes ( 0 ) ;
thisDate . setHours ( 0 ) ;
thisDate . setMilliseconds ( 0 ) ;
thisDate = thisDate . getTime ( ) ;
2020-10-09 23:40:55 +08:00
let activityChartData _amount = [ ] ;
let activityChartData _avgWpm = [ ] ;
2020-09-10 03:10:25 +08:00
let lastTimestamp = 0 ;
2020-09-17 00:29:39 +08:00
Object . keys ( activityChartData ) . forEach ( ( date ) => {
2020-09-10 03:10:25 +08:00
let datecheck ;
if ( lastTimestamp > 0 ) {
datecheck = lastTimestamp ;
} else {
2020-09-17 00:29:39 +08:00
datecheck = thisDate ;
2020-09-10 03:10:25 +08:00
}
2020-09-17 00:29:39 +08:00
2020-09-10 03:10:25 +08:00
let numDaysBetweenTheDays = ( datecheck - date ) / 86400000 ;
if ( numDaysBetweenTheDays > 1 ) {
if ( datecheck === thisDate ) {
2020-10-09 23:40:55 +08:00
activityChartData _amount . push ( {
2020-09-10 07:13:05 +08:00
x : parseInt ( thisDate ) ,
2020-09-17 00:29:39 +08:00
y : 0 ,
} ) ;
2020-09-10 03:10:25 +08:00
}
2020-09-17 00:29:39 +08:00
for ( let i = 0 ; i < numDaysBetweenTheDays - 1 ; i ++ ) {
2020-10-09 23:40:55 +08:00
activityChartData _amount . push ( {
2020-09-17 00:29:39 +08:00
x : parseInt ( datecheck ) - 86400000 * ( i + 1 ) ,
y : 0 ,
} ) ;
2020-09-10 03:10:25 +08:00
}
}
2020-10-09 23:40:55 +08:00
activityChartData _amount . push ( {
2020-09-10 07:13:05 +08:00
x : parseInt ( date ) ,
2020-10-09 23:40:55 +08:00
y : activityChartData [ date ] . amount ,
} ) ;
activityChartData _avgWpm . push ( {
2020-09-10 07:13:05 +08:00
x : parseInt ( date ) ,
2020-10-27 04:28:25 +08:00
y : roundTo2 (
activityChartData [ date ] . totalWpm / activityChartData [ date ] . amount
) ,
2020-09-17 00:29:39 +08:00
} ) ;
2020-09-10 03:10:25 +08:00
lastTimestamp = date ;
2020-09-17 00:29:39 +08:00
} ) ;
2020-09-10 03:10:25 +08:00
// console.log(activityChartData);
activityChart . options . scales . xAxes [ 0 ] . ticks . minor . fontColor =
themeColors . sub ;
activityChart . options . scales . yAxes [ 0 ] . ticks . minor . fontColor =
themeColors . sub ;
activityChart . options . scales . yAxes [ 0 ] . scaleLabel . fontColor =
themeColors . sub ;
activityChart . data . datasets [ 0 ] . borderColor = themeColors . main ;
activityChart . data . datasets [ 0 ] . backgroundColor = themeColors . main ;
activityChart . options . legend . labels . fontColor = themeColors . sub ;
activityChart . data . datasets [ 0 ] . trendlineLinear . style = themeColors . sub ;
2020-10-09 23:40:55 +08:00
activityChart . data . datasets [ 0 ] . data = activityChartData _amount ;
activityChart . options . scales . yAxes [ 1 ] . ticks . minor . fontColor =
2020-10-27 04:28:25 +08:00
themeColors . sub ;
2020-10-09 23:40:55 +08:00
activityChart . options . scales . yAxes [ 1 ] . scaleLabel . fontColor =
themeColors . sub ;
activityChart . data . datasets [ 1 ] . borderColor = themeColors . sub ;
// activityChart.data.datasets[1].backgroundColor = themeColors.main;
activityChart . data . datasets [ 1 ] . data = activityChartData _avgWpm ;
activityChart . options . legend . labels . fontColor = themeColors . sub ;
2020-09-10 03:10:25 +08:00
2020-07-31 02:48:57 +08:00
resultHistoryChart . options . scales . xAxes [ 0 ] . ticks . minor . fontColor =
themeColors . sub ;
resultHistoryChart . options . scales . yAxes [ 0 ] . ticks . minor . fontColor =
themeColors . sub ;
2020-09-06 22:17:26 +08:00
resultHistoryChart . options . scales . yAxes [ 0 ] . scaleLabel . fontColor =
themeColors . sub ;
2020-09-17 00:29:39 +08:00
resultHistoryChart . options . scales . yAxes [ 1 ] . ticks . minor . fontColor =
2020-09-06 22:17:26 +08:00
themeColors . sub ;
resultHistoryChart . options . scales . yAxes [ 1 ] . scaleLabel . fontColor =
themeColors . sub ;
2020-07-31 02:48:57 +08:00
resultHistoryChart . data . datasets [ 0 ] . borderColor = themeColors . main ;
2020-09-06 22:17:26 +08:00
resultHistoryChart . data . datasets [ 1 ] . borderColor = themeColors . sub ;
2020-07-31 02:48:57 +08:00
resultHistoryChart . options . legend . labels . fontColor = themeColors . sub ;
resultHistoryChart . data . datasets [ 0 ] . trendlineLinear . style = themeColors . sub ;
2020-05-12 07:59:12 +08:00
2020-05-20 07:11:57 +08:00
resultHistoryChart . data . datasets [ 0 ] . data = chartData ;
2020-09-06 22:17:26 +08:00
resultHistoryChart . data . datasets [ 1 ] . data = accChartData ;
2020-09-12 08:27:14 +08:00
let wpms = chartData . map ( ( r ) => r . y ) ;
2020-09-27 06:10:21 +08:00
let minWpmChartVal = Math . min ( ... wpms ) ;
let maxWpmChartVal = Math . max ( ... wpms ) ;
let accuracies = accChartData . map ( ( r ) => r . y ) ;
let minAccuracyChartVal = Math . min ( ... accuracies ) ;
let maxAccuracyChartVal = Math . max ( ... accuracies ) ;
2020-09-12 08:27:14 +08:00
2020-09-17 00:29:39 +08:00
resultHistoryChart . options . scales . yAxes [ 0 ] . ticks . max =
2020-09-27 06:10:21 +08:00
Math . floor ( maxWpmChartVal ) + ( 10 - ( Math . floor ( maxWpmChartVal ) % 10 ) ) ;
resultHistoryChart . options . scales . yAxes [ 1 ] . ticks . max = Math . ceil (
maxAccuracyChartVal
) ;
2020-09-12 08:27:14 +08:00
2020-09-09 22:56:30 +08:00
if ( ! config . startGraphsAtZero ) {
2020-09-17 00:29:39 +08:00
resultHistoryChart . options . scales . yAxes [ 0 ] . ticks . min = Math . floor (
2020-09-27 06:10:21 +08:00
minWpmChartVal
2020-09-17 00:29:39 +08:00
) ;
resultHistoryChart . options . scales . yAxes [ 1 ] . ticks . min = Math . floor (
2020-09-27 06:10:21 +08:00
minAccuracyChartVal
2020-09-17 00:29:39 +08:00
) ;
2020-10-09 22:58:04 +08:00
} else {
resultHistoryChart . options . scales . yAxes [ 0 ] . ticks . min = 0 ;
resultHistoryChart . options . scales . yAxes [ 1 ] . ticks . min = 0 ;
2020-09-09 22:56:30 +08:00
}
2020-07-03 08:35:45 +08:00
if ( chartData == [ ] || chartData . length == 0 ) {
$ ( ".pageAccount .group.noDataError" ) . removeClass ( "hidden" ) ;
$ ( ".pageAccount .group.chart" ) . addClass ( "hidden" ) ;
2020-09-10 03:10:25 +08:00
$ ( ".pageAccount .group.dailyActivityChart" ) . addClass ( "hidden" ) ;
2020-07-03 08:35:45 +08:00
$ ( ".pageAccount .group.history" ) . addClass ( "hidden" ) ;
$ ( ".pageAccount .triplegroup.stats" ) . addClass ( "hidden" ) ;
} else {
$ ( ".pageAccount .group.noDataError" ) . addClass ( "hidden" ) ;
$ ( ".pageAccount .group.chart" ) . removeClass ( "hidden" ) ;
2020-09-10 03:10:25 +08:00
$ ( ".pageAccount .group.dailyActivityChart" ) . removeClass ( "hidden" ) ;
2020-07-03 08:35:45 +08:00
$ ( ".pageAccount .group.history" ) . removeClass ( "hidden" ) ;
$ ( ".pageAccount .triplegroup.stats" ) . removeClass ( "hidden" ) ;
2020-05-27 00:51:48 +08:00
}
2020-07-31 09:25:49 +08:00
// moment
// .utc(moment.duration(totalSeconds, "seconds").asMilliseconds())
// .format("HH:mm:ss")
2020-07-31 09:28:51 +08:00
let th = Math . floor ( totalSeconds / 3600 ) ;
let tm = Math . floor ( ( totalSeconds % 3600 ) / 60 ) ;
let ts = Math . floor ( ( totalSeconds % 3600 ) % 60 ) ;
2020-07-31 09:25:49 +08:00
$ ( ".pageAccount .timeTotal .val" ) . text ( `
2020-07-31 09:28:51 +08:00
$ { th < 10 ? "0" + th : th } : $ { tm < 10 ? "0" + tm : tm } : $ {
ts < 10 ? "0" + ts : ts
}
2020-07-31 09:25:49 +08:00
` );
//moment
// .utc(moment.duration(totalSecondsFiltered, "seconds").asMilliseconds())
// .format("HH:mm:ss")
2020-07-31 09:28:51 +08:00
let tfh = Math . floor ( totalSecondsFiltered / 3600 ) ;
let tfm = Math . floor ( ( totalSecondsFiltered % 3600 ) / 60 ) ;
let tfs = Math . floor ( ( totalSecondsFiltered % 3600 ) % 60 ) ;
2020-07-31 09:25:49 +08:00
$ ( ".pageAccount .timeTotalFiltered .val" ) . text ( `
2020-07-31 09:28:51 +08:00
$ { tfh < 10 ? "0" + tfh : tfh } : $ { tfm < 10 ? "0" + tfm : tfm } : $ {
tfs < 10 ? "0" + tfs : tfs
}
2020-07-31 09:25:49 +08:00
` );
2020-05-30 07:21:39 +08:00
2020-05-10 09:04:05 +08:00
$ ( ".pageAccount .highestWpm .val" ) . text ( topWpm ) ;
2020-07-03 08:35:45 +08:00
$ ( ".pageAccount .averageWpm .val" ) . text ( Math . round ( totalWpm / testCount ) ) ;
$ ( ".pageAccount .averageWpm10 .val" ) . text (
Math . round ( wpmLast10total / last10 )
) ;
2020-05-30 05:37:52 +08:00
$ ( ".pageAccount .highestRaw .val" ) . text ( rawWpm . max ) ;
2020-07-03 08:35:45 +08:00
$ ( ".pageAccount .averageRaw .val" ) . text (
Math . round ( rawWpm . total / rawWpm . count )
) ;
$ ( ".pageAccount .averageRaw10 .val" ) . text (
Math . round ( rawWpm . last10Total / rawWpm . last10Count )
) ;
2020-05-30 05:37:52 +08:00
2020-05-11 07:07:36 +08:00
$ ( ".pageAccount .highestWpm .mode" ) . html ( topMode ) ;
2020-05-10 09:04:05 +08:00
$ ( ".pageAccount .testsTaken .val" ) . text ( testCount ) ;
2020-07-03 08:35:45 +08:00
$ ( ".pageAccount .avgAcc .val" ) . text ( Math . round ( totalAcc / testCount ) + "%" ) ;
$ ( ".pageAccount .avgAcc10 .val" ) . text (
Math . round ( totalAcc10 / last10 ) + "%"
2020-05-20 07:11:57 +08:00
) ;
2020-07-31 07:31:07 +08:00
// console.log(totalCons10);
// console.log(last10);
2020-07-31 06:03:47 +08:00
if ( totalCons == 0 || totalCons == undefined ) {
$ ( ".pageAccount .avgCons .val" ) . text ( "-" ) ;
$ ( ".pageAccount .avgCons10 .val" ) . text ( "-" ) ;
} else {
$ ( ".pageAccount .avgCons .val" ) . text (
Math . round ( totalCons / consCount ) + "%"
) ;
$ ( ".pageAccount .avgCons10 .val" ) . text (
Math . round ( totalCons10 / Math . min ( last10 , consCount ) ) + "%"
) ;
}
2020-07-03 08:35:45 +08:00
$ ( ".pageAccount .testsStarted .val" ) . text ( ` ${ testCount + testRestarts } ` ) ;
2020-05-20 07:11:57 +08:00
$ ( ".pageAccount .testsCompleted .val" ) . text (
2020-07-03 08:35:45 +08:00
` ${ testCount } ( ${ Math . floor (
( testCount / ( testCount + testRestarts ) ) * 100
) } % ) `
2020-05-17 20:17:08 +08:00
) ;
$ ( ".pageAccount .avgRestart .val" ) . text (
2020-07-03 08:35:45 +08:00
( testRestarts / testCount ) . toFixed ( 1 )
2020-05-17 20:17:08 +08:00
) ;
2020-05-20 07:11:57 +08:00
// if(testCount == 0){
// $('.pageAccount .group.chart').fadeOut(125);
// $('.pageAccount .triplegroup.stats').fadeOut(125);
// $('.pageAccount .group.history').fadeOut(125);
// }else{
// $('.pageAccount .group.chart').fadeIn(125);
// $('.pageAccount .triplegroup.stats').fadeIn(125);
// $('.pageAccount .group.history').fadeIn(125);
// }
// let favMode = testModes.words10;
// let favModeName = 'words10';
// $.each(testModes, (key, mode) => {
// if (mode.length > favMode.length) {
// favMode = mode;
// favModeName = key;
// }
// })
// if (favModeName == 'words10' && testModes.words10.length == 0) {
2020-07-03 08:35:45 +08:00
// //new user
2020-05-20 07:11:57 +08:00
// $(".pageAccount .favouriteTest .val").text(`-`);
// } else {
// $(".pageAccount .favouriteTest .val").text(`${favModeName} (${Math.floor((favMode.length/testCount) * 100)}%)`);
// }
2020-05-10 09:04:05 +08:00
2020-09-10 07:13:05 +08:00
if ( resultHistoryChart . data . datasets [ 0 ] . data . length > 0 ) {
2020-05-27 00:51:48 +08:00
resultHistoryChart . options . plugins . trendlineLinear = true ;
2020-07-03 08:35:45 +08:00
} else {
2020-05-27 00:51:48 +08:00
resultHistoryChart . options . plugins . trendlineLinear = false ;
}
2020-07-03 08:35:45 +08:00
2020-09-10 07:13:05 +08:00
if ( activityChart . data . datasets [ 0 ] . data . length > 0 ) {
activityChart . options . plugins . trendlineLinear = true ;
} else {
activityChart . options . plugins . trendlineLinear = false ;
}
2020-08-09 22:40:52 +08:00
let wpmPoints = filteredResults . map ( ( r ) => r . wpm ) . reverse ( ) ;
let trend = findLineByLeastSquares ( wpmPoints ) ;
2020-08-14 04:51:23 +08:00
let wpmChange = trend [ 1 ] [ 1 ] - trend [ 0 ] [ 1 ] ;
let wpmChangePerHour = wpmChange * ( 3600 / totalSecondsFiltered ) ;
// let slope = calculateSlope(trend);
let plus = wpmChangePerHour > 0 ? "+" : "" ;
2020-08-09 22:40:52 +08:00
2020-10-20 23:31:43 +08:00
$ ( ".pageAccount .group.chart .below .text" ) . text (
2020-08-14 04:51:23 +08:00
` Speed change per hour spent typing: ${
plus + roundTo2 ( wpmChangePerHour )
} wpm . `
2020-08-09 22:40:52 +08:00
) ;
2020-07-03 08:35:45 +08:00
resultHistoryChart . update ( { duration : 0 } ) ;
2020-09-10 03:10:25 +08:00
activityChart . update ( { duration : 0 } ) ;
2020-05-12 07:59:12 +08:00
swapElements ( $ ( ".pageAccount .preloader" ) , $ ( ".pageAccount .content" ) , 250 ) ;
}
2020-10-07 00:10:24 +08:00
if ( dbSnapshot === null ) {
showNotification ( ` Missing account data. Please refresh. ` , 5000 ) ;
2020-10-27 04:28:25 +08:00
$ ( ".pageAccount .preloader" ) . html ( "Missing account data. Please refresh." ) ;
} else if ( dbSnapshot . results === undefined ) {
2020-08-19 05:56:21 +08:00
db _getUserResults ( ) . then ( ( d ) => {
if ( d ) {
2020-08-19 06:19:40 +08:00
// cont();
showActiveFilters ( ) ;
2020-08-19 05:56:21 +08:00
} else {
2020-08-24 23:37:26 +08:00
setTimeout ( ( f ) => {
changePage ( "" ) ;
} , 500 ) ;
// console.log("something went wrong");
2020-08-19 05:56:21 +08:00
}
} ) ;
2020-05-12 07:59:12 +08:00
} else {
2020-08-19 05:56:21 +08:00
console . log ( "using db snap" ) ;
2020-10-07 00:10:24 +08:00
try {
cont ( ) ;
} catch ( e ) {
2020-10-09 23:40:55 +08:00
console . error ( e ) ;
2020-10-07 00:10:24 +08:00
showNotification ( ` Something went wrong: ${ e } ` , 5000 ) ;
}
2020-05-12 07:59:12 +08:00
}
2020-05-20 07:11:57 +08:00
}
2020-06-24 07:55:15 +08:00
2020-07-03 08:35:45 +08:00
function showResultEditTagsPanel ( ) {
2020-06-24 07:55:15 +08:00
if ( $ ( "#resultEditTagsPanelWrapper" ) . hasClass ( "hidden" ) ) {
$ ( "#resultEditTagsPanelWrapper" )
2020-07-03 08:35:45 +08:00
. stop ( true , true )
. css ( "opacity" , 0 )
. removeClass ( "hidden" )
. animate ( { opacity : 1 } , 125 ) ;
2020-06-24 07:55:15 +08:00
}
}
2020-07-03 08:35:45 +08:00
function hideResultEditTagsPanel ( ) {
2020-06-24 07:55:15 +08:00
if ( ! $ ( "#resultEditTagsPanelWrapper" ) . hasClass ( "hidden" ) ) {
$ ( "#resultEditTagsPanelWrapper" )
2020-07-03 08:35:45 +08:00
. stop ( true , true )
. css ( "opacity" , 1 )
. animate (
2020-06-24 07:55:15 +08:00
{
2020-07-03 08:35:45 +08:00
opacity : 0 ,
} ,
100 ,
( e ) => {
$ ( "#resultEditTagsPanelWrapper" ) . addClass ( "hidden" ) ;
}
) ;
}
2020-06-24 07:55:15 +08:00
}
2020-09-16 04:12:42 +08:00
$ ( ".pageAccount .toggleAccuracyOnChart" ) . click ( ( params ) => {
toggleChartAccuracy ( ) ;
2020-09-17 00:29:39 +08:00
} ) ;
2020-09-16 04:12:42 +08:00
2020-10-20 11:09:12 +08:00
$ ( ".pageAccount .toggleChartStyle" ) . click ( ( params ) => {
toggleChartStyle ( ) ;
} ) ;
2020-07-03 08:35:45 +08:00
$ ( document ) . on ( "click" , ".pageAccount .group.history #resultEditTags" , ( f ) => {
if ( dbSnapshot . tags . length > 0 ) {
let resultid = $ ( f . target ) . parents ( "span" ) . attr ( "resultid" ) ;
let tags = $ ( f . target ) . parents ( "span" ) . attr ( "tags" ) ;
$ ( "#resultEditTagsPanel" ) . attr ( "resultid" , resultid ) ;
$ ( "#resultEditTagsPanel" ) . attr ( "tags" , tags ) ;
2020-06-25 04:19:14 +08:00
updateActiveResultEditTagsPanelButtons ( JSON . parse ( tags ) ) ;
showResultEditTagsPanel ( ) ;
}
2020-07-03 08:35:45 +08:00
} ) ;
2020-06-24 07:55:15 +08:00
2020-07-03 08:35:45 +08:00
$ ( document ) . on ( "click" , "#resultEditTagsPanelWrapper .button.tag" , ( f ) => {
$ ( f . target ) . toggleClass ( "active" ) ;
} ) ;
2020-06-24 07:55:15 +08:00
2020-07-03 08:35:45 +08:00
$ ( "#resultEditTagsPanelWrapper" ) . click ( ( e ) => {
if ( $ ( e . target ) . attr ( "id" ) === "resultEditTagsPanelWrapper" ) {
2020-06-24 07:55:15 +08:00
hideResultEditTagsPanel ( ) ;
}
2020-07-03 08:35:45 +08:00
} ) ;
2020-06-24 07:55:15 +08:00
2020-07-03 08:35:45 +08:00
function updateResultEditTagsPanelButtons ( ) {
2020-06-24 07:55:15 +08:00
$ ( "#resultEditTagsPanel .buttons" ) . empty ( ) ;
2020-07-03 08:35:45 +08:00
dbSnapshot . tags . forEach ( ( tag ) => {
$ ( "#resultEditTagsPanel .buttons" ) . append (
` <div class="button tag" tagid=" ${ tag . id } "> ${ tag . name } </div> `
) ;
} ) ;
2020-06-24 07:55:15 +08:00
}
2020-07-03 08:35:45 +08:00
function updateActiveResultEditTagsPanelButtons ( active ) {
if ( active === [ ] ) return ;
$ . each ( $ ( "#resultEditTagsPanel .buttons .button" ) , ( index , obj ) => {
let tagid = $ ( obj ) . attr ( "tagid" ) ;
if ( active . includes ( tagid ) ) {
$ ( obj ) . addClass ( "active" ) ;
} else {
$ ( obj ) . removeClass ( "active" ) ;
2020-06-24 07:55:15 +08:00
}
// active.forEach(activetagid => {
// if(activetagid === tagid){
// $(obj).addClass('active');
// }else{
// $(obj).removeClass('active');
// }
// })
} ) ;
}
2020-07-03 08:35:45 +08:00
$ ( "#resultEditTagsPanel .confirmButton" ) . click ( ( f ) => {
let resultid = $ ( "#resultEditTagsPanel" ) . attr ( "resultid" ) ;
let oldtags = JSON . parse ( $ ( "#resultEditTagsPanel" ) . attr ( "tags" ) ) ;
2020-06-24 07:55:15 +08:00
let newtags = [ ] ;
2020-07-03 08:35:45 +08:00
$ . each ( $ ( "#resultEditTagsPanel .buttons .button" ) , ( index , obj ) => {
let tagid = $ ( obj ) . attr ( "tagid" ) ;
if ( $ ( obj ) . hasClass ( "active" ) ) {
2020-06-24 07:55:15 +08:00
newtags . push ( tagid ) ;
}
} ) ;
showBackgroundLoader ( ) ;
hideResultEditTagsPanel ( ) ;
2020-07-03 08:35:45 +08:00
updateResultTags ( {
uid : firebase . auth ( ) . currentUser . uid ,
tags : newtags ,
resultid : resultid ,
} ) . then ( ( r ) => {
2020-06-24 07:55:15 +08:00
hideBackgroundLoader ( ) ;
2020-07-03 08:35:45 +08:00
if ( r . data . resultCode === 1 ) {
2020-09-01 02:48:29 +08:00
showNotification ( "Tags updated." , 3000 ) ;
2020-07-03 08:35:45 +08:00
dbSnapshot . results . forEach ( ( result ) => {
if ( result . id === resultid ) {
2020-06-24 07:55:15 +08:00
result . tags = newtags ;
}
2020-07-03 08:35:45 +08:00
} ) ;
2020-09-01 02:48:29 +08:00
let tagNames = "" ;
if ( newtags . length > 0 ) {
newtags . forEach ( ( tag ) => {
dbSnapshot . tags . forEach ( ( snaptag ) => {
if ( tag === snaptag . id ) {
tagNames += snaptag . name + ", " ;
}
} ) ;
} ) ;
tagNames = tagNames . substring ( 0 , tagNames . length - 2 ) ;
}
let restags ;
if ( newtags === undefined ) {
restags = "[]" ;
} else {
restags = JSON . stringify ( newtags ) ;
}
$ ( ` .pageAccount #resultEditTags[resultid=' ${ resultid } '] ` ) . attr (
"tags" ,
restags
) ;
if ( newtags . length > 0 ) {
$ ( ` .pageAccount #resultEditTags[resultid=' ${ resultid } '] ` ) . css (
"opacity" ,
1
) ;
$ ( ` .pageAccount #resultEditTags[resultid=' ${ resultid } '] ` ) . attr (
"aria-label" ,
tagNames
) ;
} else {
$ ( ` .pageAccount #resultEditTags[resultid=' ${ resultid } '] ` ) . css (
"opacity" ,
0.25
) ;
$ ( ` .pageAccount #resultEditTags[resultid=' ${ resultid } '] ` ) . attr (
"aria-label" ,
"no tags"
) ;
}
2020-09-01 02:32:56 +08:00
// refreshAccountPage();
2020-07-03 08:35:45 +08:00
} else {
showNotification ( "Error updating tags" , 3000 ) ;
2020-06-24 07:55:15 +08:00
}
} ) ;
2020-07-03 08:35:45 +08:00
} ) ;
2020-09-17 06:15:55 +08:00
function updateLbMemory ( mode , mode2 , type , value ) {
dbSnapshot . lbMemory [ mode + mode2 ] [ type ] = value ;
}