Merge branch 'master' into single-list-command-line

This commit is contained in:
willerbee 2020-10-14 09:19:58 +08:00 committed by GitHub
commit 00639e26e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 111 additions and 98 deletions

View file

@ -2,13 +2,6 @@
"hosting": {
"public": "public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"redirects": [
{
"source": "/soon",
"destination": "/",
"type": 301
}
],
"rewrites": [
{
"source": "**",

View file

@ -262,6 +262,8 @@ function checkIfPB(uid, obj, userdata) {
wpm: obj.wpm,
acc: obj.acc,
raw: obj.rawWpm,
timestamp: Date.now(),
consistency: obj.consistency
},
],
},
@ -285,6 +287,8 @@ function checkIfPB(uid, obj, userdata) {
wpm: obj.wpm,
acc: obj.acc,
raw: obj.rawWpm,
timestamp: Date.now(),
consistency: obj.consistency
},
],
},
@ -316,6 +320,8 @@ function checkIfPB(uid, obj, userdata) {
pb.wpm = obj.wpm;
pb.acc = obj.acc;
pb.raw = obj.rawWpm;
pb.timestamp = Date.now();
pb.consistency = obj.consistency;
toUpdate = true;
} else {
//no pb
@ -332,6 +338,8 @@ function checkIfPB(uid, obj, userdata) {
wpm: obj.wpm,
acc: obj.acc,
raw: obj.rawWpm,
timestamp: Date.now(),
consistency: obj.consistency
});
toUpdate = true;
}
@ -346,6 +354,8 @@ function checkIfPB(uid, obj, userdata) {
wpm: obj.wpm,
acc: obj.acc,
raw: obj.rawWpm,
timestamp: Date.now(),
consistency: obj.consistency
},
];
toUpdate = true;
@ -701,9 +711,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;
}

View file

@ -762,13 +762,13 @@
<div class="bottom">monkey-type</div>
</div>
<div id="menu">
<div class="icon-button" tabindex="2" href="/" onclick="this.blur();">
<div class="icon-button view-start" tabindex="2" href="/" onclick="this.blur();">
<div class="icon">
<i class="fas fa-fw fa-keyboard"></i>
</div>
</div>
<div
class="icon-button leaderboards"
class="icon-button leaderboards view-leaderboards"
tabindex="2"
onclick="this.blur();"
>
@ -777,7 +777,7 @@
</div>
</div>
<div
class="icon-button"
class="icon-button view-about"
tabindex="2"
href="/about"
onclick="this.blur();"
@ -799,7 +799,7 @@
</div>
</a> -->
<div
class="icon-button"
class="icon-button view-settings"
tabindex="2"
href="/settings"
onclick="this.blur();"
@ -809,7 +809,7 @@
</div>
</div>
<div
class="icon-button hidden account"
class="icon-button hidden account view-account"
tabindex="2"
href="/account"
onclick="this.blur();"
@ -820,7 +820,7 @@
<div class="text"></div>
</div>
<div
class="icon-button login"
class="icon-button login view-login"
tabindex="2"
href="/login"
onclick="this.blur();"
@ -2691,6 +2691,7 @@
<td>wpm</td>
<td>raw</td>
<td>accuracy</td>
<td>consistency</td>
</tr>
</thead>
<tbody>
@ -2729,6 +2730,7 @@
<td>wpm</td>
<td>raw</td>
<td>accuracy</td>
<td>consistency</td>
</tr>
</thead>
<tbody>

View file

