Merge branch 'master' into feat/java-code

This commit is contained in:
Ryan Harrington 2020-12-05 14:16:55 -07:00 committed by GitHub
commit 3f1b95a427
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 11219 additions and 43 deletions

View file

@ -809,18 +809,23 @@ async function incrementTimeSpentTyping(uid, res, userData) {
timeTyping: admin.firestore.FieldValue.increment(timeSum),
});
} else {
let afk = res.afkDuration;
if (afk == undefined) {
afk = 0;
}
db.collection("users")
.doc(uid)
.update({
timeTyping: admin.firestore.FieldValue.increment(
res.testDuration + res.incompleteTestSeconds
res.testDuration + res.incompleteTestSeconds - afk
),
});
db.collection("public")
.doc("stats")
.update({
timeTyping: admin.firestore.FieldValue.increment(
res.testDuration + res.incompleteTestSeconds
res.testDuration + res.incompleteTestSeconds - afk
),
});
}
@ -941,6 +946,11 @@ exports.testCompleted = functions.https.onRequest(async (request, response) => {
return user.emailVerified;
});
if (obj.funbox === "nospace") {
response.status(200).send({ data: { resultCode: -1 } });
return;
}
return db
.collection("users")
.doc(request.uid)

View file

@ -1,5 +1,4 @@
import { showBackgroundLoader, hideBackgroundLoader } from "./dom-util";
let themesList = null;
export async function getThemesList() {
if (themesList == null) {

View file

@ -347,7 +347,7 @@ function activateFunbox(funbox, mode) {
if (config.keymapMode === "next") {
setKeymapMode("react");
}
} else if (funbox === "no_space") {
} else if (funbox === "nospace") {
$("#words").addClass("nospace");
restartTest(false, true);
}
@ -616,7 +616,7 @@ function emulateLayout(event) {
try {
if (config.layout === "default") {
//override the caps lock modifier for the default layout if needed
//override the caps lock modifier for the default layout if needed
if (config.capsLockBackspace && Misc.isASCIILetter(newEvent.key)) {
replaceEventKey(
newEvent,
@ -725,21 +725,23 @@ function punctuateWord(previousWord, currentWord, index, maxindex) {
} else if (
Math.random() < 0.01 &&
Misc.getLastChar(previousWord) != "," &&
Misc.getLastChar(previousWord) != "."
Misc.getLastChar(previousWord) != "." &&
config.language.split("_")[0] !== "russian"
) {
//1% chance to add quotes
word = `"${word}"`;
} else if (
Math.random() < 0.01 &&
getLastChar(previousWord) != "," &&
getLastChar(previousWord) != "."
Misc.getLastChar(previousWord) != "," &&
Misc.getLastChar(previousWord) != "." &&
config.language.split("_")[0] !== "russian"
) {
//1% chance to add single quotes
word = `'${word}'`;
} else if (
Math.random() < 0.01 &&
getLastChar(previousWord) != "," &&
getLastChar(previousWord) != "."
Misc.getLastChar(previousWord) != "," &&
Misc.getLastChar(previousWord) != "."
) {
//1% chance to add parentheses
word = `(${word})`;
@ -984,7 +986,8 @@ function compareInput(showError) {
}
let testNow = performance.now();
let testSeconds = Misc.roundTo2((testNow - testStart) / 1000);
incompleteTestSeconds += testSeconds;
let afkseconds = keypressPerSecond.filter((x) => x.count == 0).length;
incompleteTestSeconds += testSeconds - afkseconds;
restartCount++;
}
}
@ -1038,7 +1041,8 @@ function compareInput(showError) {
}
let testNow = performance.now();
let testSeconds = Misc.roundTo2((testNow - testStart) / 1000);
incompleteTestSeconds += testSeconds;
let afkseconds = keypressPerSecond.filter((x) => x.count == 0).length;
incompleteTestSeconds += testSeconds - afkseconds;
restartCount++;
}
if (!showError) {
@ -2002,6 +2006,7 @@ function showResult(difficultyFailed = false) {
incompleteTestSeconds: incompleteTestSeconds,
difficulty: config.difficulty,
testDuration: testtime,
afkDuration: afkseconds,
blindMode: config.blindMode,
theme: config.theme,
tags: activeTags,
@ -2133,10 +2138,14 @@ function showResult(difficultyFailed = false) {
db_getSnapshot().results.unshift(completedEvent);
if (db_getSnapshot().globalStats.time == undefined) {
db_getSnapshot().globalStats.time =
testtime + completedEvent.incompleteTestSeconds;
testtime +
completedEvent.incompleteTestSeconds -
afkseconds;
} else {
db_getSnapshot().globalStats.time +=
testtime + completedEvent.incompleteTestSeconds;
testtime +
completedEvent.incompleteTestSeconds -
afkseconds;
}
if (db_getSnapshot().globalStats.started == undefined) {
db_getSnapshot().globalStats.started = restartCount + 1;
@ -2323,6 +2332,7 @@ function showResult(difficultyFailed = false) {
if (e.data.resultCode === 2) {
//new pb
showCrown();
if (!localPb) {
}
db_saveLocalPB(
@ -2337,12 +2347,13 @@ function showResult(difficultyFailed = false) {
consistency
);
} else if (e.data.resultCode === 1) {
if (localPb) {
Misc.showNotification(
"Local PB data is out of sync! Refresh the page to resync it or contact Miodec on Discord.",
15000
);
}
hideCrown();
// if (localPb) {
// Misc.showNotification(
// "Local PB data is out of sync! Refresh the page to resync it or contact Miodec on Discord.",
// 15000
// );
// }
}
}
})
@ -4056,7 +4067,8 @@ $(document).on("keypress", "#restartTestButton", (event) => {
if (testActive) {
let testNow = performance.now();
let testSeconds = Misc.roundTo2((testNow - testStart) / 1000);
incompleteTestSeconds += testSeconds;
let afkseconds = keypressPerSecond.filter((x) => x.count == 0).length;
incompleteTestSeconds += testSeconds - afkseconds;
restartCount++;
}
restartTest();
@ -4256,7 +4268,9 @@ $(document).keydown((event) => {
if (testActive) {
let testNow = performance.now();
let testSeconds = Misc.roundTo2((testNow - testStart) / 1000);
incompleteTestSeconds += testSeconds;
let afkseconds = keypressPerSecond.filter((x) => x.count == 0)
.length;
incompleteTestSeconds += testSeconds - afkseconds;
restartCount++;
}
restartTest();
@ -4311,7 +4325,7 @@ $(document).keydown((event) => {
} else {
currentInput = inputHistory.pop();
currentCorrected = correctedHistory.pop();
if (activeFunBox === "no_space") {
if (activeFunBox === "nospace") {
currentInput = currentInput.substring(0, currentInput.length - 1);
}
}
@ -4414,7 +4428,9 @@ $(document).keydown((event) => {
showResult(true);
let testNow = performance.now();
let testSeconds = Misc.roundTo2((testNow - testStart) / 1000);
incompleteTestSeconds += testSeconds;
let afkseconds = keypressPerSecond.filter((x) => x.count == 0)
.length;
incompleteTestSeconds += testSeconds - afkseconds;
restartCount++;
return;
}
@ -4433,7 +4449,8 @@ $(document).keydown((event) => {
showResult(true);
let testNow = performance.now();
let testSeconds = Misc.roundTo2((testNow - testStart) / 1000);
incompleteTestSeconds += testSeconds;
let afkseconds = keypressPerSecond.filter((x) => x.count == 0).length;
incompleteTestSeconds += testSeconds - afkseconds;
restartCount++;
return;
} else if (currentWordIndex == wordsList.length) {
@ -4713,7 +4730,8 @@ $(document).keydown(function (event) {
showResult(true);
let testNow = performance.now();
let testSeconds = Misc.roundTo2((testNow - testStart) / 1000);
incompleteTestSeconds += testSeconds;
let afkseconds = keypressPerSecond.filter((x) => x.count == 0).length;
incompleteTestSeconds += testSeconds - afkseconds;
restartCount++;
return;
} else {
@ -4733,10 +4751,10 @@ $(document).keydown(function (event) {
compareInput(!config.blindMode);
if (
activeFunBox === "no_space" &&
activeFunBox === "nospace" &&
currentInput.length === wordsList[currentWordIndex].length
) {
jQuery.event.trigger({
$.event.trigger({
type: "keydown",
which: " ".charCodeAt(0),
key: " ",

View file

@ -1145,13 +1145,20 @@ function setTheme(name, nosave) {
let randomTheme = null;
function randomiseTheme() {
var randomList = Misc.getThemesList().map((t) => {
return t.name;
// var randomList = Misc.getThemesList().map((t) => {
// return t.name;
// });
var randomList;
Misc.getThemesList().then((themes) => {
randomList = themes.map((t) => {
return t.name;
});
if (config.randomTheme === "fav" && config.favThemes.length > 0)
randomList = config.favThemes;
randomTheme = randomList[Math.floor(Math.random() * randomList.length)];
setTheme(randomTheme, true);
});
if (config.randomTheme === "fav" && config.favThemes.length > 0)
randomList = config.favThemes;
randomTheme = randomList[Math.floor(Math.random() * randomList.length)];
setTheme(randomTheme, true);
}
function setRandomTheme(val, nosave) {

View file

@ -3200,7 +3200,7 @@ key {
}
.r5 {
grid-template-columns: 4.225fr 2fr 1fr 2fr 3fr;
grid-template-columns: 3.225fr 3fr 1fr 3fr 2fr;
}
#KeySpace2 {
opacity: 1;

View file

@ -83,10 +83,5 @@
"name": "memory",
"type": "script",
"info": "Test your memory. Remember the words and type them blind."
},
{
"name": "no_space",
"type": "script",
"info": "Whoneedsspacesanyway?"
}
]

View file

@ -2337,7 +2337,7 @@
<div class="section showAllLines">
<h1>show all lines</h1>
<div class="text">
When enabled, the website will show all lines for word,custom
When enabled, the website will show all lines for word, custom
and quote mode tests - otherwise the lines will be limited to
3, and will automatically scroll. Using this could cause the
timer text and live wpm to not be visible.

View file

@ -0,0 +1,114 @@
{
"name": "code_csharp",
"leftToRight": true,
"words": [
"abstract",
"as",
"base",
"bool",
"break",
"byte",
"case",
"catch ",
"char",
"checked",
"class",
"const ",
"continue",
"decimal",
"default",
"delegate",
"do",
"double",
"else",
"enum",
"even",
"explicit",
"extern",
"false",
"finally",
"fixed",
"float",
"for ",
"foreach",
"goto",
"if",
"implicit",
"in",
"init",
"int",
"interface",
"internal ",
"is",
"lock",
"long",
"namespace ",
"new",
"null",
"object",
"operator",
"out",
"override",
"params",
"private ",
"protected",
"public",
"readonly",
"ref ",
"return",
"sbyte",
"sealed",
"short ",
"sizeof",
"stackalloc",
"static",
"string",
"struct",
"switch",
"this",
"throw",
"true",
"try",
"typeof",
"uint ",
"ulong",
"unchecked",
"unsafe",
"ushort ",
"using",
"virtual",
"void",
"volatile",
"add",
"alias",
"ascending",
"async",
"await",
"by",
"descending",
"dynamic",
"equals",
"from",
"get",
"global",
"group",
"into",
"join",
"let",
"nameof",
"notnull",
"on",
"orderby",
"partial",
"remove",
"select",
"set",
"unmanaged",
"value",
"var",
"when",
"where",
"with",
"yield"
]
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
{
"name": "french",
"name": "french_1k",
"leftToRight": true,
"words": [
"a",

View file

@ -5,6 +5,7 @@
,"spanish"
,"spanish_1k"
,"french"
,"french_1k"
,"arabic"
,"mongolian"
,"mongolian_10k"
@ -34,6 +35,8 @@
,"icelandic_1k"
,"romanian"
,"finnish"
,"finnish_1k"
,"finnish_10k"
,"persian"
,"kazakh"
,"vietnamese"
@ -43,7 +46,8 @@
,"lojban_cmavo"
,"code_python"
,"code_c"
,"code_csharp"
,"code_javascript"
,"code_html"
,"code_java"
]
]

12
static/themes/darling.css Normal file
View file

@ -0,0 +1,12 @@
:root {
--bg-color: #fec8cd;
--main-color: #ffffff;
--caret-color: #ffffff;
--sub-color: #a30000;
--text-color: #ffffff;
--error-color: #2e7dde;
--error-extra-color: #2e7dde;
--colorful-error-color: #2e7dde;
--colorful-error-extra-color: #2e7dde;
--font: Roboto Mono;
}

View file

@ -438,5 +438,10 @@
"name": "onedark",
"bgColor": "#2f343f",
"textColor": "#98c379"
},
{
"name": "darling",
"bgColor": "#fec8cd",
"textColor": "#ffffff"
}
]