From 24e47f3b9c461f48ca807138f832ed45a4d48905 Mon Sep 17 00:00:00 2001 From: alegottu <33403572+alegottu@users.noreply.github.com> Date: Mon, 5 Oct 2020 14:26:37 -0700 Subject: [PATCH 01/57] pastel theme pretty pale colors --- public/themes/list.json | 5 +++++ public/themes/pastel.css | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 public/themes/pastel.css diff --git a/public/themes/list.json b/public/themes/list.json index 993e04d22..99f7d5c0e 100644 --- a/public/themes/list.json +++ b/public/themes/list.json @@ -388,5 +388,10 @@ "name": "nebula", "bgColor": "#212135", "textColor": "#be3c88" + }, + { + "name": "pastel", + "bgColor": "#ffd1dc", + "textColor": "#b39eb5" } ] diff --git a/public/themes/pastel.css b/public/themes/pastel.css new file mode 100644 index 000000000..29468ac14 --- /dev/null +++ b/public/themes/pastel.css @@ -0,0 +1,11 @@ +:root { + --bg-color: #ffd1dc; + --main-color: #f4f1d6; + --caret-color: #f4f1d6; + --sub-color: #ace7ff; + --text-color: #b39eb5; + --error-color: #ff6961; + --error-extra-color: #c23b22; + --colorful-error-color: #ff6961; + --colorful-error-extra-color: #c23b22; + } \ No newline at end of file From a5ff83803dca57bdbf612c2a4c9d881a25f28a76 Mon Sep 17 00:00:00 2001 From: willerbee Date: Wed, 7 Oct 2020 07:28:20 +0800 Subject: [PATCH 02/57] Fix for typo getting cut off at the bottom lines https://discordapp.com/channels/713194177403420752/713195115275091969/762797016346132510 --- public/css/style.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/public/css/style.scss b/public/css/style.scss index eb959919f..778e2cb46 100644 --- a/public/css/style.scss +++ b/public/css/style.scss @@ -1470,6 +1470,7 @@ key { width: 100%; align-content: flex-start; user-select: none; + padding-bottom: 1em; /* a little hack for right-to-left languages */ &.rightToLeftTest { From c93ac6a7e1f7a389f13fab9c5a666b77e4806dd2 Mon Sep 17 00:00:00 2001 From: Eric <9125358+elswenson@users.noreply.github.com> Date: Thu, 8 Oct 2020 23:36:31 -0700 Subject: [PATCH 03/57] Lil' Dragon Theme https://geekhack.org/index.php?topic=108950.0 --- public/themes/lil_dragon.css | 15 +++++++++++++++ public/themes/list.json | 5 +++++ 2 files changed, 20 insertions(+) create mode 100644 public/themes/lil_dragon.css diff --git a/public/themes/lil_dragon.css b/public/themes/lil_dragon.css new file mode 100644 index 000000000..631ca2cfe --- /dev/null +++ b/public/themes/lil_dragon.css @@ -0,0 +1,15 @@ +:root { + --bg-color: #ebe1ef; + --main-color: #8a5bd6; + --caret-color: #212b43; + --sub-color: #ac76e5; + --text-color: #8a5bd6; + --error-color: #f794ca; + --error-extra-color: #f279c2; + --colorful-error-color: #f794ca; + --colorful-error-extra-color: #f279c2; +} + +#menu .icon-button { + color: #ba96db; +} diff --git a/public/themes/list.json b/public/themes/list.json index 993e04d22..e0d601595 100644 --- a/public/themes/list.json +++ b/public/themes/list.json @@ -388,5 +388,10 @@ "name": "nebula", "bgColor": "#212135", "textColor": "#be3c88" + }, + { + "name": "lil_dragon", + "bgColor": "#ebe1ef", + "textColor": "#8a5bd6" } ] From c46616de711eb5e42b4258bc17393c64e9bb2a1e Mon Sep 17 00:00:00 2001 From: Eric <9125358+elswenson@users.noreply.github.com> Date: Thu, 8 Oct 2020 23:58:49 -0700 Subject: [PATCH 04/57] Add Button Hover Add button hover color --- public/themes/lil_dragon.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/themes/lil_dragon.css b/public/themes/lil_dragon.css index 631ca2cfe..05c3f5c2a 100644 --- a/public/themes/lil_dragon.css +++ b/public/themes/lil_dragon.css @@ -13,3 +13,7 @@ #menu .icon-button { color: #ba96db; } + +#menu .icon-button:hover { + color: #212b43; +} From a1f348e1cbeddd8e160890f748ea3d729d6a0780 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 9 Oct 2020 15:17:14 +0100 Subject: [PATCH 05/57] keeping the text color close to black and white --- public/themes/lil_dragon.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/themes/lil_dragon.css b/public/themes/lil_dragon.css index 05c3f5c2a..d1ef7222d 100644 --- a/public/themes/lil_dragon.css +++ b/public/themes/lil_dragon.css @@ -3,7 +3,7 @@ --main-color: #8a5bd6; --caret-color: #212b43; --sub-color: #ac76e5; - --text-color: #8a5bd6; + --text-color: #212b43; --error-color: #f794ca; --error-extra-color: #f279c2; --colorful-error-color: #f794ca; From b4bc5f4aaee38d7b78200eedec6bfa8c8a9b7d81 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 9 Oct 2020 15:23:59 +0100 Subject: [PATCH 06/57] removed duplicate quote --- public/js/english_quotes.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/public/js/english_quotes.json b/public/js/english_quotes.json index 83ab0160e..d6dbab845 100644 --- a/public/js/english_quotes.json +++ b/public/js/english_quotes.json @@ -27168,12 +27168,6 @@ "id": 4573, "length": 262 }, - { - "text": "I've flown seven million miles. And I've been waiting on people almost 20 years. The best job I could get after my bust was Cabo Air, which is the worst job you can get in this industry. And now with this arrest hanging over my head, I'm scared. If I lose my job I gotta start all over again, but I got nothing to start over with.", - "source": "Jackie Brown", - "id": 4574, - "length": 330 - }, { "text": "Raindrops on roses and whiskers on kittens, bright copper kettles and warm woolen mittens, brown paper packages tied up with strings, these are a few of my favorite things. Cream-colored ponies and crisp apple strudels, doorbells and sleigh bells and schnitzel with noodles, wild geese that fly with the moon on their wings, these are a few of my favorite things.", "source": "My Favorite Things", From 20418b74b85832a9df0879739daf1664f44a44e7 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 9 Oct 2020 15:50:40 +0100 Subject: [PATCH 07/57] fixed a weird bug when using a mouse to pick an input command and then pressing enter would result in two commands being executed --- public/js/commandline.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/js/commandline.js b/public/js/commandline.js index 4c7654c21..852ac56e8 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -1414,6 +1414,7 @@ $("#commandLineWrapper #commandLine .suggestions").on("mouseover", (e) => { }); $("#commandLineWrapper #commandLine .suggestions").click((e) => { + $(".suggestions .entry").removeClass('activeKeyboard'); triggerCommand($(e.target).attr("command")); }); From 888df4413a5384be25c888cfbf5fc12d1e35a515 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 9 Oct 2020 15:58:04 +0100 Subject: [PATCH 08/57] fixed start graphs at zero not working properly --- public/js/account.js | 6 ++++++ public/js/script.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/public/js/account.js b/public/js/account.js index 63fd06a35..fd88acc6e 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -840,6 +840,9 @@ function updateHoverChart(filteredId) { if (!config.startGraphsAtZero) { hoverChart.options.scales.yAxes[0].ticks.min = Math.round(minChartVal); hoverChart.options.scales.yAxes[1].ticks.min = Math.round(minChartVal); + } else { + hoverChart.options.scales.yAxes[0].ticks.min = 0; + hoverChart.options.scales.yAxes[1].ticks.min = 0; } hoverChart.update({ duration: 0 }); @@ -2183,6 +2186,9 @@ function refreshAccountPage() { resultHistoryChart.options.scales.yAxes[1].ticks.min = Math.floor( minAccuracyChartVal ); + } else { + resultHistoryChart.options.scales.yAxes[0].ticks.min = 0; + resultHistoryChart.options.scales.yAxes[1].ticks.min = 0; } if (chartData == [] || chartData.length == 0) { diff --git a/public/js/script.js b/public/js/script.js index 6fd828bd4..2f75e4671 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -1808,6 +1808,9 @@ function showResult(difficultyFailed = false) { if (!config.startGraphsAtZero) { wpmOverTimeChart.options.scales.yAxes[0].ticks.min = minChartVal; wpmOverTimeChart.options.scales.yAxes[1].ticks.min = minChartVal; + } else { + wpmOverTimeChart.options.scales.yAxes[0].ticks.min = 0; + wpmOverTimeChart.options.scales.yAxes[1].ticks.min = 0; } // wpmOverTimeChart.options.scales.yAxes[0].ticks.min = Math.round(minChartVal); From b17ffe3ec60d9fda0b9d4fa3eaf3c518aaa75dd5 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 9 Oct 2020 16:03:41 +0100 Subject: [PATCH 09/57] fixed current theme indicator not behaving properly --- public/js/commandline.js | 1 + public/js/script.js | 3 +++ public/js/userconfig.js | 1 + 3 files changed, 5 insertions(+) diff --git a/public/js/commandline.js b/public/js/commandline.js index 852ac56e8..c63813c73 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -1421,6 +1421,7 @@ $("#commandLineWrapper #commandLine .suggestions").click((e) => { $("#commandLineWrapper").click((e) => { if ($(e.target).attr("id") === "commandLineWrapper") { hideCommandLine(); + setTheme(config.theme, true); } }); diff --git a/public/js/script.js b/public/js/script.js index 2f75e4671..48a5ceca3 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -4827,6 +4827,9 @@ $(document).on("mouseenter", "#resultWordsHistory .words .word", (e) => { }); $(document).on("click", "#bottom .leftright .right .current-theme", (e) => { + if (config.customTheme) { + togglePresetCustomTheme(); + } currentCommands.push(commandsThemes); showCommandLine(); }); diff --git a/public/js/userconfig.js b/public/js/userconfig.js index b22f322bb..173648223 100644 --- a/public/js/userconfig.js +++ b/public/js/userconfig.js @@ -969,6 +969,7 @@ function applyCustomThemeColors() { document.documentElement.style.setProperty(e, array[index]); }); } else { + $(".current-theme").text(config.theme.replace('_',' ')); previewTheme(config.theme); colorVars.forEach((e) => { document.documentElement.style.setProperty(e, ""); From 15d3a4fe09de2b7cc9d4662cd2e2408843d0004b Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 9 Oct 2020 16:40:55 +0100 Subject: [PATCH 10/57] added average wpm that day to the activity chart --- public/js/account.js | 73 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 9 deletions(-) diff --git a/public/js/account.js b/public/js/account.js index fd88acc6e..3172b37f0 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -527,6 +527,16 @@ let activityChart = new Chart($(".pageAccount #activityChart"), { lineStyle: "dotted", width: 2, }, + order: 3 + }, + { + yAxisID: "avgWpm", + label: "Average Wpm", + data: [], + type: "line", + order: 2, + lineTension: 0, + fill: false, }, ], }, @@ -603,6 +613,28 @@ let activityChart = new Chart($(".pageAccount #activityChart"), { fontFamily: "Roboto Mono", }, }, + { + id: "avgWpm", + ticks: { + fontFamily: "Roboto Mono", + beginAtZero: true, + min: 0, + autoSkip: true, + stepSize: 1, + autoSkipPadding: 40, + stepSize: 10, + }, + display: true, + position: "right", + scaleLabel: { + display: true, + labelString: "Average Wpm", + fontFamily: "Roboto Mono", + }, + gridLines: { + display: false, + }, + }, ], }, }, @@ -1848,7 +1880,7 @@ function refreshAccountPage() { let consCount = 0; let dailyActivityDays = []; - let activityChartData = []; + let activityChartData = {}; filteredResults = []; $(".pageAccount .history table tbody").empty(); @@ -1998,9 +2030,13 @@ function refreshAccountPage() { resultDate = resultDate.getTime(); if (Object.keys(activityChartData).includes(String(resultDate))) { - activityChartData[resultDate] = activityChartData[resultDate] + 1; + activityChartData[resultDate].amount++; + activityChartData[resultDate].totalWpm += result.wpm; } else { - activityChartData[resultDate] = 1; + activityChartData[resultDate] = { + amount: 1, + totalWpm: result.wpm, + } } tt = 0; @@ -2095,7 +2131,10 @@ function refreshAccountPage() { thisDate.setMilliseconds(0); thisDate = thisDate.getTime(); - let tempChartData = []; + console.log(activityChartData); + + let activityChartData_amount = []; + let activityChartData_avgWpm = []; let lastTimestamp = 0; Object.keys(activityChartData).forEach((date) => { let datecheck; @@ -2109,23 +2148,27 @@ function refreshAccountPage() { if (numDaysBetweenTheDays > 1) { if (datecheck === thisDate) { - tempChartData.push({ + activityChartData_amount.push({ x: parseInt(thisDate), y: 0, }); } for (let i = 0; i < numDaysBetweenTheDays - 1; i++) { - tempChartData.push({ + activityChartData_amount.push({ x: parseInt(datecheck) - 86400000 * (i + 1), y: 0, }); } } - tempChartData.push({ + activityChartData_amount.push({ x: parseInt(date), - y: activityChartData[date], + y: activityChartData[date].amount, + }); + activityChartData_avgWpm.push({ + x: parseInt(date), + y: roundTo2(activityChartData[date].totalWpm / activityChartData[date].amount), }); lastTimestamp = date; }); @@ -2144,7 +2187,18 @@ function refreshAccountPage() { activityChart.options.legend.labels.fontColor = themeColors.sub; activityChart.data.datasets[0].trendlineLinear.style = themeColors.sub; - activityChart.data.datasets[0].data = tempChartData; + activityChart.data.datasets[0].data = activityChartData_amount; + + activityChart.options.scales.yAxes[1].ticks.minor.fontColor = + themeColors.sub; + activityChart.options.scales.yAxes[1].scaleLabel.fontColor = + themeColors.sub; + activityChart.data.datasets[1].borderColor = themeColors.sub; + // activityChart.data.datasets[1].backgroundColor = themeColors.main; + activityChart.data.datasets[1].data = activityChartData_avgWpm; + + + activityChart.options.legend.labels.fontColor = themeColors.sub; resultHistoryChart.options.scales.xAxes[0].ticks.minor.fontColor = themeColors.sub; @@ -2358,6 +2412,7 @@ function refreshAccountPage() { try { cont(); } catch (e) { + console.error(e); showNotification(`Something went wrong: ${e}`, 5000); } } From 64a6c2e0ebdc99b6f3635ad710ccc92cc4bec9a4 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 9 Oct 2020 16:59:46 +0100 Subject: [PATCH 11/57] updated pastel colors --- public/themes/pastel.css | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/public/themes/pastel.css b/public/themes/pastel.css index 29468ac14..6830785bf 100644 --- a/public/themes/pastel.css +++ b/public/themes/pastel.css @@ -1,11 +1,11 @@ :root { - --bg-color: #ffd1dc; - --main-color: #f4f1d6; - --caret-color: #f4f1d6; - --sub-color: #ace7ff; - --text-color: #b39eb5; - --error-color: #ff6961; - --error-extra-color: #c23b22; - --colorful-error-color: #ff6961; - --colorful-error-extra-color: #c23b22; + --bg-color: #e0b2bd; + --main-color: #fbf4b6; + --caret-color: #fbf4b6; + --sub-color: #b4e9ff; + --text-color: #6d5c6f; + --error-color: #ff6961; + --error-extra-color: #c23b22; + --colorful-error-color: #ff6961; + --colorful-error-extra-color: #c23b22; } \ No newline at end of file From 9d3994e73d56c5a965d249ca1d923488ac7e5b8a Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 10 Oct 2020 15:48:08 +0100 Subject: [PATCH 12/57] moving verification to oauth2 --- functions/index.js | 347 ++++++++++++++++++++++++------------------ package-lock.json | 35 +++-- public/index.html | 18 +-- public/js/account.js | 11 ++ public/js/script.js | 16 +- public/js/settings.js | 30 +--- 6 files changed, 250 insertions(+), 207 deletions(-) diff --git a/functions/index.js b/functions/index.js index 4c84e2480..257eee7c4 100644 --- a/functions/index.js +++ b/functions/index.js @@ -13,6 +13,7 @@ admin.initializeApp({ }); const db = admin.firestore(); +const fetch = require("node-fetch"); async function getAllNames() { // return admin @@ -474,6 +475,55 @@ exports.getPatreons = functions.https.onRequest(async (request, response) => { } }); +exports.verifyUser = functions.https.onRequest(async (request, response) => { + response.set("Access-Control-Allow-Origin", "*"); + response.set("Access-Control-Allow-Headers", "*"); + response.set("Access-Control-Allow-Credentials", "true"); + if (request.method === "OPTIONS") { + // Send response to OPTIONS requests + response.set("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); + response.set("Access-Control-Allow-Headers", "Authorization,Content-Type"); + response.set("Access-Control-Max-Age", "3600"); + response.status(204).send(""); + return; + } + request = request.body.data; + if (request.uid == undefined) { + response.status(200).send({ data: { status: -1, message: "Need to provide uid" } }); + return; + } + try { + return fetch("https://discord.com/api/users/@me", { + headers: { + authorization: `${request.tokenType} ${request.accessToken}`, + }, + }) + .then((res) => res.json()) + .then(async (res2) => { + let did = res2.id; + await db.collection('users').doc(request.uid).update({ + discordId: did + }) + await db.collection("bot-commands").add({ + command: "verify", + arguments: [did,request.uid], + executed: false, + requestTimestamp: Date.now(), + }); + response.status(200).send({ data: { status: 1, message: "Verified", did: did } }); + return; + }) + .catch((e) => { + console.error('Something went wrong when trying to verify user ' + e.message); + response.status(200).send({ data: { status: -1, message: e.message } }); + return; + }); + } catch (e) { + response.status(200).send({ data: { status: -1, message: e } }); + return; + } +}); + async function incrementTestCounter(uid, userData) { try { if (userData.completedTests === undefined) { @@ -1434,143 +1484,138 @@ class Leaderboard { } } -exports.generatePairingCode = functions - .runWith({ - timeoutSeconds: 100, - memory: "2GB", - }) - .https.onRequest((request, response) => { - response.set("Access-Control-Allow-Origin", "*"); - if (request.method === "OPTIONS") { - // Send response to OPTIONS requests - response.set("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); - response.set( - "Access-Control-Allow-Headers", - "Authorization,Content-Type" - ); - response.set("Access-Control-Max-Age", "3600"); - response.status(204).send(""); - return; - } - request = request.body.data; - try { - if (request === null) { - console.error( - `error while trying to generate discord pairing code - no input` - ); - response.status(200).send({ data: { status: -999 } }); - return; - } +// exports.generatePairingCode = functions +// .runWith({ +// timeoutSeconds: 100, +// memory: "2GB", +// }) +// .https.onRequest((request, response) => { +// response.set("Access-Control-Allow-Origin", "*"); +// if (request.method === "OPTIONS") { +// // Send response to OPTIONS requests +// response.set("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); +// response.set( +// "Access-Control-Allow-Headers", +// "Authorization,Content-Type" +// ); +// response.set("Access-Control-Max-Age", "3600"); +// response.status(204).send(""); +// return; +// } +// request = request.body.data; +// try { +// if (request === null) { +// console.error( +// `error while trying to generate discord pairing code - no input` +// ); +// response.status(200).send({ data: { status: -999 } }); +// return; +// } - return db - .collection("users") - .doc(request.uid) - .get() - .then(async (userDoc) => { - userDocData = userDoc.data(); - if ( - userDocData.discordPairingCode !== undefined && - userDocData.discordPairingCode !== null - ) { - console.log( - `user ${request.uid} already has code ${userDocData.discordPairingCode}` - ); - response.status(200).send({ - data: { - status: -999, - pairingCode: userDocData.discordPairingCode, - }, - }); - } else { - let stepSize = 1000; - let existingCodes = []; - let query = await db - .collection(`users`) - .where("discordPairingCode", ">", "") - .limit(stepSize) - .get(); - let lastDoc; - while (query.docs.length > 0) { - lastDoc = query.docs[query.docs.length - 1]; - query.docs.forEach((doc) => { - let docData = doc.data(); - if ( - docData.discordPairingCode !== undefined && - docData.discordPairingCode !== null - ) { - existingCodes.push(docData.discordPairingCode); - } - }); - query = await db - .collection(`users`) - .where("discordPairingCode", ">", "") - .limit(stepSize) - .startAfter(lastDoc) - .get(); - } +// return db +// .collection("users") +// .doc(request.uid) +// .get() +// .then(async (userDoc) => { +// userDocData = userDoc.data(); +// if ( +// userDocData.discordPairingCode !== undefined && +// userDocData.discordPairingCode !== null +// ) { +// console.log( +// `user ${request.uid} already has code ${userDocData.discordPairingCode}` +// ); +// response.status(200).send({ +// data: { +// status: -999, +// pairingCode: userDocData.discordPairingCode, +// }, +// }); +// } else { +// let stepSize = 1000; +// let existingCodes = []; +// let query = await db +// .collection(`users`) +// .where("discordPairingCode", ">", "") +// .limit(stepSize) +// .get(); +// let lastDoc; +// while (query.docs.length > 0) { +// lastDoc = query.docs[query.docs.length - 1]; +// query.docs.forEach((doc) => { +// let docData = doc.data(); +// if ( +// docData.discordPairingCode !== undefined && +// docData.discordPairingCode !== null +// ) { +// existingCodes.push(docData.discordPairingCode); +// } +// }); +// query = await db +// .collection(`users`) +// .where("discordPairingCode", ">", "") +// .limit(stepSize) +// .startAfter(lastDoc) +// .get(); +// } - let randomCode = generate(9); +// let randomCode = generate(9); - while (existingCodes.includes(randomCode)) { - randomCode = generate(9); - } +// while (existingCodes.includes(randomCode)) { +// randomCode = generate(9); +// } - return db - .collection("users") - .doc(request.uid) - .update( - { - discordPairingCode: randomCode, - }, - { merge: true } - ) - .then((res) => { - console.log(`generated ${randomCode} for user ${request.uid}`); - response.status(200).send({ - data: { - status: 1, - pairingCode: randomCode, - }, - }); - return; - }) - .catch((e) => { - console.error( - `error while trying to set discord pairing code ${randomCode} for user ${request.uid} - ${e}` - ); - response.status(200).send({ - data: { - status: -999, - }, - }); - return; - }); - } - }); - } catch (e) { - console.error( - `error while trying to generate discord pairing code for user ${request.uid} - ${e}` - ); - response.status(200).send({ - data: { - status: -999, - }, - }); - return; - } - }); +// return db +// .collection("users") +// .doc(request.uid) +// .update( +// { +// discordPairingCode: randomCode, +// }, +// { merge: true } +// ) +// .then((res) => { +// console.log(`generated ${randomCode} for user ${request.uid}`); +// response.status(200).send({ +// data: { +// status: 1, +// pairingCode: randomCode, +// }, +// }); +// return; +// }) +// .catch((e) => { +// console.error( +// `error while trying to set discord pairing code ${randomCode} for user ${request.uid} - ${e}` +// ); +// response.status(200).send({ +// data: { +// status: -999, +// }, +// }); +// return; +// }); +// } +// }); +// } catch (e) { +// console.error( +// `error while trying to generate discord pairing code for user ${request.uid} - ${e}` +// ); +// response.status(200).send({ +// data: { +// status: -999, +// }, +// }); +// return; +// } +// }); - - exports.unlinkDiscord = functions.https.onRequest((request, response) => { response.set("Access-Control-Allow-Origin", "*"); if (request.method === "OPTIONS") { // Send response to OPTIONS requests response.set("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); - response.set( - "Access-Control-Allow-Headers", - "Authorization,Content-Type" - ); + response.set("Access-Control-Allow-Headers", "Authorization,Content-Type"); response.set("Access-Control-Max-Age", "3600"); response.status(204).send(""); return; @@ -1578,40 +1623,46 @@ exports.unlinkDiscord = functions.https.onRequest((request, response) => { request = request.body.data; try { if (request === null || request.uid === undefined) { - response.status(200).send({ data: { status: -999, message: "Empty request" } }); + response + .status(200) + .send({ data: { status: -999, message: "Empty request" } }); return; } - return db.collection(`users`).doc(request.uid).update({ - discordId: null - }).then(f => { - response.status(200).send({ - data: { - status: 1, - message: "Unlinked" - }, + return db + .collection(`users`) + .doc(request.uid) + .update({ + discordId: null, + }) + .then((f) => { + response.status(200).send({ + data: { + status: 1, + message: "Unlinked", + }, + }); + return; + }) + .catch((e) => { + response.status(200).send({ + data: { + status: -999, + message: e.message, + }, + }); + return; }); - return; - }).catch(e => { - response.status(200).send({ - data: { - status: -999, - message: e.message - }, - }); - return; - }) } catch (e) { response.status(200).send({ data: { status: -999, - message: e + message: e, }, }); return; } }); - async function checkLeaderboards( resultObj, type, diff --git a/package-lock.json b/package-lock.json index 61d6a1d7f..e35d726c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -611,7 +611,7 @@ "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "requires": { - "lodash": ">=4.17.19" + "lodash": "^4.17.14" } }, "async-each": { @@ -1773,7 +1773,7 @@ "jsonschema": "^1.0.2", "jsonwebtoken": "^8.2.1", "leven": "^3.1.0", - "lodash": ">=4.17.19", + "lodash": "^4.17.14", "marked": "^0.7.0", "marked-terminal": "^3.3.0", "minimatch": "^3.0.4", @@ -2272,7 +2272,7 @@ "cli-width": "^2.0.0", "external-editor": "^3.0.3", "figures": "^2.0.0", - "lodash": ">=4.17.19", + "lodash": "^4.17.11", "mute-stream": "0.0.7", "run-async": "^2.2.0", "rxjs": "^6.4.0", @@ -2429,6 +2429,17 @@ "requires": { "node-fetch": "^1.0.1", "whatwg-fetch": ">=0.10.0" + }, + "dependencies": { + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "requires": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + } } }, "isstream": { @@ -2979,7 +2990,7 @@ "requires": { "async": "^1.3.0", "flat-arguments": "^1.0.0", - "lodash": ">=4.17.19", + "lodash": "^4.17.5", "minimist": "^1.1.0" }, "dependencies": { @@ -3014,13 +3025,9 @@ } }, "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" }, "node-forge": { "version": "0.9.1", @@ -3712,7 +3719,7 @@ "home-dir": "^1.0.0", "is-url": "^1.2.2", "join-path": "^1.1.1", - "lodash": ">=4.17.19", + "lodash": "^4.17.4", "mime-types": "^2.1.16", "minimatch": "^3.0.4", "morgan": "^1.8.2", @@ -3958,7 +3965,7 @@ "resolved": "https://registry.npmjs.org/toxic/-/toxic-1.0.1.tgz", "integrity": "sha512-WI3rIGdcaKULYg7KVoB0zcjikqvcYYvcuT6D89bFPz2rVR0Rl0PK6x8/X62rtdLtBKIE985NzVf/auTtGegIIg==", "requires": { - "lodash": ">=4.17.19" + "lodash": "^4.17.10" } }, "traverse": { @@ -4233,7 +4240,7 @@ "requires": { "http-parser-js": ">=0.4.0 <0.4.11", "safe-buffer": ">=5.1.0", - "websocket-extensions": ">=0.1.4" + "websocket-extensions": ">=0.1.1" } }, "websocket-extensions": { diff --git a/public/index.html b/public/index.html index eda2996d1..e392498b2 100644 --- a/public/index.html +++ b/public/index.html @@ -1454,17 +1454,11 @@ When you connect your monkey-type account to your Discord account, you will be automatically assigned a new role every time you achieve a new personal best in a 60 second test. -
-
- Generate pairing code -
+ + Verify with Discord +
-
diff --git a/public/js/account.js b/public/js/account.js index 3172b37f0..c5fa4b78d 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -252,6 +252,17 @@ firebase.auth().onAuthStateChanged(function (user) { // showNotification('Signed in', 1000); $(".pageLogin .preloader").addClass("hidden"); $("#menu .icon-button.account .text").text(displayName); + if (verifyUserWhenLoggedIn !== null) { + showNotification('Verifying', 1000); + verifyUserWhenLoggedIn.uid = user.uid; + verifyUser(verifyUserWhenLoggedIn).then(data => { + showNotification(data.data.message, 3000); + if (data.data.status === 1) { + dbSnapshot.discordId = data.data.did; + updateDiscordSettingsSection() + } + }) + } } }); diff --git a/public/js/script.js b/public/js/script.js index 48a5ceca3..d9e3146f8 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -41,6 +41,7 @@ let caretAnimating = true; let lastSecondNotRound = false; let paceCaret = null; let missedWords = []; +let verifyUserWhenLoggedIn = null; let themeColors = { bg: "#323437", @@ -207,6 +208,8 @@ const generatePairingCode = firebase .httpsCallable("generatePairingCode"); const saveLbMemory = firebase.functions().httpsCallable("saveLbMemory"); const unlinkDiscord = firebase.functions().httpsCallable("unlinkDiscord"); +const verifyUser = firebase.functions().httpsCallable("verifyUser"); + function refreshThemeColorObject() { @@ -4872,7 +4875,18 @@ $(document).ready(() => { setCustomThemeInputs(); applyCustomThemeColors(); } - if (window.location.pathname === "/account") { + if (window.location.pathname === "/verify") { + const fragment = new URLSearchParams(window.location.hash.slice(1)); + if (fragment.has("access_token")) { + const accessToken = fragment.get("access_token"); + const tokenType = fragment.get("token_type"); + verifyUserWhenLoggedIn = { + accessToken: accessToken, + tokenType: tokenType + } + history.replaceState("/", null, "/"); + } + }else if (window.location.pathname === "/account") { history.replaceState("/", null, "/"); } else if (window.location.pathname !== "/") { let page = window.location.pathname.replace("/", ""); diff --git a/public/js/settings.js b/public/js/settings.js index b02a60616..f4d574332 100644 --- a/public/js/settings.js +++ b/public/js/settings.js @@ -611,48 +611,20 @@ function updateDiscordSettingsSection() { $(".pageSettings .section.discordIntegration").removeClass("hidden"); if ( - dbSnapshot.pairingCode == undefined && dbSnapshot.discordId == undefined ) { //show button - $(".pageSettings .section.discordIntegration .howto").addClass("hidden"); $(".pageSettings .section.discordIntegration .buttons").removeClass( "hidden" ); $(".pageSettings .section.discordIntegration .info").addClass("hidden"); - $(".pageSettings .section.discordIntegration .code").addClass("hidden"); - } else if ( - dbSnapshot.pairingCode != undefined && - dbSnapshot.discordId == undefined - ) { - //show code - $(".pageSettings .section.discordIntegration .code .bottom").text( - dbSnapshot.pairingCode - ); - $(".pageSettings .section.discordIntegration .howtocode").text( - dbSnapshot.pairingCode - ); - $(".pageSettings .section.discordIntegration .howto").removeClass( - "hidden" - ); - $(".pageSettings .section.discordIntegration .buttons").addClass( - "hidden" - ); - $(".pageSettings .section.discordIntegration .info").addClass("hidden"); - $(".pageSettings .section.discordIntegration .code").removeClass( - "hidden" - ); - } else if ( - dbSnapshot.discordId != undefined - ) { - $(".pageSettings .section.discordIntegration .howto").addClass("hidden"); + } else{ $(".pageSettings .section.discordIntegration .buttons").addClass( "hidden" ); $(".pageSettings .section.discordIntegration .info").removeClass( "hidden" ); - $(".pageSettings .section.discordIntegration .code").addClass("hidden"); } } } From 8f8b5c4192442506fd68d33bfcbbe6ba19fe1913 Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 10 Oct 2020 16:16:23 +0100 Subject: [PATCH 13/57] reverting to previous settings after practising missed words --- public/js/script.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/js/script.js b/public/js/script.js index d9e3146f8..98159b6fb 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -42,6 +42,7 @@ let lastSecondNotRound = false; let paceCaret = null; let missedWords = []; let verifyUserWhenLoggedIn = null; +let modeBeforePractise = null; let themeColors = { bg: "#323437", @@ -2569,6 +2570,12 @@ function restartTest(withSameWordset = false, nosave = false) { } } + if (modeBeforePractise !== null) { + showNotification("Reverting to previous settings.", 1500); + changeMode(modeBeforePractise); + modeBeforePractise = null; + } + manualRestart = false; clearTimeout(timer); time = 0; @@ -4147,11 +4154,13 @@ $(document.body).on("click", "#restartTestButton", (event) => { $(document).on("keypress", "#practiseMissedWordsButton", (event) => { if (event.keyCode == 13) { if (missedWords.length > 0) { + let currentMode = config.mode; changeMode("custom"); customText = missedWords; customTextIsRandom = true; customTextWordCount = 50; restartTest(); + modeBeforePractise = currentMode; } else { showNotification("You haven't missed any words.", 2000); } @@ -4160,11 +4169,13 @@ $(document).on("keypress", "#practiseMissedWordsButton", (event) => { $(document.body).on("click", "#practiseMissedWordsButton", (event) => { if (missedWords.length > 0) { + let currentMode = config.mode; changeMode("custom"); customText = missedWords; customTextIsRandom = true; customTextWordCount = 50; restartTest(); + modeBeforePractise = currentMode; } else { showNotification("You haven't missed any words.", 2000); } From 68734ebe8a0477d0d7b2397d7189086f92f8963c Mon Sep 17 00:00:00 2001 From: willerbee Date: Sun, 11 Oct 2020 23:48:16 +0800 Subject: [PATCH 14/57] Added functions to generate single commands list --- public/js/commandline.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/public/js/commandline.js b/public/js/commandline.js index c63813c73..783bbe1a5 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -2,6 +2,35 @@ function capitalizeFirstLetter(str) { return str.charAt(0).toUpperCase() + str.slice(1); } +function addChildCommands(unifiedCommands, commandItem, parentCommandDisplay = '') { + let commandItemDisplay = commandItem.display; + if (parentCommandDisplay) commandItemDisplay = parentCommandDisplay + " → " + commandItemDisplay; + if (commandItem.subgroup) { + try { + commandItem.exec(); + currentCommandsIndex = currentCommands.length-1; + currentCommands[currentCommandsIndex].list.forEach( cmd => addChildCommands(unifiedCommands, cmd, commandItemDisplay)); + currentCommands.pop(); + } catch(e) {} + } else { + let tempCommandItem = {...commandItem}; + if (parentCommandDisplay) + tempCommandItem.display = commandItemDisplay; + unifiedCommands.push(tempCommandItem); + } +} + +function generateSingleListOfCommands() { + allCommands = []; + oldShowCommandLine = showCommandLine; + showCommandLine = () => {}; + commands.list.forEach(c => addChildCommands(allCommands, c)); + showCommandLine = oldShowCommandLine; + return { + title: "All Commands", + list: allCommands}; +} + let commands = { title: "", list: [ From b23ce833e2cd94cd85528243428625c45e4cb69a Mon Sep 17 00:00:00 2001 From: willerbee Date: Sun, 11 Oct 2020 23:50:14 +0800 Subject: [PATCH 15/57] Added more functions to use the feature --- public/js/commandline.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/public/js/commandline.js b/public/js/commandline.js index 783bbe1a5..d6c1225c8 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -31,6 +31,28 @@ function generateSingleListOfCommands() { list: allCommands}; } +function isSingleListCommandLineActive() { + return $("#commandLine").hasClass("allCommands"); +} + +function useSingleListCommandLine(show = true) { + let allCommands = generateSingleListOfCommands(); + if (config.singleListCommandLine == "manual") currentCommands.push(allCommands); + else if (config.singleListCommandLine == "on") currentCommands = [allCommands]; + + if (config.singleListCommandLine != "off") $("#commandLine").addClass("allCommands"); + if (show) showCommandLine(); +} + +function restoreOldCommandLine(show = true) { + if (isSingleListCommandLineActive()) { + $("#commandLine").removeClass("allCommands"); + currentCommands = currentCommands.filter( l => l.title != "All Commands"); + if (currentCommands.length < 1) currentCommands = [commands]; + } + if (show) showCommandLine(); +} + let commands = { title: "", list: [ From 36af4de5103bbefcd1eaba176ebb5419fa5fc2b4 Mon Sep 17 00:00:00 2001 From: willerbee Date: Sun, 11 Oct 2020 23:56:07 +0800 Subject: [PATCH 16/57] Added commands and subgroup commands --- public/js/commandline.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/public/js/commandline.js b/public/js/commandline.js index d6c1225c8..63a73c853 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -218,6 +218,15 @@ let commands = { toggleQuickEnd(); }, }, + { + id: "singleListCommandLine", + display: "Single list command line...", + subgroup: true, + exec: () => { + currentCommands.push(commandsSingleListCommandLine); + showCommandLine(); + }, + }, { id: "togglePlaySoundOnError", display: "Toggle play sound on error", @@ -892,6 +901,26 @@ let commandsTimerColor = { ], }; +let commandsSingleListCommandLine = { + title: "Single list command line...", + list: [ + { + id: "singleListCommandLineManual", + display: "manual", + exec: () => { + setSingleListCommandLine("manual"); + }, + }, + { + id: "singleListCommandLineOn", + display: "on", + exec: () => { + setSingleListCommandLine("on"); + }, + } + ], +}; + let commandsTimerOpacity = { title: "Change timer opacity...", list: [ From 08cd376fa2d6e71c5e17e0b50f00da85b0a7fc68 Mon Sep 17 00:00:00 2001 From: willerbee Date: Mon, 12 Oct 2020 00:10:39 +0800 Subject: [PATCH 17/57] Added config entries and setter function --- public/js/userconfig.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/js/userconfig.js b/public/js/userconfig.js index 173648223..0f7ab922e 100644 --- a/public/js/userconfig.js +++ b/public/js/userconfig.js @@ -53,6 +53,7 @@ let defaultConfig = { smoothLineScroll: false, alwaysShowDecimalPlaces: false, alwaysShowWordsHistory: false, + singleListCommandLine: "manual", playSoundOnError: false, playSoundOnClick: "off", startGraphsAtZero: true, @@ -190,6 +191,7 @@ function applyConfig(configObj) { setShowTimerProgress(configObj.showTimerProgress, true); setAlwaysShowDecimalPlaces(configObj.alwaysShowDecimalPlaces, true); setAlwaysShowWordsHistory(configObj.alwaysShowWordsHistory, true); + setSingleListCommandLine(configObj.singleListCommandLine, true); setPlaySoundOnError(configObj.playSoundOnError, true); setPlaySoundOnClick(configObj.playSoundOnClick, true); setStopOnError(configObj.stopOnError, true); @@ -429,6 +431,13 @@ function setAlwaysShowWordsHistory(val, nosave) { if (!nosave) saveConfigToCookie(); } +//single list command line +function setSingleListCommandLine(option, nosave) { + if (!option) option = "manual"; + config.singleListCommandLine = option; + if (!nosave) saveConfigToCookie(); +} + //show all lines function toggleShowAllLines() { sal = !config.showAllLines; From fb4990c51a9093be3efa01b2079c910697d6f2a7 Mon Sep 17 00:00:00 2001 From: willerbee Date: Mon, 12 Oct 2020 00:16:51 +0800 Subject: [PATCH 18/57] Added feature's SettingsGroup --- public/js/settings.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/js/settings.js b/public/js/settings.js index f4d574332..2ed7813dc 100644 --- a/public/js/settings.js +++ b/public/js/settings.js @@ -147,6 +147,10 @@ settingsGroups.alwaysShowWordsHistory = new SettingsGroup( "alwaysShowWordsHistory", setAlwaysShowWordsHistory ); +settingsGroups.singleListCommandLine = new SettingsGroup( + "singleListCommandLine", + setSingleListCommandLine +); settingsGroups.flipTestColors = new SettingsGroup( "flipTestColors", setFlipTestColors From 1cdfea5c42a7cf80c568344232604a10e55b5d9e Mon Sep 17 00:00:00 2001 From: willerbee Date: Mon, 12 Oct 2020 00:24:39 +0800 Subject: [PATCH 19/57] Added settings markup for feature --- public/index.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/public/index.html b/public/index.html index e392498b2..156df26bc 100644 --- a/public/index.html +++ b/public/index.html @@ -1595,6 +1595,31 @@ +
+

single list command line

+
+ When enabled, it will show the command line with all commands in a single list instead of submenu arrangements. Selecting 'manual' will expose all commands only after typing >. +
+
+
+ manual +
+
+ on +
+ +
+

language

From a83b758c1acb189997b853eea7473c89bfa5fc80 Mon Sep 17 00:00:00 2001 From: willerbee Date: Mon, 12 Oct 2020 00:35:08 +0800 Subject: [PATCH 20/57] Inserted into event handlers and functions --- public/js/commandline.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/public/js/commandline.js b/public/js/commandline.js index 63a73c853..b7dab50cc 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -1432,11 +1432,15 @@ $(document).ready((e) => { if ((event.keyCode == 27 && !config.swapEscAndTab) || (event["keyCode"] == 9 && config.swapEscAndTab)) { event.preventDefault(); if ($("#commandLineWrapper").hasClass("hidden")) { - currentCommands = [commands]; + if (config.singleListCommandLine == "on") + useSingleListCommandLine(false); + else + currentCommands = [commands]; showCommandLine(); } else { if (currentCommands.length > 1) { currentCommands.pop(); + $("#commandLine").removeClass("allCommands"); showCommandLine(); } else { hideCommandLine(); @@ -1508,6 +1512,17 @@ $("#commandLineWrapper").click((e) => { $(document).keydown((e) => { if (!$("#commandLineWrapper").hasClass("hidden")) { $("#commandLine input").focus(); + if (e.key == ">" && config.singleListCommandLine == "manual") { + if (!isSingleListCommandLineActive()) { + useSingleListCommandLine(); + return; + } else if ($("#commandLine input").val() == ">") { //so that it will ignore succeeding ">" when input is already ">" + e.preventDefault(); + return; + } + } + if (e.keyCode == 8 && $("#commandLine input").val().length == 1 && config.singleListCommandLine == "manual" && isSingleListCommandLineActive()) + restoreOldCommandLine(); if (e.keyCode == 13) { //enter e.preventDefault(); @@ -1615,6 +1630,7 @@ function hideCommandLine() { 100, () => { $("#commandLineWrapper").addClass("hidden"); + $("#commandLine").removeClass("allCommands"); focusWords(); } ); @@ -1656,6 +1672,8 @@ function showCommandInput(command, placeholder) { function updateSuggestedCommands() { let inputVal = $("#commandLine input").val().toLowerCase().split(" "); let list = currentCommands[currentCommands.length - 1]; + //ignore the preceeding ">"s in the command line input + if (inputVal[0] && inputVal[0][0] == ">") inputVal[0] = inputVal[0].replace(/^>+/,''); if (inputVal[0] == "") { $.each(list.list, (index, obj) => { if (obj.visible !== false) obj.found = true; From 35db7c9021faac430499c7db14e715ea3db23eaf Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 12 Oct 2020 00:41:03 +0100 Subject: [PATCH 21/57] tracking timestamp with pbs --- functions/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/functions/index.js b/functions/index.js index 257eee7c4..724a22057 100644 --- a/functions/index.js +++ b/functions/index.js @@ -262,6 +262,7 @@ function checkIfPB(uid, obj, userdata) { wpm: obj.wpm, acc: obj.acc, raw: obj.rawWpm, + timestamp: Date.now() }, ], }, @@ -285,6 +286,7 @@ function checkIfPB(uid, obj, userdata) { wpm: obj.wpm, acc: obj.acc, raw: obj.rawWpm, + timestamp: Date.now() }, ], }, @@ -316,6 +318,7 @@ function checkIfPB(uid, obj, userdata) { pb.wpm = obj.wpm; pb.acc = obj.acc; pb.raw = obj.rawWpm; + pb.timestamp = Date.now(); toUpdate = true; } else { //no pb @@ -332,6 +335,7 @@ function checkIfPB(uid, obj, userdata) { wpm: obj.wpm, acc: obj.acc, raw: obj.rawWpm, + timestamp: Date.now() }); toUpdate = true; } @@ -346,6 +350,7 @@ function checkIfPB(uid, obj, userdata) { wpm: obj.wpm, acc: obj.acc, raw: obj.rawWpm, + timestamp: Date.now() }, ]; toUpdate = true; @@ -701,9 +706,13 @@ exports.testCompleted = functions return; } request = request.body.data; + if (request === undefined) { + response.status(200).send({ data: { resultCode: -999 } }); + return; + } try { if (request.uid === undefined || request.obj === undefined) { - console.error(`error saving result for ${request.uid} - missing input`); + console.error(`error saving result for - missing input`); response.status(200).send({ data: { resultCode: -999 } }); return; } From 24051eba5ef8fe353b81e22e6efcf49dfd9deed9 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 12 Oct 2020 00:46:29 +0100 Subject: [PATCH 22/57] local pb timestamp --- public/js/db.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/js/db.js b/public/js/db.js index 2de6cc3a3..a092a5398 100644 --- a/public/js/db.js +++ b/public/js/db.js @@ -225,6 +225,7 @@ async function db_saveLocalPB( pb.wpm = wpm; pb.acc = acc; pb.raw = raw; + pb.timestamp = Date.now(); } }); if (!found) { @@ -236,6 +237,7 @@ async function db_saveLocalPB( wpm: wpm, acc: acc, raw: raw, + timestamp: Date.now() }); } } catch (e) { @@ -249,6 +251,7 @@ async function db_saveLocalPB( wpm: wpm, acc: acc, raw: raw, + timestamp: Date.now() }, ]; } From f2b95ea5f0b819a1549e92e953a0388face2b4e1 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 12 Oct 2020 00:55:31 +0100 Subject: [PATCH 23/57] added consistency to pbs --- functions/index.js | 13 +++++++++---- public/js/db.js | 10 +++++++--- public/js/script.js | 1 + 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/functions/index.js b/functions/index.js index 724a22057..483b20459 100644 --- a/functions/index.js +++ b/functions/index.js @@ -262,7 +262,8 @@ function checkIfPB(uid, obj, userdata) { wpm: obj.wpm, acc: obj.acc, raw: obj.rawWpm, - timestamp: Date.now() + timestamp: Date.now(), + consistency: obj.consistency }, ], }, @@ -286,7 +287,8 @@ function checkIfPB(uid, obj, userdata) { wpm: obj.wpm, acc: obj.acc, raw: obj.rawWpm, - timestamp: Date.now() + timestamp: Date.now(), + consistency: obj.consistency }, ], }, @@ -319,6 +321,7 @@ function checkIfPB(uid, obj, userdata) { pb.acc = obj.acc; pb.raw = obj.rawWpm; pb.timestamp = Date.now(); + pb.consistency = obj.consistency; toUpdate = true; } else { //no pb @@ -335,7 +338,8 @@ function checkIfPB(uid, obj, userdata) { wpm: obj.wpm, acc: obj.acc, raw: obj.rawWpm, - timestamp: Date.now() + timestamp: Date.now(), + consistency: obj.consistency }); toUpdate = true; } @@ -350,7 +354,8 @@ function checkIfPB(uid, obj, userdata) { wpm: obj.wpm, acc: obj.acc, raw: obj.rawWpm, - timestamp: Date.now() + timestamp: Date.now(), + consistency: obj.consistency }, ]; toUpdate = true; diff --git a/public/js/db.js b/public/js/db.js index a092a5398..75a732730 100644 --- a/public/js/db.js +++ b/public/js/db.js @@ -207,7 +207,8 @@ async function db_saveLocalPB( difficulty, wpm, acc, - raw + raw, + consistency ) { function cont() { try { @@ -226,6 +227,7 @@ async function db_saveLocalPB( pb.acc = acc; pb.raw = raw; pb.timestamp = Date.now(); + pb.consistency = consistency; } }); if (!found) { @@ -237,7 +239,8 @@ async function db_saveLocalPB( wpm: wpm, acc: acc, raw: raw, - timestamp: Date.now() + timestamp: Date.now(), + consistency: consistency }); } } catch (e) { @@ -251,7 +254,8 @@ async function db_saveLocalPB( wpm: wpm, acc: acc, raw: raw, - timestamp: Date.now() + timestamp: Date.now(), + consistency: consistency }, ]; } diff --git a/public/js/script.js b/public/js/script.js index 98159b6fb..8dcb09d33 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -2218,6 +2218,7 @@ function showResult(difficultyFailed = false) { stats.wpm, stats.acc, stats.wpmRaw, + stats.consistency ); } else if (e.data.resultCode === 1) { if (localPb) { From 2cbc1a0a1dcaa86e6d038c0b36f538ff1ef53212 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 12 Oct 2020 01:04:36 +0100 Subject: [PATCH 24/57] wrong var name --- public/js/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/script.js b/public/js/script.js index 8dcb09d33..ccf242ccc 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -2218,7 +2218,7 @@ function showResult(difficultyFailed = false) { stats.wpm, stats.acc, stats.wpmRaw, - stats.consistency + consistency ); } else if (e.data.resultCode === 1) { if (localPb) { From 345f6436be1aa7f0a88b3849c4a0d86e2dc47876 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 12 Oct 2020 01:09:30 +0100 Subject: [PATCH 25/57] removed consolelog --- public/js/account.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/public/js/account.js b/public/js/account.js index c5fa4b78d..7681582e5 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -2142,8 +2142,6 @@ function refreshAccountPage() { thisDate.setMilliseconds(0); thisDate = thisDate.getTime(); - console.log(activityChartData); - let activityChartData_amount = []; let activityChartData_avgWpm = []; let lastTimestamp = 0; From 740a3aa78192b6ab021bd69d783542c5e5ef1b78 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 12 Oct 2020 01:12:25 +0100 Subject: [PATCH 26/57] showing pb consistency --- public/index.html | 2 ++ public/js/account.js | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/public/index.html b/public/index.html index e392498b2..35fdd4586 100644 --- a/public/index.html +++ b/public/index.html @@ -2666,6 +2666,7 @@ wpm raw accuracy + consistency @@ -2704,6 +2705,7 @@ wpm raw accuracy + consistency diff --git a/public/js/account.js b/public/js/account.js index 7681582e5..7f7233f20 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -1489,24 +1489,28 @@ function fillPbTables() { - - - + - 30 - - - + - 60 - - - + - 120 - - - + - `); $(".pageAccount .wordsPbTable tbody").html(` @@ -1515,24 +1519,28 @@ function fillPbTables() { - - - + - 25 - - - + - 50 - - - + - 100 - - - + - `); @@ -1548,6 +1556,9 @@ function fillPbTables() { ${pbData.wpm} ${pbData.raw === undefined ? "-" : pbData.raw} ${pbData.acc === undefined ? "-" : pbData.acc + "%"} + + ${pbData.consistency === undefined ? "-" : pbData.consistency + "%"} + `; } catch (e) { text += ` @@ -1555,6 +1566,7 @@ function fillPbTables() { - - - + - `; } try { @@ -1564,6 +1576,9 @@ function fillPbTables() { ${pbData.wpm} ${pbData.raw === undefined ? "-" : pbData.raw} ${pbData.acc === undefined ? "-" : pbData.acc + "%"} + + ${pbData.consistency === undefined ? "-" : pbData.consistency + "%"} + `; } catch (e) { text += ` @@ -1571,6 +1586,7 @@ function fillPbTables() { - - - + - `; } try { @@ -1580,6 +1596,9 @@ function fillPbTables() { ${pbData.wpm} ${pbData.raw === undefined ? "-" : pbData.raw} ${pbData.acc === undefined ? "-" : pbData.acc + "%"} + + ${pbData.consistency === undefined ? "-" : pbData.consistency + "%"} + `; } catch (e) { text += ` @@ -1587,6 +1606,7 @@ function fillPbTables() { - - - + - `; } try { @@ -1596,6 +1616,9 @@ function fillPbTables() { ${pbData.wpm} ${pbData.raw === undefined ? "-" : pbData.raw} ${pbData.acc === undefined ? "-" : pbData.acc + "%"} + + ${pbData.consistency === undefined ? "-" : pbData.consistency + "%"} + `; } catch (e) { text += ` @@ -1603,6 +1626,7 @@ function fillPbTables() { - - - + - `; } $(".pageAccount .timePbTable tbody").html(text); @@ -1615,6 +1639,9 @@ function fillPbTables() { ${pbData.wpm} ${pbData.raw === undefined ? "-" : pbData.raw} ${pbData.acc === undefined ? "-" : pbData.acc + "%"} + + ${pbData.consistency === undefined ? "-" : pbData.consistency + "%"} + `; } catch (e) { text += ` @@ -1622,6 +1649,7 @@ function fillPbTables() { - - - + - `; } try { @@ -1631,6 +1659,9 @@ function fillPbTables() { ${pbData.wpm} ${pbData.raw === undefined ? "-" : pbData.raw} ${pbData.acc === undefined ? "-" : pbData.acc + "%"} + + ${pbData.consistency === undefined ? "-" : pbData.consistency + "%"} + `; } catch (e) { text += ` @@ -1638,6 +1669,7 @@ function fillPbTables() { - - - + - `; } try { @@ -1647,6 +1679,9 @@ function fillPbTables() { ${pbData.wpm} ${pbData.raw === undefined ? "-" : pbData.raw} ${pbData.acc === undefined ? "-" : pbData.acc + "%"} + + ${pbData.consistency === undefined ? "-" : pbData.consistency + "%"} + `; } catch (e) { text += ` @@ -1654,6 +1689,7 @@ function fillPbTables() { - - - + - `; } try { @@ -1663,6 +1699,9 @@ function fillPbTables() { ${pbData.wpm} ${pbData.raw === undefined ? "-" : pbData.raw} ${pbData.acc === undefined ? "-" : pbData.acc + "%"} + + ${pbData.consistency === undefined ? "-" : pbData.consistency + "%"} + `; } catch (e) { text += ` @@ -1670,6 +1709,7 @@ function fillPbTables() { - - - + - `; } $(".pageAccount .wordsPbTable tbody").html(text); From 799c9cfea6996b7485347f280196846af0a274fe Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 12 Oct 2020 01:44:35 +0100 Subject: [PATCH 27/57] fixed local time not being incremented by incomplete seconds (server was still fine) --- public/js/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/script.js b/public/js/script.js index ccf242ccc..889e6affb 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -2018,9 +2018,9 @@ function showResult(difficultyFailed = false) { if (dbSnapshot !== null && dbSnapshot.results !== undefined) { dbSnapshot.results.unshift(completedEvent); if (dbSnapshot.globalStats.time == undefined) { - dbSnapshot.globalStats.time = testtime; + dbSnapshot.globalStats.time = testtime + completedEvent.incompleteTestSeconds; } else { - dbSnapshot.globalStats.time += testtime; + dbSnapshot.globalStats.time += testtime + completedEvent.incompleteTestSeconds; } if (dbSnapshot.globalStats.started == undefined) { dbSnapshot.globalStats.started = restartCount + 1; From 0b8265c760f0acb7c3536e6a3ef656014f096730 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 12 Oct 2020 01:58:31 +0100 Subject: [PATCH 28/57] initially generating more words to fill the space better --- public/js/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/script.js b/public/js/script.js index 889e6affb..c3d2b94ea 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -435,7 +435,7 @@ function initWords() { config.mode == "custom" ) { // let wordsBound = config.mode == "time" ? 60 : config.words; - let wordsBound = 60; + let wordsBound = 100; if (config.showAllLines) { if (config.mode === "custom") { if (customTextIsRandom) { From c6a7d934ef9b27b232345e4db3d284ce53331347 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 12 Oct 2020 23:36:17 +0100 Subject: [PATCH 29/57] removed soon --- firebase.json | 7 ----- public/soon.html | 70 ------------------------------------------------ 2 files changed, 77 deletions(-) delete mode 100644 public/soon.html diff --git a/firebase.json b/firebase.json index 0a92ba351..17e046584 100644 --- a/firebase.json +++ b/firebase.json @@ -2,13 +2,6 @@ "hosting": { "public": "public", "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], - "redirects": [ - { - "source": "/soon", - "destination": "/", - "type": 301 - } - ], "rewrites": [ { "source": "**", diff --git a/public/soon.html b/public/soon.html deleted file mode 100644 index 857683e1b..000000000 --- a/public/soon.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - Monkey Type - Coming Soon! - - - - -
- -
Coming very soon...
-
- - From eefde120671dd3ebeb7aed6f321bc1750cbfc4d1 Mon Sep 17 00:00:00 2001 From: willerbee Date: Tue, 13 Oct 2020 15:16:03 +0800 Subject: [PATCH 30/57] Added classes in menu icon buttons for targetting --- public/index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/index.html b/public/index.html index 35fdd4586..83e285048 100644 --- a/public/index.html +++ b/public/index.html @@ -762,13 +762,13 @@
monkey-type