@ -1489,24 +1489,28 @@ function fillPbTables() {
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>30</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>60</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>120</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
`);
$(".pageAccount .wordsPbTable tbody").html(`
@ -1515,24 +1519,28 @@ function fillPbTables() {
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>25</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>50</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>100</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
`);
@ -1548,6 +1556,9 @@ function fillPbTables() {
<td>${pbData.wpm}</td>
<td>${pbData.raw === undefined ? "-" : pbData.raw}</td>
<td>${pbData.acc === undefined ? "-" : pbData.acc + "%"}</td>
<td>
${pbData.consistency === undefined ? "-" : pbData.consistency + "%"}
</td>
</tr>`;
} catch (e) {
text += `<tr>
@ -1555,6 +1566,7 @@ function fillPbTables() {
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>`;
}
try {
@ -1564,6 +1576,9 @@ function fillPbTables() {
<td>${pbData.wpm}</td>
<td>${pbData.raw === undefined ? "-" : pbData.raw}</td>
<td>${pbData.acc === undefined ? "-" : pbData.acc + "%"}</td>
<td>
${pbData.consistency === undefined ? "-" : pbData.consistency + "%"}
</td>
</tr>`;
} catch (e) {
text += `<tr>
@ -1571,6 +1586,7 @@ function fillPbTables() {
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>`;
}
try {
@ -1580,6 +1596,9 @@ function fillPbTables() {
<td>${pbData.wpm}</td>
<td>${pbData.raw === undefined ? "-" : pbData.raw}</td>
<td>${pbData.acc === undefined ? "-" : pbData.acc + "%"}</td>
<td>
${pbData.consistency === undefined ? "-" : pbData.consistency + "%"}
</td>
</tr>`;
} catch (e) {
text += `<tr>
@ -1587,6 +1606,7 @@ function fillPbTables() {
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>`;
}
try {
@ -1596,6 +1616,9 @@ function fillPbTables() {
<td>${pbData.wpm}</td>
<td>${pbData.raw === undefined ? "-" : pbData.raw}</td>
<td>${pbData.acc === undefined ? "-" : pbData.acc + "%"}</td>
<td>
${pbData.consistency === undefined ? "-" : pbData.consistency + "%"}
</td>
</tr>`;
} catch (e) {
text += `<tr>
@ -1603,6 +1626,7 @@ function fillPbTables() {
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>`;
}
$(".pageAccount .timePbTable tbody").html(text);
@ -1615,6 +1639,9 @@ function fillPbTables() {
<td>${pbData.wpm}</td>
<td>${pbData.raw === undefined ? "-" : pbData.raw}</td>
<td>${pbData.acc === undefined ? "-" : pbData.acc + "%"}</td>
<td>
${pbData.consistency === undefined ? "-" : pbData.consistency + "%"}
</td>
</tr>`;
} catch (e) {
text += `<tr>
@ -1622,6 +1649,7 @@ function fillPbTables() {
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>`;
}
try {
@ -1631,6 +1659,9 @@ function fillPbTables() {
<td>${pbData.wpm}</td>
<td>${pbData.raw === undefined ? "-" : pbData.raw}</td>
<td>${pbData.acc === undefined ? "-" : pbData.acc + "%"}</td>
<td>
${pbData.consistency === undefined ? "-" : pbData.consistency + "%"}
</td>
</tr>`;
} catch (e) {
text += `<tr>
@ -1638,6 +1669,7 @@ function fillPbTables() {
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>`;
}
try {
@ -1647,6 +1679,9 @@ function fillPbTables() {
<td>${pbData.wpm}</td>
<td>${pbData.raw === undefined ? "-" : pbData.raw}</td>
<td>${pbData.acc === undefined ? "-" : pbData.acc + "%"}</td>
<td>
${pbData.consistency === undefined ? "-" : pbData.consistency + "%"}
</td>
</tr>`;
} catch (e) {
text += `<tr>
@ -1654,6 +1689,7 @@ function fillPbTables() {
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>`;
}
try {
@ -1663,6 +1699,9 @@ function fillPbTables() {
<td>${pbData.wpm}</td>
<td>${pbData.raw === undefined ? "-" : pbData.raw}</td>
<td>${pbData.acc === undefined ? "-" : pbData.acc + "%"}</td>
<td>
${pbData.consistency === undefined ? "-" : pbData.consistency + "%"}
</td>
</tr>`;
} catch (e) {
text += `<tr>
@ -1670,6 +1709,7 @@ function fillPbTables() {
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>`;
}
$(".pageAccount .wordsPbTable tbody").html(text);
@ -2142,8 +2182,6 @@ function refreshAccountPage() {
thisDate.setMilliseconds(0);
thisDate = thisDate.getTime();
console.log(activityChartData);
let activityChartData_amount = [];
let activityChartData_avgWpm = [];
let lastTimestamp = 0;

View file

@ -464,6 +464,34 @@ let commands = {
display: "Next random theme",
exec: () => randomiseTheme()
},
{
id: "viewTypingPage",
display: "View Typing Page",
exec: () => $('#top #menu .icon-button.view-start').click()
},
{
id: "viewLeaderboards",
display: "View Leaderboards Page",
exec: () => $('#top #menu .icon-button.view-leaderboards').click()
},
{
id: "viewAbout",
display: "View About Page",
exec: () => $('#top #menu .icon-button.view-about').click()
},
{
id: "viewSettings",
display: "View Settings Page",
exec: () => $('#top #menu .icon-button.view-settings').click()
},
{
id: "viewAccount",
display: "View Account Page",
exec: () =>
$('#top #menu .icon-button.view-account').hasClass('hidden') ?
$('#top #menu .icon-button.view-login').click() :
$('#top #menu .icon-button.view-account').click()
},
{
id: "bailOut",
display: "Bail out...",

View file

@ -68,6 +68,7 @@ async function db_getUserSnapshot() {
.then((res) => {
// console.log('getting data from db!');
let data = res.data();
if (data === undefined) return;
try {
if (data.personalBests !== undefined) {
snap.personalBests = data.personalBests;
@ -207,7 +208,8 @@ async function db_saveLocalPB(
difficulty,
wpm,
acc,
raw
raw,
consistency
) {
function cont() {
try {
@ -225,6 +227,8 @@ async function db_saveLocalPB(
pb.wpm = wpm;
pb.acc = acc;
pb.raw = raw;
pb.timestamp = Date.now();
pb.consistency = consistency;
}
});
if (!found) {
@ -236,6 +240,8 @@ async function db_saveLocalPB(
wpm: wpm,
acc: acc,
raw: raw,
timestamp: Date.now(),
consistency: consistency
});
}
} catch (e) {
@ -249,6 +255,8 @@ async function db_saveLocalPB(
wpm: wpm,
acc: acc,
raw: raw,
timestamp: Date.now(),
consistency: consistency
},
];
}

View file

@ -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) {
@ -714,10 +714,9 @@ function punctuateWord(previousWord, currentWord, index, maxindex) {
}
function addWord() {
let bound = 60;
let bound = 100;
if (activeFunBox === "plus_one") bound = 1;
if (
!config.showAllLines &&
(wordsList.length - inputHistory.length > bound ||
(config.mode === "words" && wordsList.length >= config.words) ||
(config.mode === "custom" &&
@ -2018,9 +2017,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;
@ -2218,6 +2217,7 @@ function showResult(difficultyFailed = false) {
stats.wpm,
stats.acc,
stats.wpmRaw,
consistency
);
} else if (e.data.resultCode === 1) {
if (localPb) {
@ -4791,11 +4791,11 @@ $(document).keydown((event) => {
) {
updateTimer();
}
if (config.showAllLines) {
if (config.mode == "time") {
addWord();
}
} else {
// if (config.showAllLines) {
// if (config.mode == "time") {
// addWord();
// }
// } else {
if (
config.mode == "time" ||
config.mode == "words" ||
@ -4803,7 +4803,7 @@ $(document).keydown((event) => {
) {
addWord();
}
}
// }
}
}
});

View file

@ -1,70 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Monkey Type - Coming Soon!</title>
<link
href="https://fonts.googleapis.com/css?family=Roboto+Mono&display=swap"
rel="stylesheet"
/>
<style>
* {
font-family: "Roboto Mono";
color: var(--main-color);
}
:root {
--main-color: #eee;
--sub-color: #444;
--bg-color: #111;
--caret-color: #fff;
--active-word-color: #444;
--roundness: 0.25rem;
}
body {
background-color: var(--bg-color);
width: 100vw;
height: 100vh;
display: grid;
align-content: center;
justify-content: center;
padding: 0;
margin: 0;
}
.grid {
display: grid;
gap: 1rem;
}
.logo {
margin-bottom: -0.12rem;
white-space: nowrap;
}
.logo .top {
font-size: 0.65rem;
line-height: 0.65rem;
margin-bottom: -0.4rem;
margin-left: -0.1rem;
color: var(--sub-color);
}
.logo .bottom {
margin-left: -0.15rem;
font-size: 2.3rem;
line-height: 2.3rem;
}
.soon {
text-align: center;
}
</style>
</head>
<body>
<div class="grid">
<div class="logo">
<div class="top">monkey-see</div>
<div class="bottom">monkey-type</div>
</div>
<div class="soon">Coming very soon...</div>
</div>
</body>
</html>