From 0fafcaa4936b794885d5711cb1b6edbdaa44baa6 Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 28 Feb 2023 12:34:50 +0100 Subject: [PATCH 01/40] reports --- frontend/static/quotes/english.json | 68 +++-------------------------- 1 file changed, 6 insertions(+), 62 deletions(-) diff --git a/frontend/static/quotes/english.json b/frontend/static/quotes/english.json index 77695eb26..98f106d7f 100644 --- a/frontend/static/quotes/english.json +++ b/frontend/static/quotes/english.json @@ -1399,12 +1399,6 @@ "id": 236, "length": 286 }, - { - "text": "I think if you don't really like a girl, you shouldn't horse around with her at all, and if you do like her, then you're supposed to like her face, and if you like her face, you ought to be careful about doing crumby stuff to it, like squirting water all over it. It's really too bad that so much crumby stuff is a lot of fun sometimes.", - "source": "The Catcher in the Rye", - "id": 237, - "length": 336 - }, { "text": "And now it's time for Silly Songs with Larry, the part of the show where Larry comes out and sings a silly song.", "source": "VeggieTales", @@ -2623,12 +2617,6 @@ "id": 440, "length": 179 }, - { - "text": "But what leaves us out of breath the most isn't the moments spent on a bed too small for two but the expense of our hearts by the labor of our bodies. I guess that two float around the point. But I wanna say it's more than just those moments, at least more than the surface. It's the tempo within those seconds where time seems to slow to a crawl and I can't help but fall into the rhythm of your skin and your shaking breath and I sink into the warmest dreams and the softest skin.", - "source": "Twin Sized Sheets", - "id": 441, - "length": 482 - }, { "text": "I'm not very good at this, out, being in public. But I felt the need to speak up for this city that I love with all my heart. No one should have to live in fear, in fear of madmen who have no regard for who they injure.", "source": "Daredevil", @@ -11402,7 +11390,7 @@ "length": 252 }, { - "text": "I had a job, I had a girl. I had something going, mister, in this world. I got laid off down at the lumber yard, our love went bad, times got hard. Now I work down at the carwash, where all it ever does is rain. Don't you feel like you're a rider on a downbound train.", + "text": "I had a job, I had a girl. I had something going, mister, in this world. I got laid off down at the lumber yard, our love went bad, times got hard. Now I work down at the carwash, where all it ever does is rain. Don't you feel like you're a rider on a downbound train?", "source": "Downbound Train", "id": 1950, "length": 268 @@ -13167,7 +13155,7 @@ }, { "text": "Most test subjects do experience some, uh, cognitive deterioration after a few months in suspension. Now, you've been under for... quite a bit longer, and it's not out of the question that you might have a very minor case of serious brain damage. But don't be alarmed, all right? Although, if you do feel alarmed, try to hold onto that feeling, because that is the proper reaction to being told you have brain damage.", - "source": "Portal 2", + "source": "Wheatley, Portal 2", "id": 2253, "length": 417 }, @@ -15489,7 +15477,7 @@ }, { "text": "Every moment there are a million miracles happening around you: a flower blossoming, a bird tweeting, a bee humming, a raindrop falling, a snowflake wafting along the clear evening air. There is magic everywhere. If you learn how to live it, life is nothing short of a daily miracle.", - "source": "Inner Engineering: A Yogi’s Guide to Joy", + "source": "Inner Engineering: A Yogi's Guide to Joy", "id": 2661, "length": 283 }, @@ -23761,12 +23749,6 @@ "id": 4089, "length": 420 }, - { - "text": "There is a difference between the Holy Spirit coming and residing within us and us receiving the clothing with power that Jesus spoke of - the baptism of the Holy Spirit.", - "source": "The Bourne Identity", - "id": 4090, - "length": 170 - }, { "text": "There is no physical separation after the slicing, so that edge can be ignored and we can treat the pizza, for thermal purposes, as an infinite plane. The procedure reduces the heat-transfer problem to one dimension represented by a vector normal to the pizza surface.", "source": "The Thermodynamics of Pizza", @@ -27331,12 +27313,6 @@ "id": 4711, "length": 76 }, - { - "text": "This was the story of Howard Beale: the first known instance of a man who was killed because he had lousy ratings.", - "source": "Network", - "id": 4712, - "length": 114 - }, { "text": "Corn is what feeds the steer that becomes the steak. Corn feeds the chicken and the pig, the turkey and the lamb, the catfish and the tilapia and, increasingly, even the salmon, a carnivore by nature that the fish farmers are reengineering to tolerate corn. The eggs are made of corn. The milk and cheese and yogurt, which once came from dairy cows that grazed on grass, now typically come from cows that spend their working lives indoors tethered to machines, eating corn.", "source": "The Omnivore's Dilemma: A Natural History of Four Meals", @@ -27433,12 +27409,6 @@ "id": 4728, "length": 465 }, - { - "text": "But I will tell you this. I'd use tonight to get myself organized. Ride out in the morning clear-headed. And startin' tomorrow morning, I will offer a personal $50 bounty for every decapitated head of as many of these godless heathens as anyone can bring in.", - "source": "Deadwood", - "id": 4729, - "length": 258 - }, { "text": "By venturing too close to the dragon's flame, you made an ash out of yourself.", "source": "King's Quest I", @@ -31111,12 +31081,6 @@ "length": 494, "id": 5382 }, - { - "text": "Crying is for little girls, babies, and men who just had their ears ripped off.", - "source": "Oobeedoob Benubi, Thumb Wars", - "length": 79, - "id": 5383 - }, { "text": "I can't stand the thought of looking at you someday, this face I love, and not knowing who you are.", "source": "Lisa Genova, Still Alice", @@ -32143,12 +32107,6 @@ "length": 302, "id": 5599 }, - { - "text": "Only once in your life, I truly believe, you find someone who can completely turn your world around. You tell them things that you've never shared with another soul and they absorb everything you say and actually want to hear more. You share hopes for the future, dreams that will never come true, goals that were never achieved and the many disappointments life has thrown at you. When something wonderful happens, you can't wait to tell them about it, knowing they will share in your excitement. They are not embarrassed to cry with you when you are hurting or laugh with you when you make a fool of yourself. Never do they hurt your feelings or make you feel like you are not good enough, but rather they build you up and show you the things about yourself that make you special and even beautiful. There is never any pressure, jealousy or competition but only a quiet calmness when they are around. You can be yourself and not worry about what they will think of you because they love you for who you are. The things that seem insignificant to most people such as a note, song or walk become invaluable treasures kept safe in your heart to cherish forever. Memories of your childhood come back and are so clear and vivid it's like being young again. Colours seem brighter and more brilliant. Laughter seems part of daily life where before it was infrequent or didn't exist at all. A phone call or two during the day helps to get you through a long day's work and always brings a smile to your face. In their presence, there's no need for continuous conversation, but you find you're quite content in just having them nearby. Things that never interested you before become fascinating because you know they are important to this person who is so special to you. You think of this person on every occasion and in everything you do. Simple things bring them to mind like a pale blue sky, gentle wind or even a storm cloud on the horizon. You open your heart knowing that there's a chance it may be broken one day and in opening your heart, you experience a love and joy that you never dreamed possible. You find that being vulnerable is the only way to allow your heart to feel true pleasure that's so real it scares you. You find strength in knowing you have a true friend and possibly a soul mate who will remain loyal to the end. Life seems completely different, exciting and worthwhile. Your only hope and security is in knowing that they are a part of your life.", - "source": "Bob Marley", - "length": 2468, - "id": 5600 - }, { "text": "All that is gold does not glitter, not all those who wander are lost; the old that is strong does not wither, deep roots are not reached by the frost. From the ashes a fire shall be woken, a light from the shadows shall spring; renewed shall be blade that was broken, the crownless again shall be king.", "source": "J.R.R. Tolkien, The Fellowship of the Ring", @@ -32774,7 +32732,7 @@ "id": 5715 }, { - "text": "Christie! Ms. Esposito! Hold up. Hey, Jimmy McGill, we met inside. Hi. You didn't get it. You were never gonna get it. They dangle these things in front of you. They tell you, you got a chance, but I'm sorry. It's a lie because they had already made up their mind and they knew what they were going to do before you walked in the door. You made a mistake and they are never forgetting it. As far as they're concerned, your mistake is just, it's who you are. And it's all you are. And I'm not just talking about the scholarship here, I'm talking about everything. I mean, they'll smile at you, they'll pat you on the head, but they are never, ever letting you in. But listen... Listen... it doesn't matter. It doesn't because you don't need them. They're not going to give it to you? So what? You're going to take it. You're going to do whatever it takes. Do you hear me? You are not going to play by the rules. You're going to go your own way. You're going to do what they won't do. You're going to be smart. You are going to cut corners and you are going to win. They're on the 35th floor? You're going to be on the 50th floor. You're going to be looking down on them. And the higher you rise, the more they're going to hate you. Good. Good! You rub their noses in it. You make them suffer. Because you don't matter all that much to them. So what? So what? Screw them! Remember... the winner takes it all. You understand what I'm trying to tell you, right? All right. All right. Go get them.", + "text": "Kristy! Ms. Esposito! Hold up. Hey, Jimmy McGill, we met inside. Hi. You didn't get it. You were never gonna get it. They dangle these things in front of you. They tell you, you got a chance, but I'm sorry. It's a lie because they had already made up their mind and they knew what they were going to do before you walked in the door. You made a mistake and they are never forgetting it. As far as they're concerned, your mistake is just, it's who you are. And it's all you are. And I'm not just talking about the scholarship here, I'm talking about everything. I mean, they'll smile at you, they'll pat you on the head, but they are never, ever letting you in. But listen. Listen. it doesn't matter. It doesn't because you don't need them. They're not going to give it to you? So what? You're going to take it. You're going to do whatever it takes. Do you hear me? You are not going to play by the rules. You're going to go your own way. You're going to do what they won't do. You're going to be smart. You are going to cut corners and you are going to win. They're on the 35th floor? You're going to be on the 50th floor. You're going to be looking down on them. And the higher you rise, the more they're going to hate you. Good. Good! You rub their noses in it. You make them suffer. Because you don't matter all that much to them. So what? So what? Screw them! Remember... the winner takes it all. You understand what I'm trying to tell you, right? All right. All right. Go get them.", "source": "Better Call Saul", "length": 1492, "id": 5716 @@ -35973,7 +35931,7 @@ "id": 6359 }, { - "text": "I'd rather have loyalty than love, 'cause love really don't mean jack. See, love is just a feeling - you can love somebody and talk behind their back. It don't take much to love, you can love somebody just by being attached. See, loyalty is a action, you can love or hate me and still have my back.", + "text": "I'd rather have loyalty than love, 'cause love really don't mean jack. See, love is just a feeling - you can love somebody and talk behind their back. It don't take much to love, you can love somebody just by being attached. See, loyalty is an action, you can love or hate me and still have my back.", "source": "21 Savage, Ball w/o You", "length": 298, "approvedBy": "Smithster", @@ -37856,7 +37814,7 @@ "id": 6636 }, { - "text": "Don't leave, it's my fault. Cause' when it all comes crashing down I'll need you.", + "text": "Don't leave, it's my fault. 'Cause when it all comes crashing down I'll need you.", "source": "EARFQUAKE, Tyler, the Creator", "length": 81, "approvedBy": "Smithster", @@ -37939,13 +37897,6 @@ "approvedBy": "Smithster", "id": 6648 }, - { - "text": "When you reach the end of your rope, tie a knot in it and hang on.", - "source": "Franklin D. Roosevelt", - "length": 66, - "approvedBy": "Smithster", - "id": 6649 - }, { "text": "Always remember that you are absolutely unique. Just like everyone else.", "source": "Margaret Mead", @@ -38065,13 +38016,6 @@ "approvedBy": "Smithster", "id": 6666 }, - { - "text": "Only poetry could best fit into the vast emptiness created by men.", - "source": "Manning Marable", - "length": 66, - "approvedBy": "Smithster", - "id": 6667 - }, { "text": "A hot desert storm eddied around him and rushed to me, making my skin contract, and my pores slam shut... His hair was the color of burning embers and his eyes pierced.", "source": "Maya Angelou", From e2ef89bc7e10575cc8930c7fa0161451bf2a3c8e Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 28 Feb 2023 12:35:00 +0100 Subject: [PATCH 02/40] quote lengths --- frontend/static/quotes/english.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/static/quotes/english.json b/frontend/static/quotes/english.json index 98f106d7f..b7cd9d00b 100644 --- a/frontend/static/quotes/english.json +++ b/frontend/static/quotes/english.json @@ -32734,7 +32734,7 @@ { "text": "Kristy! Ms. Esposito! Hold up. Hey, Jimmy McGill, we met inside. Hi. You didn't get it. You were never gonna get it. They dangle these things in front of you. They tell you, you got a chance, but I'm sorry. It's a lie because they had already made up their mind and they knew what they were going to do before you walked in the door. You made a mistake and they are never forgetting it. As far as they're concerned, your mistake is just, it's who you are. And it's all you are. And I'm not just talking about the scholarship here, I'm talking about everything. I mean, they'll smile at you, they'll pat you on the head, but they are never, ever letting you in. But listen. Listen. it doesn't matter. It doesn't because you don't need them. They're not going to give it to you? So what? You're going to take it. You're going to do whatever it takes. Do you hear me? You are not going to play by the rules. You're going to go your own way. You're going to do what they won't do. You're going to be smart. You are going to cut corners and you are going to win. They're on the 35th floor? You're going to be on the 50th floor. You're going to be looking down on them. And the higher you rise, the more they're going to hate you. Good. Good! You rub their noses in it. You make them suffer. Because you don't matter all that much to them. So what? So what? Screw them! Remember... the winner takes it all. You understand what I'm trying to tell you, right? All right. All right. Go get them.", "source": "Better Call Saul", - "length": 1492, + "length": 1486, "id": 5716 }, { @@ -35933,7 +35933,7 @@ { "text": "I'd rather have loyalty than love, 'cause love really don't mean jack. See, love is just a feeling - you can love somebody and talk behind their back. It don't take much to love, you can love somebody just by being attached. See, loyalty is an action, you can love or hate me and still have my back.", "source": "21 Savage, Ball w/o You", - "length": 298, + "length": 299, "approvedBy": "Smithster", "id": 6360 }, From 2637094c5cb91dcce25d886269bafce6befbd322 Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 28 Feb 2023 12:51:42 +0100 Subject: [PATCH 03/40] fixed tags always showing as pb --- frontend/src/ts/test/result.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/test/result.ts b/frontend/src/ts/test/result.ts index fc983aae2..a15f481e5 100644 --- a/frontend/src/ts/test/result.ts +++ b/frontend/src/ts/test/result.ts @@ -460,7 +460,11 @@ function updateTags(dontSave: boolean): void { $("#result .stats .tags .bottom").append(`
${tag.display}
`); - if (Config.mode != "quote" && !dontSave) { + if ( + Config.mode != "quote" && + !dontSave && + (await Misc.getFunbox(result.funbox ?? ""))?.canGetPb === true + ) { if (tpb < result.wpm) { //new pb for that tag DB.saveLocalTagPB( From f9833ddf3b2a38d2521098cd9deb4d8fb62677f2 Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 28 Feb 2023 13:01:46 +0100 Subject: [PATCH 04/40] fixed all filters button not actually selecting all filters --- frontend/src/ts/account/result-filters.ts | 46 ++++++++++++++++++----- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/frontend/src/ts/account/result-filters.ts b/frontend/src/ts/account/result-filters.ts index 91a5df1ba..356ab40e1 100644 --- a/frontend/src/ts/account/result-filters.ts +++ b/frontend/src/ts/account/result-filters.ts @@ -80,17 +80,41 @@ export async function load(): Promise { console.log("loading filters"); try { const newResultFilters = window.localStorage.getItem("resultFilters"); - if ( - newResultFilters != undefined && - newResultFilters !== "" && - Object.keys(JSON.parse(newResultFilters)).length >= - Object.keys(defaultResultFilters).length - ) { - filters = JSON.parse(newResultFilters); - // save(); - } else { + + if (!newResultFilters) { filters = defaultResultFilters; - // save(); + } else { + const newFiltersObject = JSON.parse(newResultFilters); + + let reset = false; + for (const key of Object.keys(defaultResultFilters)) { + if (reset === true) break; + if (newFiltersObject[key] === undefined) { + reset = true; + break; + } + + if ( + typeof defaultResultFilters[ + key as keyof typeof defaultResultFilters + ] === "object" + ) { + for (const subKey of Object.keys( + defaultResultFilters[key as keyof typeof defaultResultFilters] + )) { + if (newFiltersObject[key][subKey] === undefined) { + reset = true; + break; + } + } + } + } + + if (reset) { + filters = defaultResultFilters; + } else { + filters = newFiltersObject; + } } const newTags: { @@ -532,6 +556,8 @@ $(".pageAccount .topFilters .button.allFilters").on("click", () => { // user is changing the filters -> current filter is no longer a filter preset deSelectFilterPreset(); + console.log(getFilters()); + (Object.keys(getFilters()) as MonkeyTypes.Group[]).forEach((group) => { // id and name field do not correspond to any ui elements, no need to update if (group === "_id" || group === "name") { From 06a1f2354b7b7eac11a2fb62b9d396996e02ea4a Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 28 Feb 2023 18:36:19 +0100 Subject: [PATCH 05/40] fixed tag pbs not working --- frontend/src/ts/test/result.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/ts/test/result.ts b/frontend/src/ts/test/result.ts index a15f481e5..9f90efab7 100644 --- a/frontend/src/ts/test/result.ts +++ b/frontend/src/ts/test/result.ts @@ -417,7 +417,7 @@ export async function updateCrown(): Promise { ); } -function updateTags(dontSave: boolean): void { +async function updateTags(dontSave: boolean): Promise { const activeTags: MonkeyTypes.Tag[] = []; const userTagsCount = DB.getSnapshot()?.tags?.length ?? 0; try { @@ -445,6 +445,14 @@ function updateTags(dontSave: boolean): void { ); $("#result .stats .tags .editTagsButton").addClass("invisible"); + const funboxes = result.funbox?.split("#") ?? []; + + const funboxObjects = await Promise.all( + funboxes.map(async (f) => Misc.getFunbox(f)) + ); + + const allFunboxesCanGetPb = funboxObjects.every((f) => f?.canGetPb); + let annotationSide = "start"; let labelAdjust = 15; activeTags.forEach(async (tag) => { @@ -463,7 +471,7 @@ function updateTags(dontSave: boolean): void { if ( Config.mode != "quote" && !dontSave && - (await Misc.getFunbox(result.funbox ?? ""))?.canGetPb === true + (funboxes.length === 0 || allFunboxesCanGetPb) ) { if (tpb < result.wpm) { //new pb for that tag From 99665509691c4b6025d252c65091044b05b51154 Mon Sep 17 00:00:00 2001 From: trevdev <86077703+trevorwrightdev@users.noreply.github.com> Date: Wed, 1 Mar 2023 01:45:33 -0800 Subject: [PATCH 06/40] Breeze Theme (#4032) trevorwrightdev * added 'breeze' theme * added -example firebase config back in * added 2077 theme * made 2077 theme background less bright. * made 2077 theme better * added breeze theme * softer sub alt color --------- Co-authored-by: Miodec --- frontend/static/themes/_list.json | 9 ++++++++- frontend/static/themes/breeze.css | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 frontend/static/themes/breeze.css diff --git a/frontend/static/themes/_list.json b/frontend/static/themes/_list.json index 6f8286eb8..2793c7ad8 100644 --- a/frontend/static/themes/_list.json +++ b/frontend/static/themes/_list.json @@ -1146,5 +1146,12 @@ "mainColor": "#13005A", "subColor": "#1c82adc4", "textColor": "#125d98" -} + }, + { + "name": "breeze", + "bgColor": "#e8d5c4", + "mainColor": "#7d67a9", + "subColor": "#3a98b9", + "textColor": "#1b4c5e" + } ] diff --git a/frontend/static/themes/breeze.css b/frontend/static/themes/breeze.css new file mode 100644 index 000000000..05b54f679 --- /dev/null +++ b/frontend/static/themes/breeze.css @@ -0,0 +1,12 @@ +:root { + --bg-color: #e8d5c4; + --main-color: #7d67a9; + --caret-color: #7d67a9; + --sub-color: #3a98b9; + --sub-alt-color: #f6e6da; + --text-color: #1b4c5e; + --error-color: #7d67a9; + --error-extra-color: #9f3e6d; + --colorful-error-color: #f9f871; + --colorful-error-extra-color: #67dfa1; +} From 9131cebdf5274207a25d95670b40df915e49b1fb Mon Sep 17 00:00:00 2001 From: Dainternetdude <53956237+Dainternetdude@users.noreply.github.com> Date: Wed, 1 Mar 2023 02:47:05 -0700 Subject: [PATCH 07/40] Add one quote to English (#4033) Dainternetdude * add sturdy ortho keyboard layout * remove random extra double quote oops lmao * move sturdy ortho to be with the rest of the sturdy family * add one quote to english * use the full title of the book --- frontend/static/quotes/english.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/static/quotes/english.json b/frontend/static/quotes/english.json index b7cd9d00b..d2cdf7cdb 100644 --- a/frontend/static/quotes/english.json +++ b/frontend/static/quotes/english.json @@ -38651,6 +38651,12 @@ "source": "Conduction Heat Transfer", "id": 6768, "length": 250 + }, + { + "text": "My wife and I had lived in our house for over a dozen years at that point. Holly's family had lived in theirs even longer. We were both active families, involved in the community, with work, and with our churches. Yet, the thick woods covering the lots we each occupied along a cul-de-sac was enough of a barrier to our getting to know each other that we didn't even realize our neighbors across the street had a little girl the same age as ours. That is, until they met at the kindergarten in the elementary school six miles away.", + "source": "Strong Towns - A Bottom-Up Revolution to Rebuild American Prosperity", + "id": 6769, + "length": 531 } ] } From 0e286bc43620a70597a3aa5a1a0bbb545ca4a766 Mon Sep 17 00:00:00 2001 From: Decipher-CS <82650811+Decipher-CS@users.noreply.github.com> Date: Wed, 1 Mar 2023 15:18:44 +0530 Subject: [PATCH 08/40] added one new quote in English (#4034) Decipher-CS * added english quote * fixed the wrong increment. Should have been +1. --------- Co-authored-by: Miodec --- frontend/static/quotes/english.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/static/quotes/english.json b/frontend/static/quotes/english.json index d2cdf7cdb..046e7f260 100644 --- a/frontend/static/quotes/english.json +++ b/frontend/static/quotes/english.json @@ -38652,10 +38652,16 @@ "id": 6768, "length": 250 }, + { + "text": "The secret of happiness, you see, is not found in seeking more, but in developing the capacity to enjoy less.", + "source": "Unknown", + "id": 6769, + "length": 109 + }, { "text": "My wife and I had lived in our house for over a dozen years at that point. Holly's family had lived in theirs even longer. We were both active families, involved in the community, with work, and with our churches. Yet, the thick woods covering the lots we each occupied along a cul-de-sac was enough of a barrier to our getting to know each other that we didn't even realize our neighbors across the street had a little girl the same age as ours. That is, until they met at the kindergarten in the elementary school six miles away.", "source": "Strong Towns - A Bottom-Up Revolution to Rebuild American Prosperity", - "id": 6769, + "id": 6770, "length": 531 } ] From 6aef311a9c6a8ac2fff59c398f08b083ddbe305b Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 1 Mar 2023 21:19:29 -0500 Subject: [PATCH 09/40] Remove comma (#4037) --- frontend/static/security-policy.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/static/security-policy.html b/frontend/static/security-policy.html index 23cb2a66a..1633ba60f 100644 --- a/frontend/static/security-policy.html +++ b/frontend/static/security-policy.html @@ -136,9 +136,9 @@ availability of Monkeytype services, please send your disclosure via email - , + . - . For non-security related platform bugs, follow the bug submission + For non-security related platform bugs, follow the bug submission Date: Thu, 2 Mar 2023 22:06:33 +1030 Subject: [PATCH 10/40] Add layouts gallium and angle variant (#4038) GalileoBlues --- frontend/static/layouts/_list.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/frontend/static/layouts/_list.json b/frontend/static/layouts/_list.json index 97fff0db9..a5ba18901 100644 --- a/frontend/static/layouts/_list.json +++ b/frontend/static/layouts/_list.json @@ -1341,5 +1341,27 @@ "row4": ["ဖဇ", "ထဌ", "ခဃ", "လဠ", "ဘယ", "ညဉ", "ာဦ", ",၊", ".။", "/?"], "row5": [" "] } + }, + "gallium": { + "keymapShowTopRow": false, + "type": "ansi", + "keys": { + "row1": ["`~", "1!", "2@", "3#", "4$", "5%", "6^", "7&", "8*", "9(", "0)", "-_", "=+"], + "row2": ["bB", "lL", "dD", "cC", "vV", "zZ", "yY", "oO", "uU", ",<", "[{", "]}", "\\|"], + "row3": ["nN", "rR", "tT", "sS", "gG", "pP", "hH", "aA", "eE", "iI", "/?"], + "row4": ["qQ", "xX", "mM", "wW", "jJ", "kK", "fF", "'\"", ";:", ",)"], + "row5": [" "] + } + }, + "gallium_angle": { + "keymapShowTopRow": false, + "type": "ansi", + "keys": { + "row1": ["`~", "1!", "2@", "3#", "4$", "5%", "6^", "7&", "8*", "9(", "0)", "-_", "=+"], + "row2": ["bB", "lL", "dD", "cC", "jJ", "zZ", "yY", "oO", "uU", ",<", "[{", "]}", "\\|"], + "row3": ["nN", "rR", "tT", "sS", "vV", "pP", "hH", "aA", "eE", "iI", "/?"], + "row4": ["xX", "mM", "wW", "gG", "qQ", "kK", "fF", "'\"", ";:", ",)"], + "row5": [" "] + } } } From 97582e2a59335419574cebb9aa9d3d95d3e65c42 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 2 Mar 2023 12:35:32 +0100 Subject: [PATCH 11/40] not saving last result if the user signed out manually this session --- frontend/src/ts/controllers/account-controller.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/controllers/account-controller.ts b/frontend/src/ts/controllers/account-controller.ts index b4fb6612d..20e7b13dc 100644 --- a/frontend/src/ts/controllers/account-controller.ts +++ b/frontend/src/ts/controllers/account-controller.ts @@ -47,6 +47,8 @@ import { navigate } from "../observables/navigate-event"; import { update as updateTagsCommands } from "../commandline/lists/tags"; import * as ConnectionState from "../states/connection"; +let signedOutThisSession = false; + export const gmailProvider = new GoogleAuthProvider(); export async function sendVerificationEmail(): Promise { @@ -260,7 +262,7 @@ export async function loadUser(user: UserType): Promise { // showFavouriteThemesAtTheTop(); - if (TestLogic.notSignedInLastResult !== null) { + if (TestLogic.notSignedInLastResult !== null && !signedOutThisSession) { TestLogic.setNotSignedInUid(user.uid); const response = await Ape.results.save(TestLogic.notSignedInLastResult); @@ -716,6 +718,7 @@ $("#top .signInOut").on("click", () => { } if (Auth.currentUser) { signOut(); + signedOutThisSession = true; } else { navigate("/login"); } From 25bf28e886d160eb870bd323c81b2c68bb9a5532 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 2 Mar 2023 13:45:20 +0100 Subject: [PATCH 12/40] removed test-active file merged functionality into test-state --- .../src/ts/controllers/account-controller.ts | 4 ++-- frontend/src/ts/controllers/ad-controller.ts | 4 ++-- frontend/src/ts/controllers/input-controller.ts | 8 ++++---- frontend/src/ts/states/test-active.ts | 9 --------- frontend/src/ts/test/caret.ts | 4 ++-- frontend/src/ts/test/live-acc.ts | 4 ++-- frontend/src/ts/test/live-burst.ts | 4 ++-- frontend/src/ts/test/live-wpm.ts | 9 ++------- frontend/src/ts/test/monkey.ts | 4 ++-- frontend/src/ts/test/pace-caret.ts | 3 +-- frontend/src/ts/test/test-logic.ts | 17 ++++++++--------- frontend/src/ts/test/test-state.ts | 5 +++++ frontend/src/ts/test/test-timer.ts | 4 ++-- frontend/src/ts/test/timer-progress.ts | 6 +++--- frontend/src/ts/ui.ts | 4 ++-- 15 files changed, 39 insertions(+), 50 deletions(-) delete mode 100644 frontend/src/ts/states/test-active.ts diff --git a/frontend/src/ts/controllers/account-controller.ts b/frontend/src/ts/controllers/account-controller.ts index 20e7b13dc..c4c312d87 100644 --- a/frontend/src/ts/controllers/account-controller.ts +++ b/frontend/src/ts/controllers/account-controller.ts @@ -10,7 +10,7 @@ import * as TestLogic from "../test/test-logic"; import * as Loader from "../elements/loader"; import * as PageTransition from "../states/page-transition"; import * as ActivePage from "../states/active-page"; -import * as TestActive from "../states/test-active"; +import * as TestState from "../test/test-state"; import * as LoadingPage from "../pages/loading"; import * as LoginPage from "../pages/login"; import * as ResultFilters from "../account/result-filters"; @@ -218,7 +218,7 @@ export async function getDataAndInit(): Promise { AccountButton.loading(false); } if (Config.paceCaret === "pb" || Config.paceCaret === "average") { - if (!TestActive.get()) { + if (!TestState.isActive) { PaceCaret.init(); } } diff --git a/frontend/src/ts/controllers/ad-controller.ts b/frontend/src/ts/controllers/ad-controller.ts index a866a53b7..7d6eff727 100644 --- a/frontend/src/ts/controllers/ad-controller.ts +++ b/frontend/src/ts/controllers/ad-controller.ts @@ -3,7 +3,7 @@ import * as Misc from "../utils/misc"; import * as ConfigEvent from "../observables/config-event"; import * as BannerEvent from "../observables/banner-event"; import Config from "../config"; -import * as TestActive from "../states/test-active"; +import * as TestState from "../test/test-state"; const breakpoint = 900; let widerThanBreakpoint = true; @@ -27,7 +27,7 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= height="0" width="0" style="display:none;visibility:hidden">`); setInterval(() => { - if (TestActive.get()) { + if (TestState.isActive) { return; } refreshVisible(); diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 5b0fdc7c7..b524a0927 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -20,7 +20,7 @@ import * as Replay from "../test/replay"; import * as MonkeyPower from "../elements/monkey-power"; import * as WeakSpot from "../test/weak-spot"; import * as ActivePage from "../states/active-page"; -import * as TestActive from "../states/test-active"; +import * as TestState from "../test/test-state"; import * as CompositionState from "../states/composition"; import * as TestInput from "../test/test-input"; import * as TestWords from "../test/test-words"; @@ -100,7 +100,7 @@ function updateUI(): void { } function backspaceToPrevious(): void { - if (!TestActive.get()) return; + if (!TestState.isActive) return; if ( TestInput.input.history.length === 0 || @@ -141,7 +141,7 @@ function backspaceToPrevious(): void { } function handleSpace(): void { - if (!TestActive.get()) return; + if (!TestState.isActive) return; if (TestInput.input.current === "") return; @@ -441,7 +441,7 @@ function handleChar( } //start the test - if (!TestActive.get() && !TestLogic.startTest()) { + if (!TestState.isActive && !TestLogic.startTest()) { return; } diff --git a/frontend/src/ts/states/test-active.ts b/frontend/src/ts/states/test-active.ts deleted file mode 100644 index 94133a3d1..000000000 --- a/frontend/src/ts/states/test-active.ts +++ /dev/null @@ -1,9 +0,0 @@ -let testActive = false; - -export function get(): boolean { - return testActive; -} - -export function set(active: boolean): void { - testActive = active; -} diff --git a/frontend/src/ts/test/caret.ts b/frontend/src/ts/test/caret.ts index 2a3644ef3..4708d8861 100644 --- a/frontend/src/ts/test/caret.ts +++ b/frontend/src/ts/test/caret.ts @@ -2,7 +2,7 @@ import * as Misc from "../utils/misc"; import Config from "../config"; import * as TestInput from "./test-input"; import * as SlowTimer from "../states/slow-timer"; -import * as TestActive from "../states/test-active"; +import * as TestState from "../test/test-state"; export let caretAnimating = true; const caret = $("#caret"); @@ -134,7 +134,7 @@ export async function updatePosition(): Promise { if ( newTop >= middlePos && contentHeight > browserHeight && - TestActive.get() + TestState.isActive ) { const newscrolltop = newTop - middlePos / 2; window.scrollTo({ diff --git a/frontend/src/ts/test/live-acc.ts b/frontend/src/ts/test/live-acc.ts index e33b96774..c96cebdb1 100644 --- a/frontend/src/ts/test/live-acc.ts +++ b/frontend/src/ts/test/live-acc.ts @@ -1,5 +1,5 @@ import Config from "../config"; -import * as TestActive from "../states/test-active"; +import * as TestState from "../test/test-state"; import * as ConfigEvent from "../observables/config-event"; export function update(acc: number): void { @@ -14,7 +14,7 @@ export function update(acc: number): void { export function show(): void { if (!Config.showLiveAcc) return; - if (!TestActive.get()) return; + if (!TestState.isActive) return; if (Config.timerStyle === "mini") { if (!$("#miniTimerAndLiveWpm .acc").hasClass("hidden")) return; $("#miniTimerAndLiveWpm .acc") diff --git a/frontend/src/ts/test/live-burst.ts b/frontend/src/ts/test/live-burst.ts index 3b26ff705..6dcea2803 100644 --- a/frontend/src/ts/test/live-burst.ts +++ b/frontend/src/ts/test/live-burst.ts @@ -1,5 +1,5 @@ import Config from "../config"; -import * as TestActive from "../states/test-active"; +import * as TestState from "../test/test-state"; import * as ConfigEvent from "../observables/config-event"; export async function update(burst: number): Promise { @@ -12,7 +12,7 @@ export async function update(burst: number): Promise { export function show(): void { if (!Config.showLiveBurst) return; - if (!TestActive.get()) return; + if (!TestState.isActive) return; if (Config.timerStyle === "mini") { if (!$("#miniTimerAndLiveWpm .burst").hasClass("hidden")) return; $("#miniTimerAndLiveWpm .burst") diff --git a/frontend/src/ts/test/live-wpm.ts b/frontend/src/ts/test/live-wpm.ts index 914f79c2f..e007fbecb 100644 --- a/frontend/src/ts/test/live-wpm.ts +++ b/frontend/src/ts/test/live-wpm.ts @@ -1,5 +1,5 @@ import Config from "../config"; -import * as TestActive from "../states/test-active"; +import * as TestState from "../test/test-state"; import * as ConfigEvent from "../observables/config-event"; const liveWpmElement = document.querySelector("#liveWpm") as Element; @@ -8,11 +8,6 @@ const miniLiveWpmElement = document.querySelector( ) as Element; export function update(wpm: number, raw: number): void { - // if (!TestActive.get() || !Config.showLiveWpm) { - // hideLiveWpm(); - // } else { - // showLiveWpm(); - // } let number = wpm; if (Config.blindMode) { number = raw; @@ -26,7 +21,7 @@ export function update(wpm: number, raw: number): void { export function show(): void { if (!Config.showLiveWpm) return; - if (!TestActive.get()) return; + if (!TestState.isActive) return; if (Config.timerStyle === "mini") { if (!$("#miniTimerAndLiveWpm .wpm").hasClass("hidden")) return; $("#miniTimerAndLiveWpm .wpm") diff --git a/frontend/src/ts/test/monkey.ts b/frontend/src/ts/test/monkey.ts index 7e973a814..781d54a87 100644 --- a/frontend/src/ts/test/monkey.ts +++ b/frontend/src/ts/test/monkey.ts @@ -1,10 +1,10 @@ import { mapRange } from "../utils/misc"; import Config from "../config"; import * as ConfigEvent from "../observables/config-event"; -import * as TestActive from "../states/test-active"; +import * as TestState from "../test/test-state"; ConfigEvent.subscribe((eventKey) => { - if (eventKey === "monkey" && TestActive.get()) { + if (eventKey === "monkey" && TestState.isActive) { if (Config.monkey) { $("#monkey").removeClass("hidden"); } else { diff --git a/frontend/src/ts/test/pace-caret.ts b/frontend/src/ts/test/pace-caret.ts index 4643655a2..e894d6785 100644 --- a/frontend/src/ts/test/pace-caret.ts +++ b/frontend/src/ts/test/pace-caret.ts @@ -5,7 +5,6 @@ import Config from "../config"; import * as DB from "../db"; import * as SlowTimer from "../states/slow-timer"; import * as Misc from "../utils/misc"; -import * as TestActive from "../states/test-active"; import * as TestState from "./test-state"; import * as ConfigEvent from "../observables/config-event"; @@ -113,7 +112,7 @@ export async function init(): Promise { } export function update(expectedStepEnd: number): void { - if (settings === null || !TestActive.get() || TestUI.resultVisible) { + if (settings === null || !TestState.isActive || TestUI.resultVisible) { return; } // if ($("#paceCaret").hasClass("hidden")) { diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index bf79ceb4e..4e425ecdf 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -38,7 +38,6 @@ import * as LazyMode from "./lazy-mode"; import * as Result from "./result"; import * as MonkeyPower from "../elements/monkey-power"; import * as ActivePage from "../states/active-page"; -import * as TestActive from "../states/test-active"; import * as TestInput from "./test-input"; import * as TestWords from "./test-words"; import * as TestState from "./test-state"; @@ -320,7 +319,7 @@ export function startTest(): boolean { AnalyticsController.log("testStartedNoLogin"); } - TestActive.set(true); + TestState.setActive(true); Replay.startReplayRecording(); Replay.replayGetWordsList(TestWords.words.list); TestInput.resetKeypressTimings(); @@ -417,7 +416,7 @@ export function restart(options = {} as RestartOptions): void { // } } } - if (TestActive.get()) { + if (TestState.isActive) { if ( Config.repeatQuotes === "typing" && Config.mode === "quote" && @@ -486,7 +485,7 @@ export function restart(options = {} as RestartOptions): void { TestInput.corrected.reset(); ShiftTracker.reset(); Caret.hide(); - TestActive.set(false); + TestState.setActive(false); Replay.stopReplayRecording(); LiveWpm.hide(); LiveAcc.hide(); @@ -584,7 +583,7 @@ export function restart(options = {} as RestartOptions): void { } else { TestState.setRepeated(true); TestState.setPaceRepeat(repeatWithPace); - TestActive.set(false); + TestState.setActive(false); Replay.stopReplayRecording(); TestWords.words.resetCurrentIndex(); TestInput.input.reset(); @@ -821,7 +820,7 @@ async function getNextWord( let rememberLazyMode: boolean; export async function init(): Promise { - TestActive.set(false); + TestState.setActive(false); MonkeyPower.reset(); Replay.stopReplayRecording(); TestWords.words.reset(); @@ -1482,7 +1481,7 @@ function buildCompletedEvent(difficultyFailed: boolean): CompletedEvent { } export async function finish(difficultyFailed = false): Promise { - if (!TestActive.get()) return; + if (!TestState.isActive) return; if (TestInput.input.current.length != 0) { TestInput.input.pushHistory(); TestInput.corrected.pushHistory(); @@ -1494,7 +1493,7 @@ export async function finish(difficultyFailed = false): Promise { TestUI.setResultCalculating(true); TestUI.setResultVisible(true); TestStats.setEnd(performance.now()); - TestActive.set(false); + TestState.setActive(false); Replay.stopReplayRecording(); Focus.set(false); Caret.hide(); @@ -1899,7 +1898,7 @@ $(".pageTest").on("click", "#restartTestButton", () => { ManualRestart.set(); if (TestUI.resultCalculating) return; if ( - TestActive.get() && + TestState.isActive && Config.repeatQuotes === "typing" && Config.mode === "quote" ) { diff --git a/frontend/src/ts/test/test-state.ts b/frontend/src/ts/test/test-state.ts index ed7f12043..89a164d13 100644 --- a/frontend/src/ts/test/test-state.ts +++ b/frontend/src/ts/test/test-state.ts @@ -1,5 +1,6 @@ export let isRepeated = false; export let isPaceRepeat = false; +export let isActive = false; export let activeChallenge: null | MonkeyTypes.Challenge = null; export let savingEnabled = true; @@ -11,6 +12,10 @@ export function setPaceRepeat(tf: boolean): void { isPaceRepeat = tf; } +export function setActive(tf: boolean): void { + isActive = tf; +} + export function setActiveChallenge(val: null | MonkeyTypes.Challenge): void { activeChallenge = val; } diff --git a/frontend/src/ts/test/test-timer.ts b/frontend/src/ts/test/test-timer.ts index fa71c26af..6e441b016 100644 --- a/frontend/src/ts/test/test-timer.ts +++ b/frontend/src/ts/test/test-timer.ts @@ -13,7 +13,7 @@ import * as Misc from "../utils/misc"; import * as Notifications from "../elements/notifications"; import * as Caret from "./caret"; import * as SlowTimer from "../states/slow-timer"; -import * as TestActive from "../states/test-active"; +import * as TestState from "./test-state"; import * as Time from "../states/time"; import * as TimerEvent from "../observables/timer-event"; @@ -236,7 +236,7 @@ export async function start(): Promise { timer = setTimeout(function () { // time++; - if (!TestActive.get()) { + if (!TestState.isActive) { if (timer !== null) clearTimeout(timer); SlowTimer.clear(); slowTimerCount = 0; diff --git a/frontend/src/ts/test/timer-progress.ts b/frontend/src/ts/test/timer-progress.ts index 74e18bdf3..c04353d3d 100644 --- a/frontend/src/ts/test/timer-progress.ts +++ b/frontend/src/ts/test/timer-progress.ts @@ -5,7 +5,7 @@ import * as TestWords from "./test-words"; import * as TestInput from "./test-input"; import * as Time from "../states/time"; import * as SlowTimer from "../states/slow-timer"; -import * as TestActive from "../states/test-active"; +import * as TestState from "./test-state"; import * as ConfigEvent from "../observables/config-event"; export function show(): void { @@ -201,7 +201,7 @@ export function update(): void { } export function updateStyle(): void { - if (!TestActive.get()) return; + if (!TestState.isActive) return; hide(); update(); setTimeout(() => { @@ -211,7 +211,7 @@ export function updateStyle(): void { ConfigEvent.subscribe((eventKey, eventValue) => { if (eventKey === "showTimerProgress") { - if (eventValue === true && TestActive.get()) { + if (eventValue === true && TestState.isActive) { show(); } else { hide(); diff --git a/frontend/src/ts/ui.ts b/frontend/src/ts/ui.ts index dd0b31554..589d437e0 100644 --- a/frontend/src/ts/ui.ts +++ b/frontend/src/ts/ui.ts @@ -2,7 +2,7 @@ import Config from "./config"; import * as Caret from "./test/caret"; import * as Notifications from "./elements/notifications"; import * as CustomText from "./test/custom-text"; -import * as TestActive from "./states/test-active"; +import * as TestState from "./test/test-state"; import * as ConfigEvent from "./observables/config-event"; import { debounce, throttle } from "throttle-debounce"; import * as TestUI from "./test/test-ui"; @@ -75,7 +75,7 @@ window.addEventListener("beforeunload", (event) => { ) { //ignore } else { - if (TestActive.get()) { + if (TestState.isActive) { event.preventDefault(); // Chrome requires returnValue to be set. event.returnValue = ""; From 11d768e89ecea6d9b47926232ca61f1a0ffbaa02 Mon Sep 17 00:00:00 2001 From: SauceyRed <42098474+SauceyRed@users.noreply.github.com> Date: Fri, 3 Mar 2023 12:10:10 +0100 Subject: [PATCH 13/40] Added 12 quotes to english.json - 6771-6782 (#4039) Saucy Red * Added 12 quotes to english.json * Fixed IDs in english.json --- frontend/static/quotes/english.json | 72 +++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/frontend/static/quotes/english.json b/frontend/static/quotes/english.json index 046e7f260..f16c517ae 100644 --- a/frontend/static/quotes/english.json +++ b/frontend/static/quotes/english.json @@ -38663,6 +38663,78 @@ "source": "Strong Towns - A Bottom-Up Revolution to Rebuild American Prosperity", "id": 6770, "length": 531 + }, + { + "text": "The single quality that is common across every living creature on this planet, is fear. It’s funny, then, that as common as fear is, we so easily underestimate its power. Fear of growing close to someone, the subsequent fear of loss, fear of failure. And as more people depend on you, those fears can take on greater power. But fear itself isn’t worthy of concern, it is who we become while in its clutches. Will you be proud of that person? Will you forgive them? Will you understand why they felt the need to do the things they did? Will you even recognize them? Or will the person staring back at you be the very thing you should have feared from the start? I suppose we all find out sooner or later.", + "source": "RWBY", + "id": 6771, + "length": 703 + }, + { + "text": "I once told you I made more mistakes than any man, woman, or child on this planet. I wasn't exaggerating. I'm... cursed. For thousands of years I have walked the surface of Remnant; living, dying, and reincarnating in the body of a like-minded soul. The Professor Ozpin you all met was not my first form, and it clearly wasn't my last. It's... an extraordinarily strenuous process, on everyone involved.", + "source": "RWBY", + "id": 6772, + "length": 403 + }, + { + "text": "Being a team leader isn't just a title you carry into battle, but a badge you wear constantly. If you are not always performing at your absolute best, then what reason do you give others to follow you?", + "source": "RWBY", + "id": 6773, + "length": 201 + }, + { + "text": "I'll...keep this brief. You have traveled here today in search of knowledge--to hone your craft and acquire new skills. And when you have finished, you plan to dedicate your life to the protection of the people. But I look amongst you, and all I see is wasted energy, in need of purpose -- direction. You assume knowledge will free you of this, but your time at this school will prove that knowledge can only carry you so far. It is up to you to take the first step.", + "source": "RWBY", + "id": 6774, + "length": 466 + }, + { + "text": "It's important not to lose sight of what drives us: love, justice, reverence... but the moment you put your desires before my own... they will be lost to you. This isn't a threat, this is simply the truth. The path to your desires is only found... through me.", + "source": "RWBY", + "id": 6775, + "length": 259 + }, + { + "text": "You told me once that bad things just happen. You were angry when you said it, and I didn't want to listen. But you were right. Bad things do happen, all the time, every day. Which is why I'm out here, to do whatever I can, wherever I can, and hopefully do some good.", + "source": "RWBY", + "id": 6776, + "length": 267 + }, + { + "text": "We've all lost something, and I've seen what loss can do to people. But if we gave up every time we lost, then we'd never be able to move forward.", + "source": "RWBY", + "id": 6777, + "length": 146 + }, + { + "text": "You're wrong. We've done things that most people would call impossible, and I know the only reason we were able to do it is because we didn't do it alone! We had people to teach us, people to help us, we had each other. Work with us. At least I know we'll have a better chance if we try together. Please.", + "source": "RWBY", + "id": 6778, + "length": 304 + }, + { + "text": "Just because you don't have an idea, doesn't mean we're out of options! Oz hasn't been here to tell us what to do, but we still managed to get this far anyway. We've been in bad situations before, and we don't need an adult to come save us or tell us what to do. We just did it our way! And I say we do it our way. And if you think you can keep up with us \"kids\"... we'd be happy to have you.", + "source": "RWBY", + "id": 6779, + "length": 392 + }, + { + "text": "The Threads of Fate are not puppet strings. They connect life to destiny. You are fate-touched, able to see and bend the threads around you. Understand the wholeness of what you serve, champion. All the living share one experience: death. Your mother, your sister, even you. We must safeguard that beautiful moment when the soul transitions to a new purpose.", + "source": "The Legend of Vox Machina", + "id": 6780, + "length": 358 + }, + { + "text": "Protecting the sanctity between life and death. That is our cause. Your cause. Do you accept this charge?", + "source": "The Legend of Vox Machina", + "id": 6781, + "length": 105 + }, + { + "text": "I've been watching you longer than you know. Recklessly drawn to your destiny, like a flame. My beautiful champion. There is much to fear, but not death. For it gives meaning to life.", + "source": "The Legend of Vox Machina", + "id": 6782, + "length": 183 } ] } From 5c93fa7edf47689788c694a5e7fffda5758c2412 Mon Sep 17 00:00:00 2001 From: Miodec Date: Fri, 3 Mar 2023 12:06:09 +0100 Subject: [PATCH 14/40] added better error to try to identify an issue --- backend/src/api/controllers/user.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/src/api/controllers/user.ts b/backend/src/api/controllers/user.ts index a7f6f5505..7de823537 100644 --- a/backend/src/api/controllers/user.ts +++ b/backend/src/api/controllers/user.ts @@ -84,7 +84,15 @@ export async function sendVerificationEmail( e.message.includes("TOO_MANY_ATTEMPTS_TRY_LATER") ) { // for some reason this error is not handled with a custom auth/ code, so we have to do it manually - throw new MonkeyError(429, "Too many requests. Please try again later."); + throw new MonkeyError(429, "Too many requests. Please try again later"); + } + if (e.code === "auth/user-not-found") { + throw new MonkeyError( + 500, + "Auth user not found when the user was found in the database", + JSON.stringify({ email: email, userInfoEmail: email, stack: e.stack }), + userInfo.uid + ); } throw e; } From fb9f74f8ea48633eff0488d4c8158629302b912f Mon Sep 17 00:00:00 2001 From: Miodec Date: Fri, 3 Mar 2023 15:22:43 +0100 Subject: [PATCH 15/40] added section about data that is not collected as per user request --- frontend/static/privacy-policy.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frontend/static/privacy-policy.html b/frontend/static/privacy-policy.html index acd54161e..66c4f7d58 100644 --- a/frontend/static/privacy-policy.html +++ b/frontend/static/privacy-policy.html @@ -184,6 +184,17 @@
  • How many typing tests you've started and completed
  • How long you've been typing on the website
  • +

    Monkeytype does NOT collect:

    +
      +
    • + custom texts (they are stored in your browser's local storage) +
    • +
    + + If you believe a certain data type is missing from the lists above, + feel free to contact us and we will answer any questions and update + the privacy policy. +

    How do we collect your data?

    From a6464d8067376b2a5eb7d4a52ccb4be07b4fce37 Mon Sep 17 00:00:00 2001 From: Miodec Date: Sat, 4 Mar 2023 12:03:14 +0100 Subject: [PATCH 16/40] fixed tag pbs with no funboxes not showing up --- frontend/src/ts/test/result.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/ts/test/result.ts b/frontend/src/ts/test/result.ts index 9f90efab7..6cfea4e36 100644 --- a/frontend/src/ts/test/result.ts +++ b/frontend/src/ts/test/result.ts @@ -471,7 +471,7 @@ async function updateTags(dontSave: boolean): Promise { if ( Config.mode != "quote" && !dontSave && - (funboxes.length === 0 || allFunboxesCanGetPb) + (result.funbox === "none" || funboxes.length === 0 || allFunboxesCanGetPb) ) { if (tpb < result.wpm) { //new pb for that tag @@ -735,7 +735,7 @@ export async function update( updateQuoteFavorite(randomQuote); await updateGraph(); await updateGraphPBLine(); - updateTags(dontSave); + await updateTags(dontSave); updateOther(difficultyFailed, failReason, afkDetected, isRepeated, tooShort); ((ChartController.result.options as PluginChartOptions<"line" | "scatter">) From b6f196cc27ff1641f60d01cab7015396866c75ae Mon Sep 17 00:00:00 2001 From: Miodec Date: Sat, 4 Mar 2023 16:40:12 +0100 Subject: [PATCH 17/40] allowing escape to close the mini result graph popup --- frontend/src/ts/account/mini-result-chart.ts | 10 ++++++++++ frontend/src/ts/commandline/index.ts | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/account/mini-result-chart.ts b/frontend/src/ts/account/mini-result-chart.ts index 808363190..1208ca88c 100644 --- a/frontend/src/ts/account/mini-result-chart.ts +++ b/frontend/src/ts/account/mini-result-chart.ts @@ -61,6 +61,16 @@ export function updateData(data: MonkeyTypes.ChartData): void { ChartController.miniResult.updateColors(); } +$(document).on("keydown", (event) => { + if ( + event.key === "Escape" && + Misc.isElementVisible(".pageAccount .miniResultChartWrapper") + ) { + hide(); + event.preventDefault(); + } +}); + $(".pageAccount").on("click", ".miniResultChartBg", () => { hide(); }); diff --git a/frontend/src/ts/commandline/index.ts b/frontend/src/ts/commandline/index.ts index bf01fff3a..2b07462e9 100644 --- a/frontend/src/ts/commandline/index.ts +++ b/frontend/src/ts/commandline/index.ts @@ -485,8 +485,11 @@ $(document).ready(() => { event.shiftKey) ) { const popupVisible = isAnyPopupVisible(); + const miniResultPopupVisible = isElementVisible( + ".pageAccount .miniResultChartWrapper" + ); - if (popupVisible) return; + if (popupVisible || miniResultPopupVisible) return; if (Config.quickRestart === "esc" && ActivePage.get() === "login") return; event.preventDefault(); From c7737edc8e473caa0ad6f5d23d2c12530a979200 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 25 Feb 2023 21:13:18 -0600 Subject: [PATCH 18/40] == -> === in backend and config.ts --- backend/src/api/controllers/result.ts | 2 +- backend/src/dal/new-quotes.ts | 2 +- backend/src/dal/user.ts | 4 +- frontend/src/ts/config.ts | 62 +++++++-------------------- 4 files changed, 20 insertions(+), 50 deletions(-) diff --git a/backend/src/api/controllers/result.ts b/backend/src/api/controllers/result.ts index 2403dd158..617aaf656 100644 --- a/backend/src/api/controllers/result.ts +++ b/backend/src/api/controllers/result.ts @@ -368,7 +368,7 @@ export async function addResult( let totalDurationTypedSeconds = 0; let afk = result.afkDuration; - if (afk == undefined) { + if (afk === undefined) { afk = 0; } totalDurationTypedSeconds = diff --git a/backend/src/dal/new-quotes.ts b/backend/src/dal/new-quotes.ts index 6b4b26dad..bbc28a71c 100644 --- a/backend/src/dal/new-quotes.ts +++ b/backend/src/dal/new-quotes.ts @@ -66,7 +66,7 @@ export async function add( } else { return { languageError: 1 }; } - if (duplicateId != -1) { + if (duplicateId !== -1) { return { duplicateId, similarityScore }; } await db.collection("new-quotes").insertOne(quote); diff --git a/backend/src/dal/user.ts b/backend/src/dal/user.ts index 18ec60a30..61f8af047 100644 --- a/backend/src/dal/user.ts +++ b/backend/src/dal/user.ts @@ -304,7 +304,7 @@ export async function removeTag(uid: string, _id: string): Promise { const user = await getUser(uid, "remove tag"); if ( user.tags === undefined || - user.tags.filter((t) => t._id.toHexString() == _id).length === 0 + user.tags.filter((t) => t._id.toHexString() === _id).length === 0 ) { throw new MonkeyError(404, "Tag not found"); } @@ -321,7 +321,7 @@ export async function removeTagPb(uid: string, _id: string): Promise { const user = await getUser(uid, "remove tag pb"); if ( user.tags === undefined || - user.tags.filter((t) => t._id.toHexString() == _id).length === 0 + user.tags.filter((t) => t._id.toHexString() === _id).length === 0 ) { throw new MonkeyError(404, "Tag not found"); } diff --git a/frontend/src/ts/config.ts b/frontend/src/ts/config.ts index 0058e4dbf..7854e1a61 100644 --- a/frontend/src/ts/config.ts +++ b/frontend/src/ts/config.ts @@ -140,14 +140,14 @@ export function setMode(mode: MonkeyTypes.Mode, nosave?: boolean): boolean { const previous = config.mode; config.mode = mode; - if (config.mode == "custom") { + if (config.mode === "custom") { setPunctuation(false, true); setNumbers(false, true); - } else if (config.mode == "quote") { + } else if (config.mode === "quote") { setPunctuation(false, true); setNumbers(false, true); - } else if (config.mode == "zen") { - if (config.paceCaret != "off") { + } else if (config.mode === "zen") { + if (config.paceCaret !== "off") { Notifications.add(`Pace caret will not work with zen mode.`, 0); } } @@ -268,7 +268,7 @@ export function toggleFunbox( let r; const funboxArray = config.funbox.split("#"); - if (funboxArray[0] == "none") funboxArray.splice(0, 1); + if (funboxArray[0] === "none") funboxArray.splice(0, 1); if (!funboxArray.includes(funbox)) { funboxArray.push(funbox); config.funbox = funboxArray.sort().join("#"); @@ -276,7 +276,7 @@ export function toggleFunbox( } else { r = funboxArray.indexOf(funbox); funboxArray.splice(r, 1); - if (funboxArray.length == 0) { + if (funboxArray.length === 0) { config.funbox = "none"; } else { config.funbox = funboxArray.join("#"); @@ -407,12 +407,12 @@ export function setPaceCaret( } if (document.readyState === "complete") { - if (val == "pb" && !Auth?.currentUser) { + if (val === "pb" && !Auth?.currentUser) { Notifications.add("PB pace caret is unavailable without an account", 0); return false; } } - // if (config.mode === "zen" && val != "off") { + // if (config.mode === "zen" && val !== "off") { // Notifications.add(`Can't use pace caret with zen mode.`, 0); // val = "off"; // } @@ -733,21 +733,7 @@ export function setCaretStyle( $("#caret").removeClass("carrot"); $("#caret").removeClass("banana"); - if (caretStyle == "off") { - $("#caret").addClass("off"); - } else if (caretStyle == "default") { - $("#caret").addClass("default"); - } else if (caretStyle == "block") { - $("#caret").addClass("block"); - } else if (caretStyle == "outline") { - $("#caret").addClass("outline"); - } else if (caretStyle == "underline") { - $("#caret").addClass("underline"); - } else if (caretStyle == "carrot") { - $("#caret").addClass("carrot"); - } else if (caretStyle == "banana") { - $("#caret").addClass("banana"); - } + $("#caret").addClass(caretStyle); saveToLocalStorage("caretStyle", nosave); ConfigEvent.dispatch("caretStyle", config.caretStyle); @@ -775,19 +761,7 @@ export function setPaceCaretStyle( $("#paceCaret").removeClass("carrot"); $("#paceCaret").removeClass("banana"); - if (caretStyle == "default") { - $("#paceCaret").addClass("default"); - } else if (caretStyle == "block") { - $("#paceCaret").addClass("block"); - } else if (caretStyle == "outline") { - $("#paceCaret").addClass("outline"); - } else if (caretStyle == "underline") { - $("#paceCaret").addClass("underline"); - } else if (caretStyle == "carrot") { - $("#paceCaret").addClass("carrot"); - } else if (caretStyle == "banana") { - $("#paceCaret").addClass("banana"); - } + $("#paceCaret").addClass(caretStyle); saveToLocalStorage("paceCaretStyle", nosave); ConfigEvent.dispatch("paceCaretStyle", config.paceCaretStyle); @@ -1208,9 +1182,7 @@ export function setFontFamily(font: string, nosave?: boolean): boolean { export function setFreedomMode(freedom: boolean, nosave?: boolean): boolean { if (!isConfigValueValid("freedom mode", freedom, ["boolean"])) return false; - if (freedom == null) { - freedom = false; - } + freedom ??= false; config.freedomMode = freedom; if (config.freedomMode && config.confidenceMode !== "off") { config.confidenceMode = "off"; @@ -1576,9 +1548,7 @@ export function setLayout(layout: string, nosave?: boolean): boolean { } // export function setSavedLayout(layout: string, nosave?: boolean): boolean { -// if (layout == null || layout == undefined) { -// layout = "qwerty"; -// } +// layout ??= "qwerty"; // config.savedLayout = layout; // setLayout(layout, nosave); @@ -1612,7 +1582,7 @@ export function setFontSize(fontSize: number, nosave?: boolean): boolean { // after converting from the string to float system // keeping this in for now, if you want a big font go 14.9 or something - if (fontSize == 15) { + if (fontSize === 15) { fontSize = 1.5; } @@ -1641,7 +1611,7 @@ export function setCustomBackground(value: string, nosave?: boolean): boolean { value ) && !/[<> "]/.test(value)) || - value == "" + value === "" ) { config.customBackground = value; saveToLocalStorage("customBackground", nosave); @@ -1689,7 +1659,7 @@ export function setCustomBackgroundSize( return false; } - if (value != "cover" && value != "contain" && value != "max") { + if (value !== "cover" && value !== "contain" && value !== "max") { value = "cover"; } config.customBackgroundSize = value; @@ -1897,7 +1867,7 @@ export function getConfigChanges(): MonkeyTypes.PresetConfig { const configChanges = {} as MonkeyTypes.PresetConfig; (Object.keys(config) as (keyof MonkeyTypes.Config)[]) .filter((key) => { - return config[key] != DefaultConfig[key]; + return config[key] !== DefaultConfig[key]; }) .forEach((key) => { (configChanges[key] as typeof config[typeof key]) = config[key]; From 3e202e3248a22842b6f5163b96f6c70ab75439d7 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 25 Feb 2023 21:47:58 -0600 Subject: [PATCH 19/40] == -> === in db.ts --- frontend/src/ts/db.ts | 86 ++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 50 deletions(-) diff --git a/frontend/src/ts/db.ts b/frontend/src/ts/db.ts index 2bb4c6ae1..38dc43904 100644 --- a/frontend/src/ts/db.ts +++ b/frontend/src/ts/db.ts @@ -45,7 +45,7 @@ export async function initSnapshot(): Promise< const snap = defaultSnap; try { if (!Auth?.currentUser) return false; - // if (ActivePage.get() == "loading") { + // if (ActivePage.get() === "loading") { // LoadingPage.updateBar(22.5); // } else { // LoadingPage.updateBar(16); @@ -126,7 +126,7 @@ export async function initSnapshot(): Promise< } else if (userData.lbMemory) { snap.lbMemory = userData.lbMemory; } - // if (ActivePage.get() == "loading") { + // if (ActivePage.get() === "loading") { // LoadingPage.updateBar(45); // } else { // LoadingPage.updateBar(32); @@ -155,7 +155,7 @@ export async function initSnapshot(): Promise< snap.config = newConfig; } - // if (ActivePage.get() == "loading") { + // if (ActivePage.get() === "loading") { // LoadingPage.updateBar(67.5); // } else { // LoadingPage.updateBar(48); @@ -177,7 +177,7 @@ export async function initSnapshot(): Promise< return 0; } }); - // if (ActivePage.get() == "loading") { + // if (ActivePage.get() === "loading") { // LoadingPage.updateBar(90); // } else { // LoadingPage.updateBar(64); @@ -353,13 +353,14 @@ export async function getUserHighestWpm( dbSnapshot?.results?.forEach((result) => { if ( - result.mode == mode && - result.mode2 == mode2 && - result.punctuation == punctuation && - result.language == language && - result.difficulty == difficulty && + result.mode === mode && + result.mode2 === mode2 && + (result.punctuation === punctuation || + (result.punctuation === undefined && !punctuation)) && + result.language === language && + result.difficulty === difficulty && (result.lazyMode === lazyMode || - (result.lazyMode === undefined && lazyMode === false)) + (result.lazyMode === undefined && !lazyMode)) ) { if (result.wpm > topWpm) { topWpm = result.wpm; @@ -539,11 +540,10 @@ export async function getLocalPB( ] as unknown as MonkeyTypes.PersonalBest[] ).forEach((pb) => { if ( - pb.punctuation == punctuation && - pb.difficulty == difficulty && - pb.language == language && - (pb.lazyMode === lazyMode || - (pb.lazyMode === undefined && lazyMode === false)) + pb.punctuation === punctuation && + pb.difficulty === difficulty && + pb.language === language && + pb.lazyMode === lazyMode ) { ret = pb.wpm; } @@ -572,7 +572,7 @@ export async function saveLocalPB( raw: number, consistency: number ): Promise { - if (mode == "quote") return; + if (mode === "quote") return; if (!dbSnapshot) return; function cont(): void { if (!dbSnapshot) return; @@ -608,9 +608,9 @@ export async function saveLocalPB( ] as unknown as MonkeyTypes.PersonalBest[] ).forEach((pb) => { if ( - pb.punctuation == punctuation && - pb.difficulty == difficulty && - pb.language == language && + pb.punctuation === punctuation && + pb.difficulty === difficulty && + pb.language === language && (pb.lazyMode === lazyMode || (pb.lazyMode === undefined && lazyMode === false)) ) { @@ -643,7 +643,7 @@ export async function saveLocalPB( } } - if (dbSnapshot != null) { + if (!dbSnapshot) { cont(); } } @@ -682,11 +682,10 @@ export async function getLocalTagPB( personalBests.forEach((pb) => { if ( - pb.punctuation == punctuation && - pb.difficulty == difficulty && - pb.language == language && - (pb.lazyMode === lazyMode || - (pb.lazyMode === undefined && lazyMode === false)) + pb.punctuation === punctuation && + pb.difficulty === difficulty && + pb.language === language && + pb.lazyMode === lazyMode ) { ret = pb.wpm; } @@ -715,7 +714,7 @@ export async function saveLocalTagPB( raw: number, consistency: number ): Promise { - if (mode == "quote") return; + if (mode === "quote") return; function cont(): void { const filteredtag = dbSnapshot?.tags?.filter( (t) => t._id === tagId @@ -743,11 +742,10 @@ export async function saveLocalTagPB( ] as unknown as MonkeyTypes.PersonalBest[] ).forEach((pb) => { if ( - pb.punctuation == punctuation && - pb.difficulty == difficulty && - pb.language == language && - (pb.lazyMode === lazyMode || - (pb.lazyMode === undefined && lazyMode === false)) + pb.punctuation === punctuation && + pb.difficulty === difficulty && + pb.language === language && + pb.lazyMode === lazyMode ) { found = true; pb.wpm = wpm; @@ -808,7 +806,7 @@ export async function saveLocalTagPB( } } - if (dbSnapshot != null) { + if (!dbSnapshot) { cont(); } @@ -842,7 +840,7 @@ export async function updateLbMemory( } const current = snapshot.lbMemory[timeMode][timeMode2][language]; snapshot.lbMemory[timeMode][timeMode2][language] = rank; - if (api && current != rank) { + if (api && current !== rank) { await Ape.users.updateLeaderboardMemory(mode, mode2, language, rank); } setSnapshot(snapshot); @@ -878,21 +876,9 @@ export function updateLocalStats(started: number, time: number): void { snapshot.typingStats = {} as MonkeyTypes.TypingStats; } if (snapshot !== null && snapshot.typingStats !== undefined) { - if (snapshot.typingStats.timeTyping == undefined) { - snapshot.typingStats.timeTyping = time; - } else { - snapshot.typingStats.timeTyping += time; - } - if (snapshot.typingStats.startedTests == undefined) { - snapshot.typingStats.startedTests = started; - } else { - snapshot.typingStats.startedTests += started; - } - if (snapshot.typingStats.completedTests == undefined) { - snapshot.typingStats.completedTests = 1; - } else { - snapshot.typingStats.completedTests += 1; - } + snapshot.typingStats.timeTyping += time; + snapshot.typingStats.startedTests += started; + snapshot.typingStats.completedTests++; } setSnapshot(snapshot); @@ -940,7 +926,7 @@ export function setStreak(streak: number): void { // let ret = 0; // try { // ret = dbSnapshot.tags.filter((t) => t.id === tagId)[0].pb; -// if (ret == undefined) { +// if (ret === undefined) { // ret = 0; // } // return ret; @@ -963,7 +949,7 @@ export function setStreak(streak: number): void { // }); // } -// if (dbSnapshot != null) { +// if (dbSnapshot !== null) { // cont(); // } // } From 626262db2883da111a7e9f8495cbefe6d40cb7b6 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 25 Feb 2023 22:11:02 -0600 Subject: [PATCH 20/40] == -> === in result-filters.ts --- frontend/src/ts/account/result-filters.ts | 36 +++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/frontend/src/ts/account/result-filters.ts b/frontend/src/ts/account/result-filters.ts index 356ab40e1..111a22fd8 100644 --- a/frontend/src/ts/account/result-filters.ts +++ b/frontend/src/ts/account/result-filters.ts @@ -1,10 +1,10 @@ -import * as Misc from "../utils/misc"; -import * as DB from "../db"; -import Config from "../config"; -import * as Notifications from "../elements/notifications"; import Ape from "../ape/index"; +import Config from "../config"; +import * as DB from "../db"; import * as Loader from "../elements/loader"; +import * as Notifications from "../elements/notifications"; import { showNewResultFilterPresetPopup } from "../popups/new-result-filter-preset-popup"; +import * as Misc from "../utils/misc"; export const defaultResultFilters: MonkeyTypes.ResultFilters = { _id: "default-result-filters-id", @@ -81,7 +81,7 @@ export async function load(): Promise { try { const newResultFilters = window.localStorage.getItem("resultFilters"); - if (!newResultFilters) { + if (newResultFilters === null) { filters = defaultResultFilters; } else { const newFiltersObject = JSON.parse(newResultFilters); @@ -360,25 +360,25 @@ export function updateActive(): void { function addText(group: MonkeyTypes.Group): string { let ret = ""; ret += "
    "; - if (group == "difficulty") { + if (group === "difficulty") { ret += ``; - } else if (group == "mode") { + } else if (group === "mode") { ret += ``; - } else if (group == "punctuation") { + } else if (group === "punctuation") { ret += ``; - } else if (group == "numbers") { + } else if (group === "numbers") { ret += ``; - } else if (group == "words") { + } else if (group === "words") { ret += ``; - } else if (group == "time") { + } else if (group === "time") { ret += ``; - } else if (group == "date") { + } else if (group === "date") { ret += ``; - } else if (group == "tags") { + } else if (group === "tags") { ret += ``; - } else if (group == "language") { + } else if (group === "language") { ret += ``; - } else if (group == "funbox") { + } else if (group === "funbox") { ret += ``; } if (aboveChartDisplay[group]?.all) { @@ -387,12 +387,12 @@ export function updateActive(): void { if (group === "tags") { ret += aboveChartDisplay.tags?.array ?.map((id) => { - if (id == "none") return id; + if (id === "none") return id; const snapshot = DB.getSnapshot(); if (snapshot === undefined) return id; - const name = snapshot.tags?.filter((t) => t._id == id)[0]; + const name = snapshot.tags.filter((t) => t._id === id)[0]; if (name !== undefined) { - return snapshot.tags?.filter((t) => t._id == id)[0].display; + return snapshot.tags.filter((t) => t._id === id)[0].display; } return name; }) From 8fb2aefb1a4e6527492ae41c5446803b31ccb056 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 25 Feb 2023 22:11:17 -0600 Subject: [PATCH 21/40] == -> === in commandline --- frontend/src/ts/commandline/index.ts | 46 ++++++++++++++-------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/frontend/src/ts/commandline/index.ts b/frontend/src/ts/commandline/index.ts index 2b07462e9..7f35a6f47 100644 --- a/frontend/src/ts/commandline/index.ts +++ b/frontend/src/ts/commandline/index.ts @@ -41,7 +41,7 @@ function showInput( $("#commandInput input").trigger("focus"); $("#commandInput input").attr("command", ""); $("#commandInput input").attr("command", command); - if (inputValue != "") { + if (inputValue !== "") { $("#commandInput input").trigger("select"); } } @@ -121,7 +121,7 @@ function showFound(): void { } }); $("#commandLine .suggestions").html(commandsHTML); - if ($("#commandLine .suggestions .entry").length == 0) { + if ($("#commandLine .suggestions .entry").length === 0) { $("#commandLine .separator").css({ height: 0, margin: 0 }); } else { $("#commandLine .separator").css({ @@ -164,7 +164,7 @@ function updateSuggested(): void { const inputVal = ($("#commandLine input").val() as string) .toLowerCase() .split(" ") - .filter((s, i) => s || i == 0); //remove empty entries after first + .filter((s, i) => s || i === 0); //remove empty entries after first const list = CommandlineLists.current[CommandlineLists.current.length - 1]; if (list.beforeList) list.beforeList(); @@ -181,10 +181,10 @@ function updateSuggested(): void { return; } //ignore the preceeding ">"s in the command line input - if (inputVal[0] && inputVal[0][0] == ">") { + if (inputVal[0] && inputVal[0][0] === ">") { inputVal[0] = inputVal[0].replace(/^>+/, ""); } - if (inputVal[0] == "" && inputVal.length == 1) { + if (inputVal[0] === "" && inputVal.length === 1) { $.each(list.list, (_index, obj) => { if (obj.visible !== false) obj.found = true; }); @@ -192,15 +192,15 @@ function updateSuggested(): void { $.each(list.list, (_index, obj) => { let foundcount = 0; $.each(inputVal, (_index2, obj2) => { - if (obj2 == "") return; + if (obj2 === "") return; const escaped = obj2.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); const re = new RegExp("\\b" + escaped, "g"); const res = obj.display.toLowerCase().match(re); const res2 = obj.alias !== undefined ? obj.alias.toLowerCase().match(re) : null; if ( - (res != null && res.length > 0) || - (res2 != null && res2.length > 0) + (res !== null && res.length > 0) || + (res2 !== null && res2.length > 0) ) { foundcount++; } else { @@ -286,7 +286,7 @@ function trigger(command: string): void { let sticky = false; $.each(list.list, (_index, obj) => { - if (obj.id == command) { + if (obj.id === command) { if (obj.shouldFocusTestUI !== undefined) { shouldFocusTestUI = obj.shouldFocusTestUI; } @@ -411,12 +411,12 @@ function generateSingleListOfCommands(): { function useSingleListCommandLine(sshow = true): void { const allCommands = generateSingleListOfCommands(); - // if (Config.singleListCommandLine == "manual") { + // if (Config.singleListCommandLine === "manual") { // CommandlineLists.pushCurrent(allCommands); - // } else if (Config.singleListCommandLine == "on") { + // } else if (Config.singleListCommandLine === "on") { CommandlineLists.setCurrent([allCommands]); // } - if (Config.singleListCommandLine != "manual") { + if (Config.singleListCommandLine !== "manual") { state["usingSingleList"] = true; $("#commandLine").addClass("allCommands"); } @@ -428,7 +428,7 @@ function restoreOldCommandLine(sshow = true): void { state["usingSingleList"] = false; $("#commandLine").removeClass("allCommands"); CommandlineLists.setCurrent( - CommandlineLists.current.filter((l) => l.title != "All Commands") + CommandlineLists.current.filter((l) => l.title !== "All Commands") ); if (CommandlineLists.current.length < 1) { CommandlineLists.setCurrent([CommandlineLists.commands]); @@ -494,7 +494,7 @@ $(document).ready(() => { if (Config.quickRestart === "esc" && ActivePage.get() === "login") return; event.preventDefault(); - if (Config.singleListCommandLine == "on") { + if (Config.singleListCommandLine === "on") { useSingleListCommandLine(false); } else { CommandlineLists.setCurrent([CommandlineLists.commands]); @@ -512,7 +512,7 @@ $("#commandInput input").on("keydown", (e) => { const value = $("#commandInput input").val() as string; const list = CommandlineLists.current[CommandlineLists.current.length - 1]; $.each(list.list, (_index, obj) => { - if (obj.id == command) { + if (obj.id === command) { if (obj.exec) obj.exec(value); } }); @@ -554,7 +554,7 @@ $("#commandLineWrapper #commandLine .suggestions").on("mouseover", (e) => { try { const list = CommandlineLists.current[CommandlineLists.current.length - 1]; $.each(list.list, (_index, obj) => { - if (obj.id == hoverId) { + if (obj.id === hoverId) { if (/changeTheme.+/gi.test(obj.id)) { removeCommandlineBackground(); } else { @@ -639,11 +639,11 @@ $(document).on("keydown", (e) => { // } if (isPopupVisible(wrapperId)) { $("#commandLine input").trigger("focus"); - if (e.key == ">" && Config.singleListCommandLine == "manual") { + if (e.key === ">" && Config.singleListCommandLine === "manual") { if (!isSingleListCommandLineActive()) { useSingleListCommandLine(false); return; - } else if ($("#commandLine input").val() == ">") { + } else if ($("#commandLine input").val() === ">") { //so that it will ignore succeeding ">" when input is already ">" e.preventDefault(); return; @@ -654,7 +654,7 @@ $(document).on("keydown", (e) => { setTimeout(() => { const inputVal = $("#commandLine input").val() as string; if ( - Config.singleListCommandLine == "manual" && + Config.singleListCommandLine === "manual" && isSingleListCommandLineActive() && inputVal[0] !== ">" ) { @@ -698,7 +698,7 @@ $(document).on("keydown", (e) => { e.key === "k" ) { entries.removeClass("activeKeyboard"); - if (activenum == 0) { + if (activenum === 0) { $(entries[entries.length - 1]).addClass("activeKeyboard"); hoverId = $(entries[entries.length - 1]).attr("command") as string; } else { @@ -713,7 +713,7 @@ $(document).on("keydown", (e) => { e.key === "j" ) { entries.removeClass("activeKeyboard"); - if (activenum + 1 == entries.length) { + if (activenum === entries.length - 1) { $(entries[0]).addClass("activeKeyboard"); hoverId = $(entries[0]).attr("command") as string; } else { @@ -741,7 +741,7 @@ $(document).on("keydown", (e) => { const list = CommandlineLists.current[CommandlineLists.current.length - 1]; $.each(list.list, (_index, obj) => { - if (obj.id == hoverId) { + if (obj.id === hoverId) { if (/changeTheme.+/gi.test(obj.id)) { removeCommandlineBackground(); } else { @@ -768,7 +768,7 @@ $(document).on("keydown", (e) => { }); $("#commandLineMobileButton").on("click", () => { - if (Config.singleListCommandLine == "on") { + if (Config.singleListCommandLine === "on") { useSingleListCommandLine(false); } else { CommandlineLists.setCurrent([CommandlineLists.commands]); From 1de8f916b3fbd5f6a5acb275b8e92ca11f918838 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 25 Feb 2023 22:17:23 -0600 Subject: [PATCH 22/40] add lint rule --- .eslintrc.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.json b/.eslintrc.json index 5be444934..2251b7bb5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -27,6 +27,7 @@ "rules": { "json/*": ["error"], "indent": ["off"], + "eqeqeq": ["error", "always"], "linebreak-style": ["error", "unix"], "curly": ["error", "multi-line"], "quotes": [ From 175acb5ea45d8a840864278b2231f0dd27a26fe1 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 25 Feb 2023 22:17:35 -0600 Subject: [PATCH 23/40] == -> === in bail-out and keymap-layouts --- frontend/src/ts/commandline/lists/bail-out.ts | 6 +++--- frontend/src/ts/commandline/lists/keymap-layouts.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/ts/commandline/lists/bail-out.ts b/frontend/src/ts/commandline/lists/bail-out.ts index cae9134a6..240da2797 100644 --- a/frontend/src/ts/commandline/lists/bail-out.ts +++ b/frontend/src/ts/commandline/lists/bail-out.ts @@ -9,18 +9,18 @@ function canBailOut(): boolean { (Config.mode === "custom" && CustomTextState.isCustomTextLong() === true) || (Config.mode === "custom" && CustomText.isWordRandom && - (CustomText.word >= 5000 || CustomText.word == 0)) || + (CustomText.word >= 5000 || CustomText.word === 0)) || (Config.mode === "custom" && !CustomText.isWordRandom && !CustomText.isTimeRandom && CustomText.text.length >= 5000) || (Config.mode === "custom" && CustomText.isTimeRandom && - (CustomText.time >= 3600 || CustomText.time == 0)) || + (CustomText.time >= 3600 || CustomText.time === 0)) || (Config.mode === "words" && Config.words >= 5000) || Config.words === 0 || (Config.mode === "time" && (Config.time >= 3600 || Config.time === 0)) || - Config.mode == "zen" + Config.mode === "zen" ); } diff --git a/frontend/src/ts/commandline/lists/keymap-layouts.ts b/frontend/src/ts/commandline/lists/keymap-layouts.ts index 5db9a26fd..e877d174d 100644 --- a/frontend/src/ts/commandline/lists/keymap-layouts.ts +++ b/frontend/src/ts/commandline/lists/keymap-layouts.ts @@ -35,7 +35,7 @@ function update(layouts: MonkeyTypes.Layouts): void { }, }); Object.keys(layouts).forEach((layout) => { - if (layout.toString() != "default") { + if (layout.toString() !== "default") { subgroup.list.push({ id: "changeKeymapLayout" + capitalizeFirstLetterOfEachWord(layout), display: layout.replace(/_/g, " "), From b2e67dac31e90963fd3941b061234cf1c9c87800 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 25 Feb 2023 22:22:11 -0600 Subject: [PATCH 24/40] == -> === in account-controller --- .../src/ts/controllers/account-controller.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/frontend/src/ts/controllers/account-controller.ts b/frontend/src/ts/controllers/account-controller.ts index c4c312d87..9d2e50a77 100644 --- a/frontend/src/ts/controllers/account-controller.ts +++ b/frontend/src/ts/controllers/account-controller.ts @@ -103,7 +103,7 @@ export async function getDataAndInit(): Promise { $("#top #menu .account").css("opacity", 1); return false; } - if (ActivePage.get() == "loading") { + if (ActivePage.get() === "loading") { LoadingPage.updateBar(100); } else { LoadingPage.updateBar(45); @@ -165,15 +165,16 @@ export async function getDataAndInit(): Promise { if (configsDifferent) return; try { if (key !== "resultFilters") { - if (Array.isArray(Config[key])) { - (Config[key] as string[]).forEach((arrval, index) => { + const value = Config[key]; + if (Array.isArray(value)) { + value.forEach((arrval, index) => { const arrayValue = ( - snapshot?.config?.[key] as + snapshot.config?.[key] as | string[] | MonkeyTypes.QuoteLength[] | MonkeyTypes.CustomBackgroundFilter )[index]; - if (arrval != arrayValue) { + if (arrval !== arrayValue) { configsDifferent = true; console.log( `.config is different: ${arrval} != ${arrayValue}` @@ -181,10 +182,10 @@ export async function getDataAndInit(): Promise { } }); } else { - if (Config[key] != snapshot?.config?.[key]) { + if (value !== snapshot.config?.[key]) { configsDifferent = true; console.log( - `..config is different ${key}: ${Config[key]} != ${snapshot?.config?.[key]}` + `..config is different ${key}: ${Config[key]} != ${snapshot.config?.[key]}` ); } } @@ -201,7 +202,7 @@ export async function getDataAndInit(): Promise { UpdateConfig.apply(snapshot.config); Settings.update(); UpdateConfig.saveFullConfigToLocalStorage(true); - if (ActivePage.get() == "test") { + if (ActivePage.get() === "test") { TestLogic.restart({ nosave: true, }); @@ -295,7 +296,7 @@ if (Auth && ConnectionState.get()) { await loadUser(user); } else { $("#top .signInOut .icon").html(``); - if (window.location.pathname == "/account") { + if (window.location.pathname === "/account") { window.history.replaceState("", "", "/login"); } PageTransition.set(false); @@ -330,7 +331,7 @@ if (Auth && ConnectionState.get()) { const search = window.location.search; const hash = window.location.hash; $("#top .signInOut .icon").html(``); - if (window.location.pathname == "/account") { + if (window.location.pathname === "/account") { window.history.replaceState("", "", "/login"); } PageTransition.set(false); From 9c94257755735a2ce333b0749a1541bc43a5c1fd Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 25 Feb 2023 22:29:12 -0600 Subject: [PATCH 25/40] == -> === in ad and challenge controllers --- frontend/src/ts/controllers/ad-controller.ts | 8 +- .../ts/controllers/challenge-controller.ts | 73 +++++++++++-------- 2 files changed, 46 insertions(+), 35 deletions(-) diff --git a/frontend/src/ts/controllers/ad-controller.ts b/frontend/src/ts/controllers/ad-controller.ts index 7d6eff727..6eaafc062 100644 --- a/frontend/src/ts/controllers/ad-controller.ts +++ b/frontend/src/ts/controllers/ad-controller.ts @@ -104,7 +104,7 @@ export async function refreshVisible(): Promise { if (!el) continue; const elParent = el.parentElement as HTMLElement; if ( - window.getComputedStyle(elParent).getPropertyValue("display") != "none" + window.getComputedStyle(elParent).getPropertyValue("display") !== "none" ) { visibleAdDivs.push(adDivs[i]); } @@ -276,12 +276,12 @@ $(window).on("resize", () => { ConfigEvent.subscribe((event, value) => { if (event === "ads") { - if (value == "off") { + if (value === "off") { removeAll(); - } else if (value == "result") { + } else if (value === "result") { removeSellout(); removeOn(); - } else if (value == "on") { + } else if (value === "on") { removeSellout(); } } diff --git a/frontend/src/ts/controllers/challenge-controller.ts b/frontend/src/ts/controllers/challenge-controller.ts index fef304e21..cc943357d 100644 --- a/frontend/src/ts/controllers/challenge-controller.ts +++ b/frontend/src/ts/controllers/challenge-controller.ts @@ -44,66 +44,69 @@ export function verify( let requirementsMet = true; const failReasons = []; for (const requirementType in TestState.activeChallenge.requirements) { - if (requirementsMet == false) return null; + if (!requirementsMet) return null; const requirementValue = TestState.activeChallenge.requirements[ requirementType as keyof typeof TestState.activeChallenge.requirements ]; - if (requirementType == "wpm") { + if (requirementType === "wpm") { const wpmMode = Object.keys(requirementValue)[0]; - if (wpmMode == "exact") { - if (Math.round(result.wpm) != requirementValue["exact"]) { + if (wpmMode === "exact") { + if (Math.round(result.wpm) !== requirementValue["exact"]) { requirementsMet = false; failReasons.push(`WPM not ${requirementValue["exact"]}`); } - } else if (wpmMode == "min") { - if (result.wpm < requirementValue["min"]) { + } else if (wpmMode === "min") { + if (result.wpm < requirementValue["min"]) { requirementsMet = false; failReasons.push(`WPM below ${requirementValue["min"]}`); } } - } else if (requirementType == "acc") { + } else if (requirementType === "acc") { const accMode = Object.keys(requirementValue)[0]; - if (accMode == "exact") { - if (result.acc != requirementValue["exact"]) { + if (accMode === "exact") { + if (result.acc !== requirementValue["exact"]) { requirementsMet = false; failReasons.push(`Accuracy not ${requirementValue["exact"]}`); } - } else if (accMode == "min") { - if (result.acc < requirementValue["min"]) { + } else if (accMode === "min") { + if (result.acc < requirementValue["min"]) { requirementsMet = false; failReasons.push(`Accuracy below ${requirementValue["min"]}`); } } - } else if (requirementType == "afk") { + } else if (requirementType === "afk") { const afkMode = Object.keys(requirementValue)[0]; - if (afkMode == "max") { - if (Math.round(afk) > requirementValue["max"]) { + if (afkMode === "max") { + if (Math.round(afk) > requirementValue["max"]) { requirementsMet = false; failReasons.push( `AFK percentage above ${requirementValue["max"]}` ); } } - } else if (requirementType == "time") { + } else if (requirementType === "time") { const timeMode = Object.keys(requirementValue)[0]; - if (timeMode == "min") { - if (Math.round(result.testDuration) < requirementValue["min"]) { + if (timeMode === "min") { + if ( + Math.round(result.testDuration) < + requirementValue["min"] + ) { requirementsMet = false; failReasons.push(`Test time below ${requirementValue["min"]}`); } } - } else if (requirementType == "funbox") { + } else if (requirementType === "funbox") { const funboxMode = requirementValue["exact"] .toString() .split("#") .sort() .join("#"); - if (funboxMode != result.funbox) { + if (funboxMode !== result.funbox) { requirementsMet = false; for (const f of funboxMode.split("#")) { if ( - result.funbox?.split("#").find((rf) => rf == f) == undefined + result.funbox?.split("#").find((rf) => rf === f) === undefined ) { failReasons.push(`${f} funbox not active`); } @@ -111,36 +114,38 @@ export function verify( if (result.funbox?.split("#")) { for (const f of result.funbox.split("#")) { if ( - funboxMode.split("#").find((rf) => rf == f) == undefined + funboxMode.split("#").find((rf) => rf === f) === undefined ) { failReasons.push(`${f} funbox active`); } } } } - } else if (requirementType == "raw") { + } else if (requirementType === "raw") { const rawMode = Object.keys(requirementValue)[0]; - if (rawMode == "exact") { - if (Math.round(result.rawWpm) != requirementValue["exact"]) { + if (rawMode === "exact") { + if (Math.round(result.rawWpm) !== requirementValue["exact"]) { requirementsMet = false; failReasons.push(`Raw WPM not ${requirementValue["exact"]}`); } } - } else if (requirementType == "con") { + } else if (requirementType === "con") { const conMode = Object.keys(requirementValue)[0]; - if (conMode == "exact") { - if (Math.round(result.consistency) != requirementValue["exact"]) { + if (conMode === "exact") { + if ( + Math.round(result.consistency) !== requirementValue["exact"] + ) { requirementsMet = false; failReasons.push( `Consistency not ${requirementValue["exact"]}` ); } } - } else if (requirementType == "config") { + } else if (requirementType === "config") { for (const configKey in requirementValue) { const configValue = requirementValue[configKey]; if ( - Config[configKey as keyof MonkeyTypes.Config] != configValue + Config[configKey as keyof MonkeyTypes.Config] !== configValue ) { requirementsMet = false; failReasons.push(`${configKey} not set to ${configValue}`); @@ -253,10 +258,16 @@ export async function setup(challengeName: string): Promise { CustomText.setWord(-1); UpdateConfig.setMode("custom", true); UpdateConfig.setDifficulty("normal", true); - if (challenge.parameters[1] != null) { + if ( + challenge.parameters[1] !== null && + challenge.parameters[1] !== undefined + ) { UpdateConfig.setTheme(challenge.parameters[1] as string); } - if (challenge.parameters[2] != null) { + if ( + challenge.parameters[2] !== null && + challenge.parameters[2] !== undefined + ) { Funbox.activate(challenge.parameters[2]); } } else if (challenge.type === "accuracy") { From 68da5945e60abae59676dc705780363ce856d164 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 25 Feb 2023 22:34:13 -0600 Subject: [PATCH 26/40] == -> === in chart-controller --- .../src/ts/controllers/chart-controller.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/frontend/src/ts/controllers/chart-controller.ts b/frontend/src/ts/controllers/chart-controller.ts index 4c2ed84bf..70c3649ee 100644 --- a/frontend/src/ts/controllers/chart-controller.ts +++ b/frontend/src/ts/controllers/chart-controller.ts @@ -125,12 +125,12 @@ export const result: ChartWithUpdateColors< pointStyle: "crossRot", pointRadius: function (context): number { const index = context.dataIndex; - const value = context.dataset.data[index]; + const value = context.dataset.data[index] as number; return (value ?? 0) <= 0 ? 0 : 3; }, pointHoverRadius: function (context): number { const index = context.dataIndex; - const value = context.dataset.data[index]; + const value = context.dataset.data[index] as number; return (value ?? 0) <= 0 ? 0 : 5; }, }, @@ -227,7 +227,7 @@ export const result: ChartWithUpdateColors< $("#resultWordsHistory .words .word")[wordIndex] ); const input = wordEl.attr("input"); - if (input != undefined) { + if (input !== undefined) { wordEl.append( `
    ${input .replace(/\t/g, "_") @@ -366,16 +366,14 @@ export const accountHistory: ChartWithUpdateColors< "\n\n" + `mode: ${resultData.mode} `; - if (resultData.mode == "time") { + if (resultData.mode === "time") { label += resultData.mode2; - } else if (resultData.mode == "words") { + } else if (resultData.mode === "words") { label += resultData.mode2; } - let diff = resultData.difficulty; - if (diff == undefined) { - diff = "normal"; - } + const diff = resultData.difficulty ?? "normal"; + label += "\n" + `difficulty: ${diff}`; label += @@ -842,7 +840,7 @@ function updateAccuracy(): void { } function updateStyle(): void { - if (Config.chartStyle == "scatter") { + if (Config.chartStyle === "scatter") { accountHistory.data.datasets[0].showLine = false; accountHistory.data.datasets[1].showLine = false; } else { From 2224eefc7c5c33a99c9b57fcb33d2c03bbea48df Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 26 Feb 2023 09:35:44 -0600 Subject: [PATCH 27/40] check if window.egAdPack exists --- frontend/src/ts/controllers/ad-controller.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/src/ts/controllers/ad-controller.ts b/frontend/src/ts/controllers/ad-controller.ts index 6eaafc062..00fd286e5 100644 --- a/frontend/src/ts/controllers/ad-controller.ts +++ b/frontend/src/ts/controllers/ad-controller.ts @@ -93,6 +93,9 @@ function updateBreakpoint(noReinstate = false): void { } export async function refreshVisible(): Promise { + //@ts-ignore + if (window.egAdPack === undefined) return; + //@ts-ignore const adDivs = Object.keys(window.egAdPack.gptAdSlots); const visibleAdDivs = []; From 44cb85265cf969cee25b71ed22aaf50e8375976f Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 26 Feb 2023 09:38:57 -0600 Subject: [PATCH 28/40] == -> === in input-controller --- .../src/ts/controllers/input-controller.ts | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index b524a0927..305d4b333 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -110,7 +110,7 @@ function backspaceToPrevious(): void { } if ( - (TestInput.input.history[TestWords.words.currentIndex - 1] == + (TestInput.input.history[TestWords.words.currentIndex - 1] === TestWords.words.get(TestWords.words.currentIndex - 1) && !Config.freedomMode) || $($(".word")[TestWords.words.currentIndex - 1]).hasClass("hidden") @@ -145,7 +145,7 @@ function handleSpace(): void { if (TestInput.input.current === "") return; - if (Config.mode == "zen") { + if (Config.mode === "zen") { $("#words .word.active").removeClass("active"); $("#words").append("
    "); } @@ -172,7 +172,7 @@ function handleSpace(): void { //correct word or in zen mode const isWordCorrect: boolean = - currentWord === TestInput.input.current || Config.mode == "zen"; + currentWord === TestInput.input.current || Config.mode === "zen"; MonkeyPower.addPower(isWordCorrect, true); TestInput.incrementAccuracy(isWordCorrect); if (isWordCorrect) { @@ -210,13 +210,13 @@ function handleSpace(): void { TestInput.corrected.current.substring(cil + 1); } } - if (Config.stopOnError != "off") { - if (Config.difficulty == "expert" || Config.difficulty == "master") { + if (Config.stopOnError !== "off") { + if (Config.difficulty === "expert" || Config.difficulty === "master") { //failed due to diff when pressing space TestLogic.fail("difficulty"); return; } - if (Config.stopOnError == "word") { + if (Config.stopOnError === "word") { dontInsertSpace = false; Replay.addReplayEvent("incorrectLetter", "_"); TestUI.updateWordElement(true); @@ -238,7 +238,7 @@ function handleSpace(): void { TestInput.incrementKeypressCount(); TestInput.pushKeypressWord(TestWords.words.currentIndex); TestInput.updateLastKeypress(); - if (Config.difficulty == "expert" || Config.difficulty == "master") { + if (Config.difficulty === "expert" || Config.difficulty === "master") { TestLogic.fail("difficulty"); return; } else if (TestWords.words.currentIndex === TestWords.words.length) { @@ -269,7 +269,7 @@ function handleSpace(): void { if ( !Config.showAllLines || - Config.mode == "time" || + Config.mode === "time" || (CustomText.isWordRandom && CustomText.word === 0) || CustomText.isTimeRandom ) { @@ -306,10 +306,10 @@ function handleSpace(): void { TimerProgress.update(); } if ( - Config.mode == "time" || - Config.mode == "words" || - Config.mode == "custom" || - Config.mode == "quote" + Config.mode === "time" || + Config.mode === "words" || + Config.mode === "custom" || + Config.mode === "quote" ) { TestLogic.addWord(); } @@ -318,7 +318,7 @@ function handleSpace(): void { function isCharCorrect(char: string, charIndex: number): boolean { if (!correctShiftUsed) return false; - if (Config.mode == "zen") { + if (Config.mode === "zen") { return true; } @@ -366,7 +366,7 @@ function isCharCorrect(char: string, charIndex: number): boolean { } if ( - (char === `"` || char === "”" || char == "“" || char === "„") && + (char === `"` || char === "”" || char === "“" || char === "„") && (originalChar === `"` || originalChar === "”" || originalChar === "“" || @@ -523,7 +523,7 @@ function handleChar( KeymapEvent.flash(char, thisCharCorrect); } - if (!correctShiftUsed && Config.difficulty != "master") return; + if (!correctShiftUsed && Config.difficulty !== "master") return; //update current corrected version. if its empty then add the current char. if its not then replace the last character with the currently pressed one / add it if (TestInput.corrected.current === "") { @@ -553,7 +553,7 @@ function handleChar( if ( Config.difficulty !== "master" && - Config.stopOnError == "letter" && + Config.stopOnError === "letter" && !thisCharCorrect ) { return; @@ -583,12 +583,12 @@ function handleChar( TestInput.input.current = resultingWord; } - if (!thisCharCorrect && Config.difficulty == "master") { + if (!thisCharCorrect && Config.difficulty === "master") { TestLogic.fail("difficulty"); return; } - if (Config.mode != "zen") { + if (Config.mode !== "zen") { //not applicable to zen mode //auto stop the test if the last word is correct const currentWord: string = TestWords.words.getCurrent(); @@ -598,7 +598,7 @@ function handleChar( (Config.quickEnd && !Config.language.startsWith("korean") && currentWord.length === TestInput.input.current.length && - Config.stopOnError == "off")) && + Config.stopOnError === "off")) && lastIndex === TestWords.words.length - 1 ) { TestLogic.finish(); @@ -621,7 +621,7 @@ function handleChar( !TestUI.lineTransition && TestInput.input.current.length > 1 ) { - if (Config.mode == "zen") { + if (Config.mode === "zen") { const currentTop = Math.floor( document.querySelectorAll("#words .word")[ TestUI.currentWordElementIndex - 1 @@ -679,7 +679,7 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void { let shouldInsertTabCharacter = false; if ( - (Config.mode == "zen" && !event.shiftKey) || + (Config.mode === "zen" && !event.shiftKey) || (TestWords.hasTab && !event.shiftKey) ) { shouldInsertTabCharacter = true; @@ -754,7 +754,7 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void { } $(document).keydown(async (event) => { - if (ActivePage.get() == "loading") return; + if (ActivePage.get() === "loading") return; if (IgnoredKeys.includes(event.key)) return; @@ -786,7 +786,7 @@ $(document).keydown(async (event) => { } //tab - if (event.key == "Tab") { + if (event.key === "Tab") { handleTab(event, popupVisible); } @@ -866,7 +866,7 @@ $(document).keydown(async (event) => { if (event.key === "Enter") { if (event.shiftKey) { - if (Config.mode == "zen") { + if (Config.mode === "zen") { TestLogic.finish(); } else if ( !Misc.canQuickRestart( @@ -986,7 +986,7 @@ $("#wordsInput").on("input", (event) => { TestInput.setKeypressNotAfk(); if ( - (Config.layout == "default" || Config.layout == "korean") && + (Config.layout === "default" || Config.layout === "korean") && (event.target as HTMLInputElement).value .normalize() .match( From ec9f73eeee94c7438b553027d49d30d28a5d3222 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 26 Feb 2023 09:41:32 -0600 Subject: [PATCH 29/40] == -> === in a few more files --- frontend/src/ts/controllers/preset-controller.ts | 2 +- frontend/src/ts/controllers/tag-controller.ts | 2 +- frontend/src/ts/controllers/theme-controller.ts | 4 ++-- frontend/src/ts/elements/account-button.ts | 2 +- frontend/src/ts/elements/alerts.ts | 6 +++--- frontend/src/ts/elements/custom-background-filter.ts | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/ts/controllers/preset-controller.ts b/frontend/src/ts/controllers/preset-controller.ts index ef7c5e8e2..0fa200634 100644 --- a/frontend/src/ts/controllers/preset-controller.ts +++ b/frontend/src/ts/controllers/preset-controller.ts @@ -9,7 +9,7 @@ export function apply(_id: string): void { const snapshot = DB.getSnapshot(); if (!snapshot) return; snapshot.presets?.forEach((preset) => { - if (preset._id == _id) { + if (preset._id === _id) { UpdateConfig.apply(preset.config); TagController.clear(true); if (preset.config.tags) { diff --git a/frontend/src/ts/controllers/tag-controller.ts b/frontend/src/ts/controllers/tag-controller.ts index 310a86b07..c286c0b93 100644 --- a/frontend/src/ts/controllers/tag-controller.ts +++ b/frontend/src/ts/controllers/tag-controller.ts @@ -64,7 +64,7 @@ export function loadActiveFromLocalStorage(): void { let newTags: string[] | string = window.localStorage.getItem( "activeTags" ) as string; - if (newTags != undefined && newTags !== "") { + if (newTags !== undefined && newTags !== "") { try { newTags = JSON.parse(newTags) ?? []; } catch (e) { diff --git a/frontend/src/ts/controllers/theme-controller.ts b/frontend/src/ts/controllers/theme-controller.ts index f9cc9912c..6086632ec 100644 --- a/frontend/src/ts/controllers/theme-controller.ts +++ b/frontend/src/ts/controllers/theme-controller.ts @@ -37,7 +37,7 @@ async function updateFavicon(size: number, curveSize: number): Promise { maincolor = bgcolor; bgcolor = swap; } - if (bgcolor == maincolor) { + if (bgcolor === maincolor) { bgcolor = "#111"; maincolor = "#eee"; } @@ -371,7 +371,7 @@ export function clearRandom(): void { } export function applyCustomBackgroundSize(): void { - if (Config.customBackgroundSize == "max") { + if (Config.customBackgroundSize === "max") { $(".customBackground img").css({ // width: "calc(100%)", // height: "calc(100%)", diff --git a/frontend/src/ts/elements/account-button.ts b/frontend/src/ts/elements/account-button.ts index 049cafc7a..b23f6d53e 100644 --- a/frontend/src/ts/elements/account-button.ts +++ b/frontend/src/ts/elements/account-button.ts @@ -368,7 +368,7 @@ async function animateXpBar( barEl.css("width", `${(startingLevel % 1) * 100}%`); - if (endingLevel % 1 == 0) { + if (endingLevel % 1 === 0) { await Misc.promiseAnimation( barEl, { diff --git a/frontend/src/ts/elements/alerts.ts b/frontend/src/ts/elements/alerts.ts index 185100b47..fc0eb7afc 100644 --- a/frontend/src/ts/elements/alerts.ts +++ b/frontend/src/ts/elements/alerts.ts @@ -216,7 +216,7 @@ async function getAccountAlerts(): Promise { $("#alertsPopup .accountAlerts .list").empty(); for (const ie of accountAlerts) { - if (!ie.read && ie.rewards.length == 0) { + if (!ie.read && ie.rewards.length === 0) { mailToMarkRead.push(ie.id); } @@ -248,7 +248,7 @@ async function getAccountAlerts(): Promise { } ${ (ie.rewards.length > 0 && ie.read === true) || - ie.rewards.length == 0 + ie.rewards.length === 0 ? `
    ` : `` } @@ -350,7 +350,7 @@ function updateInboxSize(): void { function deleteAlert(id: string): void { mailToDelete.push(id); $(`#alertsPopup .accountAlerts .list .item[data-id="${id}"]`).remove(); - if ($("#alertsPopup .accountAlerts .list .item").length == 0) { + if ($("#alertsPopup .accountAlerts .list .item").length === 0) { $("#alertsPopup .accountAlerts .list").html(`
    Nothing to show diff --git a/frontend/src/ts/elements/custom-background-filter.ts b/frontend/src/ts/elements/custom-background-filter.ts index 49e94dfb1..42cbeedae 100644 --- a/frontend/src/ts/elements/custom-background-filter.ts +++ b/frontend/src/ts/elements/custom-background-filter.ts @@ -25,9 +25,9 @@ export function getCSS(): string { let ret = ""; Object.keys(filters).forEach((filterKey) => { const key = filterKey as keyof typeof filters; - if (filters[key].value != filters[key].default) { + if (filters[key].value !== filters[key].default) { ret += `${filterKey}(${filters[key].value}${ - filterKey == "blur" ? "rem" : "" + filterKey === "blur" ? "rem" : "" }) `; } }); From bf4bfb07c2e6b9a452907ad68e9bd08e50ceb38e Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 26 Feb 2023 09:45:53 -0600 Subject: [PATCH 30/40] == -> === in a few more files --- frontend/src/ts/elements/keymap.ts | 12 ++++++------ frontend/src/ts/elements/leaderboards.ts | 4 ++-- frontend/src/ts/elements/modes-notice.ts | 2 +- frontend/src/ts/elements/notifications.ts | 6 +++--- frontend/src/ts/elements/profile.ts | 2 +- frontend/src/ts/elements/psa.ts | 2 +- frontend/src/ts/elements/scroll-to-top.ts | 4 ++-- frontend/src/ts/pages/about.ts | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/frontend/src/ts/elements/keymap.ts b/frontend/src/ts/elements/keymap.ts index 76128b2f2..b573ce074 100644 --- a/frontend/src/ts/elements/keymap.ts +++ b/frontend/src/ts/elements/keymap.ts @@ -12,7 +12,7 @@ function highlightKey(currentKey: string): void { if (Config.mode === "zen") return; if (currentKey === "") currentKey = " "; try { - if ($(".activeKey") != undefined) { + if ($(".activeKey") !== undefined) { $(".activeKey").removeClass("activeKey"); } @@ -20,9 +20,9 @@ function highlightKey(currentKey: string): void { if (Config.language.startsWith("korean")) { currentKey = Hangul.disassemble(currentKey)[0]; } - if (currentKey == " ") { + if (currentKey === " ") { highlightKey = "#keymap .keySpace, #keymap .keySplitSpace"; - } else if (currentKey == '"') { + } else if (currentKey === '"') { highlightKey = `#keymap .keymapKey[data-key*='${currentKey}']`; } else { highlightKey = `#keymap .keymapKey[data-key*="${currentKey}"]`; @@ -39,11 +39,11 @@ function highlightKey(currentKey: string): void { } async function flashKey(key: string, correct?: boolean): Promise { - if (key == undefined) return; + if (key === undefined) return; //console.log("key", key); - if (key == " ") { + if (key === " ") { key = "#keymap .keySpace, #keymap .keySplitSpace"; - } else if (key == '"') { + } else if (key === '"') { key = `#keymap .keymapKey[data-key*='${key}']`; } else { key = `#keymap .keymapKey[data-key*="${key}"]`; diff --git a/frontend/src/ts/elements/leaderboards.ts b/frontend/src/ts/elements/leaderboards.ts index d5f4f2bf5..b46f8744b 100644 --- a/frontend/src/ts/elements/leaderboards.ts +++ b/frontend/src/ts/elements/leaderboards.ts @@ -170,7 +170,7 @@ function updateFooter(lb: LbKey): void { const num = Misc.roundTo2( (currentRank[lb]["rank"] / (currentRank[lb].count as number)) * 100 ); - if (currentRank[lb]["rank"] == 1) { + if (currentRank[lb]["rank"] === 1) { toppercent = "GOAT"; } else { toppercent = `Top ${num}%`; @@ -313,7 +313,7 @@ async function fillTable(lb: LbKey, prepend?: number): Promise { } if (entry.hidden) return; let meClassString = ""; - if (entry.name == loggedInUserName) { + if (entry.name === loggedInUserName) { meClassString = ' class="me"'; } const date = new Date(entry.timestamp); diff --git a/frontend/src/ts/elements/modes-notice.ts b/frontend/src/ts/elements/modes-notice.ts index 17501dbae..2a766a034 100644 --- a/frontend/src/ts/elements/modes-notice.ts +++ b/frontend/src/ts/elements/modes-notice.ts @@ -199,7 +199,7 @@ export async function update(): Promise { ); } - if (Config.stopOnError != "off") { + if (Config.stopOnError !== "off") { $(".pageTest #testModesNotice").append( `
    stop on ${Config.stopOnError}
    ` ); diff --git a/frontend/src/ts/elements/notifications.ts b/frontend/src/ts/elements/notifications.ts index 1d8e32a50..2c166da79 100644 --- a/frontend/src/ts/elements/notifications.ts +++ b/frontend/src/ts/elements/notifications.ts @@ -41,7 +41,7 @@ class Notification { if (type === "banner") { this.duration = duration as number; } else { - if (duration == undefined) { + if (duration === undefined) { if (level === -1) { this.duration = 0; } else { @@ -75,7 +75,7 @@ class Notification { console.error(this.message); } - if (this.customTitle != undefined) { + if (this.customTitle !== undefined) { title = this.customTitle; } @@ -83,7 +83,7 @@ class Notification { icon = ``; } - if (this.customIcon != undefined) { + if (this.customIcon !== undefined) { icon = ``; } diff --git a/frontend/src/ts/elements/profile.ts b/frontend/src/ts/elements/profile.ts index e192f6303..3c7d920f6 100644 --- a/frontend/src/ts/elements/profile.ts +++ b/frontend/src/ts/elements/profile.ts @@ -90,7 +90,7 @@ export async function update( const joinedText = "Joined " + format(profile.addedAt ?? 0, "dd MMM yyyy"); const creationDate = new Date(profile.addedAt); const diffDays = differenceInDays(new Date(), creationDate); - const balloonText = `${diffDays} day${diffDays != 1 ? "s" : ""} ago`; + const balloonText = `${diffDays} day${diffDays !== 1 ? "s" : ""} ago`; details.find(".joined").text(joinedText).attr("aria-label", balloonText); if (profile.streak && profile?.streak > 1) { diff --git a/frontend/src/ts/elements/psa.ts b/frontend/src/ts/elements/psa.ts index 7309597fe..d9c7f0b9b 100644 --- a/frontend/src/ts/elements/psa.ts +++ b/frontend/src/ts/elements/psa.ts @@ -59,7 +59,7 @@ async function getLatest(): Promise { export async function show(): Promise { const latest = await getLatest(); if (latest === null) return; - if (latest.length == 0) { + if (latest.length === 0) { clearMemory(); return; } diff --git a/frontend/src/ts/elements/scroll-to-top.ts b/frontend/src/ts/elements/scroll-to-top.ts index fa3f7866d..715dd8922 100644 --- a/frontend/src/ts/elements/scroll-to-top.ts +++ b/frontend/src/ts/elements/scroll-to-top.ts @@ -8,8 +8,8 @@ $(".scrollToTopButton").on("click", () => { $(window).scroll(() => { const page = ActivePage.get(); - if (page == "test") return; - if (page == "about" || page == "settings" || page == "account") { + if (page === "test") return; + if (page === "about" || page === "settings" || page === "account") { const scroll = window.scrollY; if (!visible && scroll > 100) { $(".scrollToTopButton").removeClass("invisible"); diff --git a/frontend/src/ts/pages/about.ts b/frontend/src/ts/pages/about.ts index 162e3b825..8c1972205 100644 --- a/frontend/src/ts/pages/about.ts +++ b/frontend/src/ts/pages/about.ts @@ -160,7 +160,7 @@ function getHistogramDataBucketed(data: Record): { y: data[bucket], }); labels.push(`${bucket} - ${bucket + 9}`); - if (bucket + 10 != parseInt(keys[i + 1], 10)) { + if (bucket + 10 !== parseInt(keys[i + 1], 10)) { for (let j = bucket + 10; j < parseInt(keys[i + 1], 10); j += 10) { histogramChartDataBucketed.push({ x: j, y: 0 }); labels.push(`${j} - ${j + 9}`); From 651dc85470830bc1eddcc77ba51c8565aee7b788 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 26 Feb 2023 09:50:31 -0600 Subject: [PATCH 31/40] == -> === in a few more files --- frontend/src/ts/pages/settings.ts | 8 ++++---- frontend/src/ts/popups/custom-test-duration-popup.ts | 6 +++--- frontend/src/ts/popups/custom-text-popup.ts | 2 +- frontend/src/ts/popups/custom-word-amount-popup.ts | 4 ++-- frontend/src/ts/popups/google-sign-up-popup.ts | 4 ++-- frontend/src/ts/popups/mobile-test-config-popup.ts | 8 ++++---- frontend/src/ts/popups/quote-rate-popup.ts | 8 ++++---- frontend/src/ts/popups/quote-search-popup.ts | 5 +++-- frontend/src/ts/popups/result-tags-popup.ts | 4 ++-- 9 files changed, 25 insertions(+), 24 deletions(-) diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts index 2ebc5babc..adea85d07 100644 --- a/frontend/src/ts/pages/settings.ts +++ b/frontend/src/ts/pages/settings.ts @@ -474,7 +474,7 @@ export async function fillSettingsPage(): Promise { " " )}`; } - if (layout.toString() != "default") { + if (layout.toString() !== "default") { keymapElHTML += `