Merge branch 'master' into custom-theme

This commit is contained in:
Jack 2020-07-02 02:56:32 +01:00 committed by GitHub
commit 0eb78e9ca7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 10747 additions and 442 deletions

View file

@ -1,6 +0,0 @@
{
"projects": {
"default": "monkey-type-dev-67af4",
"live": "monkey-type"
}
}

5
.firebaserc_example Normal file
View file

@ -0,0 +1,5 @@
{
"projects": {
"default": "..."
}
}

1
.gitignore vendored
View file

@ -73,3 +73,4 @@ public/css/style.css
public/css/style.css.map
functions/serviceAccountKey.json
functions/serviceAccountKey_live.json
.firebaserc

View file

@ -1,5 +1,5 @@
# about
Monkey-type is a minimalistic typing test, featuring many test modes, an account system to save your typing speed history and user configurable features like themes, a smooth caret and more.
Monkey-type is a minimalistic, customisable typing test, featuring many test modes, an account system to save your typing speed history and user configurable features like themes, a smooth caret and more.
# features
- minimalistic design with no ads
@ -12,6 +12,7 @@ Monkey-type is a minimalistic typing test, featuring many test modes, an account
- smooth caret
- account system
- command line
- and much more
# keybinds
You can use `tab` and `enter` (or just `tab` if you have quick tab mode enabled) to restart the typing test. Open the command line by pressing `esc` - there you can access all the functionality you need without touching your mouse.
@ -33,9 +34,9 @@ If you wish to support further development and feeling extra awesome, you can do
# how to contribute
1. Head to [the firebase console](https://console.firebase.google.com/u/0/) and make a new project (the project name doesnt really matter, but just name it `monkey-type`). You dont need to enable analytics for it.
2. Install the [Firebase Command Line Interface](https://firebase.google.com/docs/cli), and use `firebase login` to log in to the same google account as you just used to make the project
3. Git clone the project and make sure the project name inside `.firebaserc` is the same as what you made it in step 1
4. Make sure you use a SCSS compiler. For VSCode I recommend `Live Sass Compiler` extension.
2. Install the [Firebase Command Line Interface](https://firebase.google.com/docs/cli), and use `firebase login` to log in to the same google account as you just used to make the project.
3. Git clone the project and make sure to rename `.firebaserc_example` to `.firebaserc` and changed the project name inside to your firebase project name.
4. Make sure you use a SCSS compiler. For VSCode I recommend `Easy Sass` or `Live Sass Compiler` extension.
5. Run `firebase serve --only hosting` to start a local server on post 5000. Use ctrl+c to stop it.
That should be it. If you run into any problems, let me know.

View file

@ -187,6 +187,9 @@ function checkIfPB(uid,obj){
let pbs = null;
try{
pbs = data.data().personalBests;
if(pbs === undefined){
throw new Error("pb is undefined");
}
}catch(e){
return admin.firestore().collection('users').doc(uid).update({
personalBests: {
@ -294,7 +297,7 @@ exports.testCompleted = functions.https.onCall((request,response) => {
}
})
if (err){
console.error(`error saving result for ${request.uid} - bad input`);
console.error(`error saving result for ${request.uid} - bad input - ${JSON.stringify(request.obj)}`);
return -1;
}
@ -303,7 +306,7 @@ exports.testCompleted = functions.https.onCall((request,response) => {
}
return admin.firestore().collection(`users/${request.uid}/results`).add(obj).then(e => {
// return 1;
return checkIfPB(request.uid,request.obj).then(e => {
if(e){
return 2;
@ -312,7 +315,7 @@ exports.testCompleted = functions.https.onCall((request,response) => {
}
});
}).catch(e => {
console.error(`error saving result for ${request.uid} - ${e.message}`);
console.error(`error saving result when checking for PB for ${request.uid} - ${e.message}`);
return -1;
});
}catch(e){
@ -423,4 +426,68 @@ exports.updateResultTags = functions.https.onCall((request,response) => {
console.error(`error updating tags by ${request.uid} - ${e}`);
return {resultCode:-999};
}
})
})
function isConfigKeyValid(name){
if(name === null || name === undefined || name === "") return false;
if(name.length > 20) return false;
return /^[0-9a-zA-Z_.-]+$/.test(name);
}
exports.saveConfig = functions.https.onCall((request,response) => {
try{
if(request.uid === undefined || request.obj === undefined){
console.error(`error saving config for ${request.uid} - missing input`);
return -1;
}
let obj = request.obj;
let err = false;
Object.keys(obj).forEach(key => {
let val = obj[key];
if(Array.isArray(val)){
val.forEach(valarr => {
if(!isConfigKeyValid(valarr)) err = true;
})
}else{
if(!isConfigKeyValid(val)) err = true;
}
})
if (err){
console.error(`error saving config for ${request.uid} - bad input - ${JSON.stringify(request.obj)}`);
return -1;
}
return admin.firestore().collection(`users`).doc(request.uid).set({
config: obj
}, {merge: true}).then(e => {
return 1;
}).catch(e => {
console.error(`error saving config to DB for ${request.uid} - ${e.message}`);
return -1;
});
}catch(e){
console.error(`error saving config for ${request.uid} - ${e}`);
return {resultCode:-999};
}
})
// exports.getConfig = functions.https.onCall((request,response) => {
// try{
// if(request.uid === undefined){
// console.error(`error getting config for ${request.uid} - missing input`);
// return -1;
// }
// return admin.firestore().collection(`users`).doc(request.uid).get().then(e => {
// return e.data().config;
// }).catch(e => {
// console.error(`error getting config from DB for ${request.uid} - ${e.message}`);
// return -1;
// });
// }catch(e){
// console.error(`error getting config for ${request.uid} - ${e}`);
// return {resultCode:-999};
// }
// })

View file

@ -361,6 +361,9 @@ a:hover {
line-height: 0.75rem;
}
.suggestions {
display: block;
overflow-y: scroll;
max-height: calc(100vh - 10rem - 3rem);
display: grid;
.entry {
padding: 0.5rem 1rem;
@ -373,13 +376,17 @@ a:hover {
&:last-child{
border-radius: 0 0 var(--roundness) var(--roundness);
}
&.active {
&.activeMouse {
color: var(--bg-color);
background: var(--main-color);
}
&.activeKeyboard {
color: var(--bg-color);
background: var(--main-color);
}
&:hover{
color: var(--bg-color);
background: var(--main-color);
color: var(--text-color);
background: var(--sub-color);
cursor: pointer;
}
}
@ -981,39 +988,39 @@ key {
}
}
#words.extraColor{
#words.colorfulMode{
.word{
& letter.correct{
color: var(--main-color);
}
& letter.incorrect{
color: var(--extra-error-color);
color: var(--colorful-error-color);
}
& letter.incorrect.extra{
color: var(--extra-error-extra-color);
color: var(--colorful-error-extra-color);
}
}
}
#words.flipped.extraColor{
#words.flipped.colorfulMode{
.word{
color: var(--main-color);
& letter.correct{
color: var(--sub-color);
}
& letter.incorrect{
color: var(--extra-error-color);
color: var(--colorful-error-color);
}
& letter.incorrect.extra{
color: var(--extra-error-extra-color);
color: var(--colorful-error-extra-color);
}
}
}
#words.flipped.extraColor .word.error,
#words.extraColor .word.error
#words.flipped.colorfulMode .word.error,
#words.colorfulMode .word.error
{
border-bottom: 2px solid var(--extra-error-color);
border-bottom: 2px solid var(--colorful-error-color);
}
.pageTest #resultExtraButtons{
@ -1698,7 +1705,28 @@ key {
}
}
.devIndicator{
position: fixed;
font-size: 3rem;
color: var(--sub-color);
opacity: .25;
&.tl{
top: 2rem;
left: 2rem;
}
&.tr{
top: 2rem;
right: 2rem;
}
&.bl{
bottom: 2rem;
left: 2rem;
}
&.br{
bottom: 2rem;
right: 2rem;
}
}
* {
box-sizing: border-box;

View file

@ -190,7 +190,7 @@
<div class="bottom">-</div>
</div>
<div class="group key">
<div class="top">key</div>
<div class="top">char</div>
<div class="bottom">-</div>
</div>
<div class="group time">
@ -198,7 +198,7 @@
<div class="bottom">-</div>
</div>
<div class="group raw">
<div class="top">raw wpm</div>
<div class="top">raw</div>
<div class="bottom">-</div>
</div>
<div class="group testType">
@ -226,14 +226,14 @@
<input id="wordsInput" class="" tabindex="0" autocomplete="off"></input>
<div id="wordsTitle">input history</div>
<div id="timerNumber">60</div>
<div id="words" class="extraColor"></div>
<div id="words" class=""></div>
<div id="liveWpm">123</div>
<div class="buttons">
<div id="restartTestButton" class="" tabindex="0" onclick="this.blur();"><i class="fas fa-fw fa-redo-alt"></i></div>
<div id="restartTestButton" aria-label="Restart test" data-balloon-pos="up" class="" tabindex="0" onclick="this.blur();"><i class="fas fa-fw fa-redo-alt"></i></div>
<div id="resultExtraButtons" class="hidden">
<div id="restartTestButtonWithSameWordset" tabindex="0" onclick="this.blur();"><i class="fas fa-fw fa-sync-alt"></i></div>
<div id="showWordHistoryButton" tabindex="0" onclick="this.blur();"><i class="fas fa-fw fa-align-left"></i></div>
<div id="copyResultToClipboardButton" tabindex="0" onclick="this.blur();"><i class="far fa-fw fa-image"></i></div>
<div id="restartTestButtonWithSameWordset" aria-label="Repeat test" data-balloon-pos="up" tabindex="0" onclick="this.blur();"><i class="fas fa-fw fa-sync-alt"></i></div>
<div id="showWordHistoryButton" aria-label="Show words history" data-balloon-pos="up" tabindex="0" onclick="this.blur();"><i class="fas fa-fw fa-align-left"></i></div>
<div id="copyResultToClipboardButton" aria-label="Save screenshot" data-balloon-pos="up" tabindex="0" onclick="this.blur();"><i class="far fa-fw fa-image"></i></div>
</div>
</div>
</div>
@ -292,7 +292,7 @@
</div>
<div class="section quickTab">
<h1>quick tab mode</h1>
<div class="text">Press <key>tab</key> to quickly restart the test. This function disables tab navigation on some parts of the website.</div>
<div class="text">Press <key>tab</key> to quickly restart the test, or to quickly jump to the test page. This function disables tab navigation on the website.</div>
<div class="buttons">
<div class="button on" tabindex="0" onclick="this.blur();">on</div>
<div class="button off" tabindex="0" onclick="this.blur();">off</div>
@ -400,10 +400,10 @@
<div class="button off" tabindex="0" onclick="this.blur();">off</div>
</div>
</div>
<div class="section extraTestColor">
<h1>extra test color</h1>
<div class="section colorfulMode">
<h1>colorful mode</h1>
<div class="text">
When enabled, the test words will use the main color, instead of the text color.
When enabled, the test words will use the main color, instead of the text color, making the website more colorful.
</div>
<div class="buttons">
<div class="button on" tabindex="0" onclick="this.blur();">on</div>
@ -630,7 +630,7 @@
</div>
</div>
<div class="group noDataError hidden">
No data found.
No data found. Check your filters.
</div>
<div class="group chart">
<!-- <div class="chartPreloader">
@ -755,6 +755,7 @@
</div>
</div>
</body>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="/__/firebase/7.14.3/firebase-app.js"></script>
@ -775,17 +776,17 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script> -->
<script src="js/chart.js"></script>
<script src="js/chartjs-plugin-trendline.js?v=20"></script>
<script src="js/chartjs-plugin-trendline.js?v=22"></script>
<script src="js/chartjs-plugin-annotation.js"></script>
<script src="js/html2canvas.js"></script>
<script src="js/words.js?v=20"></script>
<script src="js/layouts.js?v=20"></script>
<script src="js/db.js?v=20"></script>
<script src="js/userconfig.js?v=20"></script>
<script src="js/commandline.js?v=20"></script>
<script src="js/settings.js?v=20"></script>
<script src="js/account.js?v=20"></script>
<script src="js/script.js?v=20"></script>
<script src="js/words.js?v=22"></script>
<script src="js/layouts.js?v=22"></script>
<script src="js/db.js?v=22"></script>
<script src="js/userconfig.js?v=22"></script>
<script src="js/commandline.js?v=22"></script>
<script src="js/settings.js?v=22"></script>
<script src="js/account.js?v=22"></script>
<script src="js/script.js?v=22"></script>
</html>

View file

@ -78,6 +78,8 @@ function signIn() {
}
let dontCheckUserName = false;
function signUp() {
$(".pageLogin .preloader").removeClass('hidden');
let nname = $(".pageLogin .register input")[0].value;
@ -104,12 +106,14 @@ function signUp() {
}
firebase.auth().createUserWithEmailAndPassword(email, password).then(user => {
// Account has been created here.
dontCheckUserName = true;
let usr = user.user;
usr.updateProfile({
displayName: nname
}).then(function() {
// Update successful.
showNotification("Account created", 2000);
$("#menu .button.account .text").text(nname);
try{
firebase.analytics().logEvent("accountCreated", usr.uid);
}catch(e){
@ -171,6 +175,32 @@ firebase.auth().onAuthStateChanged(function(user) {
toggleFilterButton(filter);
}
})
refreshTagsSettingsSection();
if(cookieConfig === null){
applyConfig(dbSnapshot.config);
// showNotification('Applying db config',3000);
updateSettingsPage();
saveConfigToCookie();
}else{
let configsDifferent = false;
Object.keys(config).forEach(key => {
if(!configsDifferent){
try{
if(key !== 'resultFilters'){
if(config[key] != dbSnapshot.config[key]) configsDifferent = true;
}
}catch(e){
configsDifferent = true;
}
}
})
if(configsDifferent){
applyConfig(dbSnapshot.config);
// showNotification('Applying db config',3000);
updateSettingsPage();
saveConfigToCookie();
}
}
});
var displayName = user.displayName;
var email = user.email;
@ -181,7 +211,7 @@ firebase.auth().onAuthStateChanged(function(user) {
var providerData = user.providerData;
// showNotification('Signed in', 1000);
$(".pageLogin .preloader").addClass('hidden');
verifyUsername();
if(!dontCheckUserName) verifyUsername();
$("#menu .button.account .text").text(displayName);
}
});
@ -526,13 +556,20 @@ function loadMoreLines(){
// icons += `<span aria-label="${tagNames}" data-balloon-pos="up"><i class="fas fa-fw fa-tag"></i></span>`;
// }
let tagIcons = `<span id="resultEditTags" resultId="${result.id}" tags='${JSON.stringify(result.tags)}' style="opacity: .25"><i class="fas fa-fw fa-tag"></i></span>`;
let restags;
if(result.tags === undefined){
restags = '[]';
}else{
restags = JSON.stringify(result.tags)
}
let tagIcons = `<span id="resultEditTags" resultId="${result.id}" tags='${restags}' style="opacity: .25"><i class="fas fa-fw fa-tag"></i></span>`;
if(tagNames !== ""){
if(result.tags !== undefined && result.tags.length > 1){
tagIcons = `<span id="resultEditTags" resultId="${result.id}" tags='${JSON.stringify(result.tags)}' aria-label="${tagNames}" data-balloon-pos="up"><i class="fas fa-fw fa-tags"></i></span>`;
tagIcons = `<span id="resultEditTags" resultId="${result.id}" tags='${restags}' aria-label="${tagNames}" data-balloon-pos="up"><i class="fas fa-fw fa-tags"></i></span>`;
}else{
tagIcons = `<span id="resultEditTags" resultId="${result.id}" tags='${JSON.stringify(result.tags)}' aria-label="${tagNames}" data-balloon-pos="up"><i class="fas fa-fw fa-tag"></i></span>`;
tagIcons = `<span id="resultEditTags" resultId="${result.id}" tags='${restags}' aria-label="${tagNames}" data-balloon-pos="up"><i class="fas fa-fw fa-tag"></i></span>`;
}
}

View file

@ -13,6 +13,33 @@ let commands = {
restartTest();
}
},
{
id: "changeMode",
display: "Change mode...",
subgroup: true,
exec: () => {
currentCommands.push(commandsMode);
showCommandLine();
}
},
{
id: "changeTimeConfig",
display: "Change time config...",
subgroup: true,
exec: () => {
currentCommands.push(commandsTimeConfig);
showCommandLine();
}
},
{
id: "changeWordCount",
display: "Change word count...",
subgroup: true,
exec: () => {
currentCommands.push(commandsWordCount);
showCommandLine();
}
},
{
visible: false,
id: "changeTags",
@ -97,10 +124,10 @@ let commands = {
}
},
{
id: "toggleExtraTestColor",
display: "Toggle extra test color",
id: "toggleColorfulMode",
display: "Toggle colorful mode",
exec: () => {
toggleExtraTestColor();
toggleColorfulMode();
}
},
{
@ -114,7 +141,7 @@ let commands = {
},
{
id: "changeCaretStyle",
display: "Change caret...",
display: "Change caret style...",
subgroup: true,
exec: () => {
currentCommands.push(commandsCaretStyle);
@ -123,7 +150,7 @@ let commands = {
},
{
id: "changeTimerStyle",
display: "Change timer...",
display: "Change timer style...",
subgroup: true,
exec: () => {
currentCommands.push(commandsTimerStyle);
@ -166,33 +193,6 @@ let commands = {
showCommandLine();
}
},
{
id: "changeMode",
display: "Change mode...",
subgroup: true,
exec: () => {
currentCommands.push(commandsMode);
showCommandLine();
}
},
{
id: "changeTimeConfig",
display: "Change time config...",
subgroup: true,
exec: () => {
currentCommands.push(commandsTimeConfig);
showCommandLine();
}
},
{
id: "changeWordCount",
display: "Change word count...",
subgroup: true,
exec: () => {
currentCommands.push(commandsWordCount);
showCommandLine();
}
},
{
id: "joinDiscord",
display: "Join the Discord server",
@ -478,7 +478,7 @@ function updateCommandsTagsList(){
}
})
})
commands.list[1].visible = true;
commands.list[4].visible = true;
}
}
@ -532,6 +532,7 @@ let commandsLanguages = {
if (Object.keys(words).length > 0) {
commandsLanguages.list = [];
Object.keys(words).forEach(language => {
if(language === "english_10k") return;
commandsLanguages.list.push({
id: "changeLanguage" + capitalizeFirstLetter(language),
display: language.replace('_', ' '),
@ -541,6 +542,17 @@ if (Object.keys(words).length > 0) {
saveConfigToCookie();
}
})
if(language === "english_expanded"){
commandsLanguages.list.push({
id: "changeLanguageEnglish10k",
display: "english 10k",
exec: () => {
changeLanguage("english_10k");
restartTest();
saveConfigToCookie();
}
})
}
})
}
@ -599,6 +611,7 @@ $(document).ready(e => {
})
})
$("#commandInput textarea").keydown((e) => {
if (e.keyCode == 13 && e.shiftKey) {
//enter
@ -646,13 +659,20 @@ $("#commandLineWrapper #commandLine .suggestions").click(e =>{
triggerCommand($(e.target).attr('command'));
})
$('#commandLineWrapper').click(e => {
if($(e.target).attr('id') === "commandLineWrapper"){
hideCommandLine();
}
})
$(document).keydown((e) => {
if(!$("#commandLineWrapper").hasClass("hidden")){
$("#commandLine input").focus();
if (e.keyCode == 13) {
//enter
e.preventDefault();
let command = $(".suggestions .entry.active").attr("command");
let command = $(".suggestions .entry.activeKeyboard").attr("command");
triggerCommand(command);
return;
}
@ -662,28 +682,31 @@ $(document).keydown((e) => {
let activenum = -1;
let hoverId;
$.each(entries, (index, obj) => {
if ($(obj).hasClass("active")) activenum = index;
if ($(obj).hasClass("activeKeyboard")) activenum = index;
});
if (e.keyCode == 38) {
entries.removeClass("active");
entries.removeClass("activeKeyboard");
if (activenum == 0) {
$(entries[entries.length - 1]).addClass("active");
$(entries[entries.length - 1]).addClass("activeKeyboard");
hoverId = $(entries[entries.length - 1]).attr('command');
} else {
$(entries[--activenum]).addClass("active");
$(entries[--activenum]).addClass("activeKeyboard");
hoverId = $(entries[activenum]).attr('command');
}
}
if (e.keyCode == 40) {
entries.removeClass("active");
entries.removeClass("activeKeyboard");
if (activenum + 1 == entries.length) {
$(entries[0]).addClass("active");
$(entries[0]).addClass("activeKeyboard");
hoverId = $(entries[0]).attr('command');
} else {
$(entries[++activenum]).addClass("active");
$(entries[++activenum]).addClass("activeKeyboard");
hoverId = $(entries[activenum]).attr('command');
}
}
let scroll = Math.abs($('.suggestions').offset().top - $('.entry.activeKeyboard').offset().top - $('.suggestions').scrollTop()) - ($('.suggestions').outerHeight() / 2) + ($($('.entry')[0]).outerHeight());
$('.suggestions').scrollTop(scroll);
console.log(`scrolling to ${scroll}`);
try {
let list = currentCommands[currentCommands.length-1];
$.each(list.list, (index, obj) => {
@ -830,7 +853,7 @@ function hideCommandLine() {
}
let entries = $("#commandLine .suggestions .entry");
if (entries.length > 0) {
$(entries[0]).addClass("active");
$(entries[0]).addClass("activeKeyboard");
try{
$.each(list.list, (index, obj) => {
if (obj.found) {

View file

@ -47,7 +47,10 @@ async function db_getUserSnapshot() {
.then(data => {
// console.log('getting data from db!');
try{
snap.personalBests = data.data().personalBests;
if(data.data().personalBests !== undefined){
snap.personalBests = data.data().personalBests;
}
snap.config = data.data().config;
}catch(e){
//
}

10000
public/js/english_10k.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -27,5 +27,12 @@ const layouts = {
"aA","sS","hH","tT","gG","yY","nN","eE","oO","iI","'\"",
"zZ","xX","mM","cC","vV","kK","lL",",<",".>","/?",
" "
],
turkish_f: [
"*+","1!","2\"","3^","4$","5%","6&","7'","8(","9)","0=","/?","-_",
"fF","gG","ğĞ","ıI","oO","dD","rR","nN","hH","pP","qQ","wW","xX",
"uU","iİ","eE","aA","üÜ","tT","kK","mM","lL","yY","şŞ",
"jJ","öÖ","vV","cC","çÇ","zZ","sS","bB",".:",",;",
" "
]
}
}

View file

@ -28,13 +28,15 @@ let accuracyStats = {
incorrect: 0
}
let customText = "The quick brown fox jumps over the lazy dog";
let customText = "The quick brown fox jumps over the lazy dog".split(' ');
const testCompleted = firebase.functions().httpsCallable('testCompleted');
const addTag = firebase.functions().httpsCallable('addTag');
const editTag = firebase.functions().httpsCallable('editTag');
const removeTag = firebase.functions().httpsCallable('removeTag');
const updateResultTags = firebase.functions().httpsCallable('updateResultTags');
const saveConfig = firebase.functions().httpsCallable('saveConfig');
function smooth(arr, windowSize, getter = (value) => value, setter) {
const get = getter
@ -218,6 +220,19 @@ function initWords() {
currentInput = "";
let language = words[config.language];
if(language === undefined && config.language === "english_10k"){
showBackgroundLoader();
$.ajax({
url: "js/english_10k.json",
async: false,
success: function (data) {
hideBackgroundLoader();
words['english_10k'] = data;
language = words[config.language];
}
})
}
if (language == undefined || language == []) {
config.language = "english";
@ -230,7 +245,8 @@ function initWords() {
for (let i = 0; i < wordsBound; i++) {
randomWord = language[Math.floor(Math.random() * language.length)];
previousWord = wordsList[i - 1];
while (randomWord == previousWord || (!config.punctuation && randomWord == "I") || randomWord.indexOf(' ') > -1) {
previousWord2 = wordsList[i - 2];
while (randomWord == previousWord || randomWord == previousWord2 || (!config.punctuation && randomWord == "I") || randomWord.indexOf(' ') > -1) {
randomWord = language[Math.floor(Math.random() * language.length)];
}
if (config.punctuation && config.mode != "custom"){
@ -240,16 +256,16 @@ function initWords() {
}
} else if (config.mode == "custom") {
let w = customText.split(" ");
for (let i = 0; i < w.length; i++) {
wordsList.push(w[i]);
// let w = customText.split(" ");
for (let i = 0; i < customText.length; i++) {
wordsList.push(customText[i]);
}
}
showWords();
}
function emulateLayout(event){
if (config.layout == "default")
if (config.layout == "default" || event.key === " ")
return event;
const qwertyMasterLayout = {"Backquote":"`~","Digit1":"1!","Digit2":"2@","Digit3":"3#","Digit4":"4$","Digit5":"5%","Digit6":"6^","Digit7":"7&","Digit8":"8*","Digit9":"9(","Digit0":"0)","Minus":"-_","Equal":"=+","KeyQ":"qQ","KeyW":"wW","KeyE":"eE","KeyR":"rR","KeyT":"tT","KeyY":"yY","KeyU":"uU","KeyI":"iI","KeyO":"oO","KeyP":"pP","BracketLeft":"[{","BracketRight":"]}","KeyA":"aA","KeyS":"sS","KeyD":"dD","KeyF":"fF","KeyG":"gG","KeyH":"hH","KeyJ":"jJ","KeyK":"kK","KeyL":"lL","Semicolon":";:","Quote":"'\"","Backslash":"\\|","KeyZ":"zZ","KeyX":"xX","KeyC":"cC","KeyV":"vV","KeyB":"bB","KeyN":"nN","KeyM":"mM","Comma":",<","Period":".>","Slash":"/?","Space":" "}
let layoutMap = layouts[config.layout];
@ -714,13 +730,15 @@ function showResult(difficultyFailed = false) {
});
let mode2 = "";
if (config.mode == "time") {
if (config.mode === "time") {
mode2 = config.time;
// $("#result .stats .time").addClass('hidden');
} else if (config.mode == "words") {
} else if (config.mode === "words") {
mode2 = config.words;
// $("#result .stats .time").removeClass('hidden');
// $("#result .stats .time .bottom").text(roundedToFixed(stats.time,1)+'s');
} else if (config.mode === "custom"){
mode2 = "custom";
}
@ -730,123 +748,6 @@ function showResult(difficultyFailed = false) {
$("#result .loginTip").removeClass('hidden');
}
if(difficultyFailed){
showNotification("Test failed",2000);
}else if(afkDetected){
showNotification("Test invalid - AFK detected",2000);
}else if(sameWordset){
showNotification("Test invalid - repeated",2000);
}else{
let activeTags = [];
try{
dbSnapshot.tags.forEach(tag => {
if(tag.active === true){
activeTags.push(tag.id);
}
})
}catch(e){
}
let completedEvent = {
wpm: stats.wpm,
rawWpm: stats.wpmRaw,
correctChars: stats.correctChars + stats.spaces,
incorrectChars: stats.incorrectChars,
acc: stats.acc,
mode: config.mode,
mode2: mode2,
punctuation: config.punctuation,
timestamp: Date.now(),
language: config.language,
restartCount: restartCount,
incompleteTestSeconds: incompleteTestSeconds,
difficulty: config.difficulty,
testDuration: testtime,
blindMode: config.blindMode,
theme: config.theme,
tags: activeTags
};
if(config.difficulty == "normal" || ((config.difficulty == "master" || config.difficulty == "expert") && !difficultyFailed)){
// console.log(incompleteTestSeconds);
// console.log(restartCount);
restartCount = 0;
incompleteTestSeconds = 0;
}
if (stats.wpm > 0 && stats.wpm < 350 && stats.acc > 50 && stats.acc <= 100) {
if (firebase.auth().currentUser != null) {
completedEvent.uid = firebase.auth().currentUser.uid;
//check local pb
let localPb = false;
let dontShowCrown = false;
db_getLocalPB(config.mode,mode2,config.punctuation,config.language,config.difficulty).then(d => {
db_getUserHighestWpm(config.mode,mode2,config.punctuation,config.language,config.difficulty).then(d2 => {
if(d < stats.wpm && stats.wpm < d2){
dontShowCrown = true;
}
if(d < stats.wpm){
//new pb based on local
if(!dontShowCrown){
hideCrown();
showCrown();
}
localPb = true;
}
wpmOverTimeChart.options.annotation.annotations[0].value = d2;
wpmOverTimeChart.options.annotation.annotations[0].label.content = "PB: "+ d2;
wpmOverTimeChart.update();
})
})
accountIconLoading(true);
testCompleted({uid:firebase.auth().currentUser.uid,obj:completedEvent}).then(e => {
accountIconLoading(false);
if(e.data === -1){
showNotification('Could not save result',3000);
}else if(e.data === 1 || e.data === 2){
dbSnapshot.results.unshift(completedEvent);
try{
firebase.analytics().logEvent('testCompleted', completedEvent);
}catch(e){
console.log("Analytics unavailable");
}
if(e.data === 2){
//new pb
if(!localPb){
showNotification('Local PB data is out of sync! Resyncing.',5000);
}
db_saveLocalPB(config.mode,mode2,config.punctuation,config.language,config.difficulty,stats.wpm);
}else{
if(localPb){
showNotification('Local PB data is out of sync! Refresh the page to resync it or contact Miodec on Discord.',15000);
}
}
}
})
} else {
try{
firebase.analytics().logEvent('testCompletedNoLogin', completedEvent);
}catch(e){
console.log("Analytics unavailable");
}
// showNotification("Sign in to save your result",3000);
}
} else {
showNotification("Test invalid", 3000);
testInvalid = true;
try{
firebase.analytics().logEvent('testCompletedInvalid', completedEvent);
}catch(e){
console.log("Analytics unavailable");
}
}
}
let testType = "";
@ -948,36 +849,144 @@ function showResult(difficultyFailed = false) {
wpmOverTimeChart.options.annotation.annotations[0].borderColor = subColor;
wpmOverTimeChart.options.annotation.annotations[0].label.backgroundColor = subColor;
wpmOverTimeChart.options.annotation.annotations[0].label.fontColor = bgColor;
// let maxVal = 0;
// rawWpmPerSecond.forEach(raw =>{
// if(raw >= maxVal){
// maxVal = raw;
// }
// })
let maxVal = Math.max(...[Math.max(...rawWpmPerSecond),Math.max(...wpmHistory)]);
wpmOverTimeChart.options.scales.yAxes[0].ticks.max = maxVal;
wpmOverTimeChart.options.scales.yAxes[1].ticks.max = maxVal;
let maxChartVal = Math.max(...[Math.max(...rawWpmPerSecond),Math.max(...wpmHistory)]);
let errorsNoZero = [];
for(let i = 0; i < errorsPerSecond.length; i++){
// if(errorsPerSecond[i] != 0){
errorsNoZero.push({
x: i+1,
y: errorsPerSecond[i]
});
// }
}
wpmOverTimeChart.data.datasets[2].data = errorsNoZero;
if(difficultyFailed){
showNotification("Test failed",2000);
}else if(afkDetected){
showNotification("Test invalid - AFK detected",2000);
}else if(sameWordset){
showNotification("Test invalid - repeated",2000);
}else{
let activeTags = [];
try{
dbSnapshot.tags.forEach(tag => {
if(tag.active === true){
activeTags.push(tag.id);
}
})
}catch(e){
}
let completedEvent = {
wpm: stats.wpm,
rawWpm: stats.wpmRaw,
correctChars: stats.correctChars + stats.spaces,
incorrectChars: stats.incorrectChars,
acc: stats.acc,
mode: config.mode,
mode2: mode2,
punctuation: config.punctuation,
timestamp: Date.now(),
language: config.language,
restartCount: restartCount,
incompleteTestSeconds: incompleteTestSeconds,
difficulty: config.difficulty,
testDuration: testtime,
blindMode: config.blindMode,
theme: config.theme,
tags: activeTags
};
if(config.difficulty == "normal" || ((config.difficulty == "master" || config.difficulty == "expert") && !difficultyFailed)){
// console.log(incompleteTestSeconds);
// console.log(restartCount);
restartCount = 0;
incompleteTestSeconds = 0;
}
if (stats.wpm > 0 && stats.wpm < 350 && stats.acc > 50 && stats.acc <= 100) {
if (firebase.auth().currentUser != null) {
completedEvent.uid = firebase.auth().currentUser.uid;
//check local pb
accountIconLoading(true);
let localPb = false;
let dontShowCrown = false;
db_getLocalPB(config.mode,mode2,config.punctuation,config.language,config.difficulty).then(lpb => {
db_getUserHighestWpm(config.mode,mode2,config.punctuation,config.language,config.difficulty).then(highestwpm => {
if(lpb < stats.wpm && stats.wpm < highestwpm){
dontShowCrown = true;
}
if(lpb < stats.wpm){
//new pb based on local
if(!dontShowCrown){
hideCrown();
showCrown();
}
localPb = true;
}
if(highestwpm > 0){
wpmOverTimeChart.options.annotation.annotations[0].value = highestwpm;
wpmOverTimeChart.options.annotation.annotations[0].label.content = "PB: "+ highestwpm;
if(maxChartVal >= highestwpm - 15 && maxChartVal <= highestwpm + 15){
maxChartVal = highestwpm + 15;
}
wpmOverTimeChart.options.scales.yAxes[0].ticks.max = Math.round(maxChartVal);
wpmOverTimeChart.options.scales.yAxes[1].ticks.max = Math.round(maxChartVal);
wpmOverTimeChart.update({ duration: 0 });
}
testCompleted({uid:firebase.auth().currentUser.uid,obj:completedEvent}).then(e => {
accountIconLoading(false);
if(e.data === -1){
showNotification('Could not save result',3000);
}else if(e.data === 1 || e.data === 2){
dbSnapshot.results.unshift(completedEvent);
try{
firebase.analytics().logEvent('testCompleted', completedEvent);
}catch(e){
console.log("Analytics unavailable");
}
if(e.data === 2){
//new pb
if(!localPb){
showNotification('Local PB data is out of sync! Resyncing.',5000);
}
db_saveLocalPB(config.mode,mode2,config.punctuation,config.language,config.difficulty,stats.wpm);
}else{
if(localPb){
showNotification('Local PB data is out of sync! Refresh the page to resync it or contact Miodec on Discord.',15000);
}
}
}
})
})
})
} else {
try{
firebase.analytics().logEvent('testCompletedNoLogin', completedEvent);
}catch(e){
console.log("Analytics unavailable");
}
// showNotification("Sign in to save your result",3000);
}
} else {
showNotification("Test invalid", 3000);
testInvalid = true;
try{
firebase.analytics().logEvent('testCompletedInvalid', completedEvent);
}catch(e){
console.log("Analytics unavailable");
}
}
}
wpmOverTimeChart.options.scales.yAxes[0].ticks.max = maxChartVal;
wpmOverTimeChart.options.scales.yAxes[1].ticks.max = maxChartVal;
wpmOverTimeChart.update({ duration: 0 });
swapElements($("#words"),$("#result"),250, () => {
@ -1126,6 +1135,12 @@ function changeCustomText() {
customText = prompt("Custom text").trim();
customText = customText.replace(/[\n\r\t ]/gm, ' ');
customText = customText.replace(/ +/gm, ' ');
customText = customText.split(' ');
if(customText.length > 10000){
showNotification('Custom text cannot be longer than 10000 words.',4000);
changeMode('time');
customText = "The quick brown fox jumped over the lazy dog".split(' ');
}
// initWords();
}
@ -1160,7 +1175,7 @@ function changePage(page) {
});
hideTestConfig();
hideSignOutButton();
} else if (page == "settings") {
} else if (page == "settings") {
pageTransition = true;
swapElements(activePage, $(".page.pageSettings"), 250, ()=>{
pageTransition = false;
@ -1372,11 +1387,11 @@ function flipTestColors(tf){
}
}
function applyExtraTestColor(tc){
function applyColorfulMode(tc){
if(tc){
$("#words").addClass('extraColor');
$("#words").addClass('colorfulMode');
}else{
$("#words").removeClass('extraColor');
$("#words").removeClass('colorfulMode');
}
}
@ -1732,7 +1747,7 @@ $(document).keypress(function(event) {
if (event["keyCode"] == 27) return;
if (event["keyCode"] == 93) return;
//start the test
if (currentInput == "" && inputHistory.length == 0) {
if (currentInput == "" && inputHistory.length == 0 && !testActive) {
try{
if (firebase.auth().currentUser != null) {
firebase.analytics().logEvent('testStarted');
@ -1812,15 +1827,19 @@ $(document).keydown((event) => {
//tab
if (event["keyCode"] == 9) {
if (config.quickTab && $(".pageTest").hasClass("active")) {
if (config.quickTab) {
event.preventDefault();
if (testActive && !afkDetected) {
let testNow = Date.now();
let testSeconds = roundTo2((testNow - testStart) / 1000);
incompleteTestSeconds += testSeconds;
restartCount++;
if($(".pageTest").hasClass("active")){
if (testActive && !afkDetected) {
let testNow = Date.now();
let testSeconds = roundTo2((testNow - testStart) / 1000);
incompleteTestSeconds += testSeconds;
restartCount++;
}
restartTest();
}else{
changePage('test');
}
restartTest();
}
}
@ -1940,7 +1959,15 @@ getReleasesFromGitHub();
if (firebase.app().options.projectId === "monkey-type-dev-67af4") {
$("#top .logo .bottom").text("monkey-dev");
$("head title").text("Monkey Dev")
$("head title").text("Monkey Dev");
$('body').append(`
<div class="devIndicator tr">
DEV
</div>
<div class="devIndicator bl">
DEV
</div>
`);
}
if (window.location.hostname === "localhost") {
@ -1950,6 +1977,12 @@ if (window.location.hostname === "localhost") {
$("#top .logo .top").text("localhost");
$("head title").text($("head title").text() + " (localhost)");
firebase.functions().useFunctionsEmulator("http://localhost:5001");
$('body').append(`<div class="devIndicator tl">
local
</div>
<div class="devIndicator br">
local
</div>`);
}
$(document).on('mouseenter','#words .word',e =>{

View file

@ -7,7 +7,11 @@ function updateSettingsPage(){
let langEl = $(".pageSettings .section.languages .buttons").empty();
Object.keys(words).forEach(language => {
if(language === "english_10k") return;
langEl.append(`<div class="language" language='${language}'>${language.replace('_', ' ')}</div>`);
if(language === "english_expanded"){
langEl.append(`<div class="language" language='english_10k'>english 10k</div>`);
}
})
let layoutEl = $(".pageSettings .section.layouts .buttons").empty();
@ -15,6 +19,41 @@ function updateSettingsPage(){
layoutEl.append(`<div class="layout button" layout='${layout}'>${layout.replace('_', ' ')}</div>`);
});
refreshTagsSettingsSection();
setSettingsButton('smoothCaret', config.smoothCaret);
setSettingsButton('quickTab', config.quickTab);
setSettingsButton('liveWpm', config.showLiveWpm);
setSettingsButton('timerBar', config.showTimerBar)
setSettingsButton('keyTips', config.showKeyTips);
setSettingsButton('freedomMode', config.freedomMode);
setSettingsButton('blindMode', config.blindMode);
setSettingsButton('quickEnd', config.quickEnd);
setSettingsButton('flipTestColors', config.flipTestColors);
setSettingsButton('discordDot', config.showDiscordDot);
setSettingsButton('colorfulMode', config.colorfulMode);
setSettingsButton('maxConfidence', config.maxConfidence);
setActiveThemeButton();
setActiveLanguageButton();
setActiveLayoutButton();
setActiveFontSizeButton();
setActiveDifficultyButton();
setActiveCaretStyleButton();
setActiveTimerStyleButton();
if (config.showKeyTips) {
$(".pageSettings .tip").removeClass('hidden');
} else {
$(".pageSettings .tip").addClass('hidden');
}
}
function refreshTagsSettingsSection(){
if(firebase.auth().currentUser !== null && dbSnapshot !== null){
let tagsEl = $(".pageSettings .section.tags .tagsList").empty();
dbSnapshot.tags.forEach(tag => {
@ -51,40 +90,6 @@ function updateSettingsPage(){
}else{
$(".pageSettings .section.tags").addClass('hidden');
}
setSettingsButton('smoothCaret', config.smoothCaret);
setSettingsButton('quickTab', config.quickTab);
setSettingsButton('liveWpm', config.showLiveWpm);
setSettingsButton('timerBar', config.showTimerBar)
setSettingsButton('keyTips', config.showKeyTips);
setSettingsButton('freedomMode', config.freedomMode);
setSettingsButton('blindMode', config.blindMode);
setSettingsButton('quickEnd', config.quickEnd);
setSettingsButton('flipTestColors', config.flipTestColors);
setSettingsButton('discordDot', config.showDiscordDot);
setSettingsButton('extraTestColor', config.extraTestColor);
setSettingsButton('maxConfidence', config.maxConfidence);
setActiveThemeButton();
setActiveThemeTab();
setCustomThemeInputs();
setActiveLanguageButton();
setActiveLayoutButton();
setActiveFontSizeButton();
setActiveDifficultyButton();
setActiveCaretStyleButton();
setActiveTimerStyleButton();
if (config.showKeyTips) {
$(".pageSettings .tip").removeClass('hidden');
} else {
$(".pageSettings .tip").addClass('hidden');
}
}
function setActiveThemeButton() {
@ -197,24 +202,24 @@ function toggleTag(tagid, nosave = false){
//smooth caret
$(".pageSettings .section.smoothCaret .buttons .button.on").click(e => {
setSmoothCaret(true);
showNotification('Smooth caret on', 1000);
// showNotification('Smooth caret on', 1000);
setSettingsButton('smoothCaret', config.smoothCaret);
})
$(".pageSettings .section.smoothCaret .buttons .button.off").click(e => {
setSmoothCaret(false);
showNotification('Smooth caret off', 1000);
// showNotification('Smooth caret off', 1000);
setSettingsButton('smoothCaret', config.smoothCaret);
})
//quick tab
$(".pageSettings .section.quickTab .buttons .button.on").click(e => {
setQuickTabMode(true);
showNotification('Quick tab on', 1000);
// showNotification('Quick tab on', 1000);
setSettingsButton('quickTab', config.quickTab);
})
$(".pageSettings .section.quickTab .buttons .button.off").click(e => {
setQuickTabMode(false);
showNotification('Quick tab off', 1000);
// showNotification('Quick tab off', 1000);
setSettingsButton('quickTab', config.quickTab);
})
@ -222,13 +227,13 @@ $(".pageSettings .section.quickTab .buttons .button.off").click(e => {
$(".pageSettings .section.liveWpm .buttons .button.on").click(e => {
config.showLiveWpm = true;
saveConfigToCookie();
showNotification('Live WPM on', 1000);
// showNotification('Live WPM on', 1000);
setSettingsButton('liveWpm', config.showLiveWpm);
})
$(".pageSettings .section.liveWpm .buttons .button.off").click(e => {
config.showLiveWpm = false;
saveConfigToCookie();
showNotification('Live WPM off', 1000);
// showNotification('Live WPM off', 1000);
setSettingsButton('liveWpm', config.showLiveWpm);
})
@ -236,13 +241,13 @@ $(".pageSettings .section.liveWpm .buttons .button.off").click(e => {
$(".pageSettings .section.timerBar .buttons .button.on").click(e => {
config.showTimerBar = true;
saveConfigToCookie();
showNotification('Timer bar on', 1000);
// showNotification('Timer bar on', 1000);
setSettingsButton('timerBar', config.showTimerBar);
})
$(".pageSettings .section.timerBar .buttons .button.off").click(e => {
config.showTimerBar = false;
saveConfigToCookie();
showNotification('Timer bar off', 1000);
// showNotification('Timer bar off', 1000);
setSettingsButton('timerBar', config.showTimerBar);
})
@ -250,14 +255,14 @@ $(".pageSettings .section.timerBar .buttons .button.off").click(e => {
$(".pageSettings .section.freedomMode .buttons .button.on").click(e => {
setFreedomMode(true);
saveConfigToCookie();
showNotification('Freedom mode on', 1000);
// showNotification('Freedom mode on', 1000);
setSettingsButton('freedomMode', config.freedomMode);
setSettingsButton('maxConfidence', config.maxConfidence);
})
$(".pageSettings .section.freedomMode .buttons .button.off").click(e => {
setFreedomMode(false);
saveConfigToCookie();
showNotification('Freedom mode off', 1000);
// showNotification('Freedom mode off', 1000);
setSettingsButton('freedomMode', config.freedomMode);
setSettingsButton('maxConfidence', config.maxConfidence);
})
@ -266,14 +271,14 @@ $(".pageSettings .section.freedomMode .buttons .button.off").click(e => {
$(".pageSettings .section.maxConfidence .buttons .button.on").click(e => {
setMaxConfidence(true);
saveConfigToCookie();
showNotification('Max confidence on', 1000);
// showNotification('Max confidence on', 1000);
setSettingsButton('freedomMode', config.freedomMode);
setSettingsButton('maxConfidence', config.maxConfidence);
})
$(".pageSettings .section.maxConfidence .buttons .button.off").click(e => {
setMaxConfidence(false);
saveConfigToCookie();
showNotification('Max confidence off', 1000);
// showNotification('Max confidence off', 1000);
setSettingsButton('freedomMode', config.freedomMode);
setSettingsButton('maxConfidence', config.maxConfidence);
})
@ -281,7 +286,7 @@ $(".pageSettings .section.maxConfidence .buttons .button.off").click(e => {
//keytips
$(".pageSettings .section.keyTips .buttons .button.on").click(e => {
setKeyTips(true);
showNotification('Key tips on', 1000);
// showNotification('Key tips on', 1000);
setSettingsButton('keyTips', config.showKeyTips);
if (config.showKeyTips) {
$(".pageSettings .tip").removeClass('hidden');
@ -291,7 +296,7 @@ $(".pageSettings .section.keyTips .buttons .button.on").click(e => {
})
$(".pageSettings .section.keyTips .buttons .button.off").click(e => {
setKeyTips(false);
showNotification('Key tips off', 1000);
// showNotification('Key tips off', 1000);
setSettingsButton('keyTips', config.showKeyTips);
if (config.showKeyTips) {
$(".pageSettings .tip").removeClass('hidden');
@ -330,7 +335,7 @@ $(document).on("click",".pageSettings .section.themes .theme", (e) => {
$(document).on("click",".pageSettings .section.languages .language", (e) => {
let language = $(e.currentTarget).attr('language');
changeLanguage(language);
showNotification('Language changed', 1000);
// showNotification('Language changed', 1000);
restartTest();
setActiveLanguageButton();
})
@ -340,7 +345,7 @@ $(document).on("click",".pageSettings .section.layouts .layout", (e) => {
console.log("clicked")
let layout = $(e.currentTarget).attr('layout');
changeLayout(layout);
showNotification('Layout changed', 1000);
// showNotification('Layout changed', 1000);
restartTest();
setActiveLayoutButton();
})
@ -349,7 +354,7 @@ $(document).on("click",".pageSettings .section.layouts .layout", (e) => {
$(document).on("click",".pageSettings .section.fontSize .button", (e) => {
let fontSize = $(e.currentTarget).attr('fontsize');
changeFontSize(fontSize);
showNotification('Font size changed', 1000);
// showNotification('Font size changed', 1000);
setActiveFontSizeButton();
})
@ -357,7 +362,7 @@ $(document).on("click",".pageSettings .section.fontSize .button", (e) => {
$(document).on("click",".pageSettings .section.difficulty .button", (e) => {
let difficulty = $(e.currentTarget).attr('difficulty');
setDifficulty(difficulty);
showNotification('Difficulty changed', 1000);
// showNotification('Difficulty changed', 1000);
setActiveDifficultyButton();
})
@ -365,7 +370,7 @@ $(document).on("click",".pageSettings .section.difficulty .button", (e) => {
$(document).on("click",".pageSettings .section.caretStyle .button", (e) => {
let caretStyle = $(e.currentTarget).attr('caret');
setCaretStyle(caretStyle);
showNotification('Caret style updated', 1000);
// showNotification('Caret style updated', 1000);
setActiveCaretStyleButton();
})
@ -373,7 +378,7 @@ $(document).on("click",".pageSettings .section.caretStyle .button", (e) => {
$(document).on("click",".pageSettings .section.timerStyle .button", (e) => {
let timerStyle = $(e.currentTarget).attr('timer');
setTimerStyle(timerStyle);
showNotification('Timer style updated', 1000);
// showNotification('Timer style updated', 1000);
setActiveTimerStyleButton();
})
@ -381,49 +386,49 @@ $(document).on("click",".pageSettings .section.timerStyle .button", (e) => {
//blind mode
$(".pageSettings .section.blindMode .buttons .button.on").click(e => {
setBlindMode(true);
showNotification('Blind mode on', 1000);
// showNotification('Blind mode on', 1000);
setSettingsButton('blindMode', config.blindMode);
})
$(".pageSettings .section.blindMode .buttons .button.off").click(e => {
setBlindMode(false);
showNotification('Blind mode off', 1000);
// showNotification('Blind mode off', 1000);
setSettingsButton('blindMode', config.blindMode);
})
//blind mode
$(".pageSettings .section.quickEnd .buttons .button.on").click(e => {
setQuickEnd(true);
showNotification('Quick end on', 1000);
// showNotification('Quick end on', 1000);
setSettingsButton('quickEnd', config.quickEnd);
})
$(".pageSettings .section.quickEnd .buttons .button.off").click(e => {
setQuickEnd(false);
showNotification('Quick end off', 1000);
// showNotification('Quick end off', 1000);
setSettingsButton('quickEnd', config.quickEnd);
})
//flip test
$(".pageSettings .section.flipTestColors .buttons .button.on").click(e => {
setFlipTestColors(true);
showNotification('Flip test colors on', 1000);
// showNotification('Flip test colors on', 1000);
setSettingsButton('flipTestColors', config.flipTestColors);
})
$(".pageSettings .section.flipTestColors .buttons .button.off").click(e => {
setFlipTestColors(false);
showNotification('Flip test colors off', 1000);
// showNotification('Flip test colors off', 1000);
setSettingsButton('flipTestColors', config.flipTestColors);
})
//extra color
$(".pageSettings .section.extraTestColor .buttons .button.on").click(e => {
setExtraTestColor(true);
showNotification('Extra test color on', 1000);
setSettingsButton('extraTestColor', config.extraTestColor);
$(".pageSettings .section.colorfulMode .buttons .button.on").click(e => {
setColorfulMode(true);
// showNotification('Colorful mode on', 1000);
setSettingsButton('colorfulMode', config.colorfulMode);
})
$(".pageSettings .section.extraTestColor .buttons .button.off").click(e => {
setExtraTestColor(false);
showNotification('Extra test color off', 1000);
setSettingsButton('extraTestColor', config.extraTestColor);
$(".pageSettings .section.colorfulMode .buttons .button.off").click(e => {
setColorfulMode(false);
// showNotification('Colorful mode off', 1000);
setSettingsButton('colorfulMode', config.colorfulMode);
})
//tags

View file

@ -23,9 +23,12 @@ let defaultConfig = {
layout:"default",
showDiscordDot: true,
maxConfidence: false,
timerStyle: "bar"
timerStyle: "bar",
colorfulMode: true
}
let cookieConfig = null;
let config = defaultConfig;
//cookies
@ -38,6 +41,20 @@ function saveConfigToCookie() {
path: '/'
});
restartCount = 0;
saveConfigToDB();
}
function saveConfigToDB(){
if(firebase.auth().currentUser !== null){
// showNotification('saving config to db',1000);
accountIconLoading(true);
saveConfig({uid:firebase.auth().currentUser.uid,obj:config}).then(d => {
accountIconLoading(false);
if(d.data === 1){
// showNotification('config saved to db',1000);
}
})
}
}
function saveActiveTagsToCookie(){
@ -64,50 +81,62 @@ function saveActiveTagsToCookie(){
function loadConfigFromCookie() {
let newConfig = $.cookie('config');
if (newConfig && newConfig != null && newConfig != "null") {
if(newConfig !== undefined){
newConfig = JSON.parse(newConfig);
setTheme(newConfig.theme,true);
applyConfig(newConfig);
cookieConfig = newConfig;
saveConfigToCookie();
}
}
function applyConfig(configObj){
if (configObj && configObj != null && configObj != "null") {
setTheme(configObj.theme,true);
setCustomTheme(newConfig.customTheme,true);
setCustomThemeColors(newConfig.customThemeColors,true);
setQuickTabMode(newConfig.quickTab,true);
setPunctuation(newConfig.punctuation,true);
setKeyTips(newConfig.showKeyTips,true);
changeTimeConfig(newConfig.time,true);
changeWordCount(newConfig.words,true);
changeMode(newConfig.mode,true);
changeLanguage(newConfig.language,true);
changeLayout(newConfig.layout, true);
changeFontSize(newConfig.fontSize,true);
setFreedomMode(newConfig.freedomMode,true);
setCaretStyle(newConfig.caretStyle,true);
setDifficulty(newConfig.difficulty,true);
setBlindMode(newConfig.blindMode,true);
setQuickEnd(newConfig.quickEnd,true);
setFlipTestColors(newConfig.flipTestColors,true);
setDiscordDot(newConfig.hideDiscordDot,true);
setExtraTestColor(newConfig.extraTestColor,true);
setMaxConfidence(newConfig.maxConfidence,true);
setTimerStyle(newConfig.timerStyle,true);
if(newConfig.resultFilters == null || newConfig.resultFilters == undefined){
newConfig.resultFilters = ["all"];
setQuickTabMode(configObj.quickTab,true);
setPunctuation(configObj.punctuation,true);
setKeyTips(configObj.showKeyTips,true);
changeTimeConfig(configObj.time,true);
changeWordCount(configObj.words,true);
changeMode(configObj.mode,true);
changeLanguage(configObj.language,true);
changeLayout(configObj.layout, true);
changeFontSize(configObj.fontSize,true);
setFreedomMode(configObj.freedomMode,true);
setCaretStyle(configObj.caretStyle,true);
setDifficulty(configObj.difficulty,true);
setBlindMode(configObj.blindMode,true);
setQuickEnd(configObj.quickEnd,true);
setFlipTestColors(configObj.flipTestColors,true);
setDiscordDot(configObj.hideDiscordDot,true);
setColorfulMode(configObj.colorfulMode,true);
setMaxConfidence(configObj.maxConfidence,true);
setTimerStyle(configObj.timerStyle,true);
if(configObj.resultFilters == null || configObj.resultFilters == undefined){
configObj.resultFilters = ["all"];
}
config = newConfig;
config = configObj;
}
Object.keys(defaultConfig).forEach(configKey => {
if(config[configKey] == undefined){
config[configKey] = defaultConfig[configKey];
}
})
saveConfigToCookie();
}
function loadActiveTagsFromCookie(){
let newTags = $.cookie('activeTags');
newTags = JSON.parse(newTags);
newTags.forEach(ntag => {
toggleTag(ntag, true);
})
saveActiveTagsToCookie();
if(newTags !== undefined){
newTags = JSON.parse(newTags);
newTags.forEach(ntag => {
toggleTag(ntag, true);
})
saveActiveTagsToCookie();
}
}
function showTestConfig() {
@ -213,18 +242,18 @@ function toggleFlipTestColors(){
}
//extra color
function setExtraTestColor(extra,nosave){
function setColorfulMode(extra,nosave){
if(extra == undefined){
extra = false;
}
config.extraTestColor = extra;
applyExtraTestColor(extra);
config.colorfulMode = extra;
applyColorfulMode(extra);
if(!nosave) saveConfigToCookie();
}
function toggleExtraTestColor(){
config.extraTestColor = !config.extraTestColor;
applyExtraTestColor(config.extraTestColor);
function toggleColorfulMode(){
config.colorfulMode = !config.colorfulMode;
applyColorfulMode(config.colorfulMode);
saveConfigToCookie();
}
@ -378,6 +407,9 @@ function togglePunctuation() {
//freedom
function setFreedomMode(freedom, nosave) {
if(freedom === null){
freedom = false;
}
config.freedomMode = freedom;
if(config.freedomMode && config.maxConfidence){
config.maxConfidence = false;

File diff suppressed because one or more lines are too long

View file

@ -6,6 +6,6 @@
--text-color: #e9ecf0;
--error-color: #da3333;
--error-extra-color: #791717;
--extra-error-color: #c5da33;
--extra-error-extra-color: #849224;
--colorful-error-color: #c5da33;
--colorful-error-extra-color: #849224;
}

View file

@ -5,9 +5,9 @@
--sub-color: #99947f;
--text-color: #080909;
--error-color: #c87e74;
--extra-error-color: #a56961;
--extra-error-color: #c87e74;
--extra-error-extra-color: #a56961;
--colorful-error-color: #a56961;
--colorful-error-color: #c87e74;
--colorful-error-extra-color: #a56961;
}
.word letter.incorrect{
@ -15,7 +15,7 @@
}
.word letter.incorrect.extra{
color: var(--extra-error-color);
color: var(--colorful-error-color);
}
.word.error{

View file

@ -7,8 +7,8 @@
--text-color: #ebe6ea;
--error-color: #921341;
--error-extra-color: #640b2c;
--extra-error-color: #921341;
--extra-error-extra-color: #640b2c;
--colorful-error-color: #921341;
--colorful-error-extra-color: #640b2c;
}
/* .word.error{

View file

@ -6,6 +6,6 @@
--text-color: #fff;
--error-color: #bd4141;
--error-extra-color: #883434;
--extra-error-color: #bd4141;
--extra-error-extra-color: #883434;
--colorful-error-color: #bd4141;
--colorful-error-extra-color: #883434;
}

View file

@ -6,6 +6,6 @@
--text-color: #eaf1f3;
--error-color: #f6c9b4;
--error-extra-color: #f59a71;
--extra-error-color: #f6c9b4;
--extra-error-extra-color: #f59a71;
--colorful-error-color: #f6c9b4;
--colorful-error-extra-color: #f59a71;
}

View file

@ -6,6 +6,6 @@
--text-color: #f6f0e9;
--error-color: #ec4c56;
--error-extra-color: #9b333a;
--extra-error-color: #ecdc4c;
--extra-error-extra-color: #bdb03d;
--colorful-error-color: #ecdc4c;
--colorful-error-extra-color: #bdb03d;
}

View file

@ -6,8 +6,8 @@
--text-color: #3c403b;
--error-color: #ad4f4e;
--error-extra-color: #7e3a39;
--extra-error-color: #ad4f4e;
--extra-error-extra-color: #7e3a39;
--colorful-error-color: #ad4f4e;
--colorful-error-extra-color: #7e3a39;
}

View file

@ -5,7 +5,7 @@
--sub-color: #616161;
--text-color: #f5e6c8;
--error-color: #e72d2d;
--extra-error-color: #b62828;
--extra-error-color: #a5e72d;
--extra-error-extra-color: #74a120;
--colorful-error-color: #b62828;
--colorful-error-color: #a5e72d;
--colorful-error-extra-color: #74a120;
}

View file

@ -0,0 +1,11 @@
:root {
--bg-color: #181c18;
--main-color: #00ce7c;
--caret-color: #00ce7c;
--sub-color: #9578d3;
--text-color: #c2fbe1;
--error-color: #ff5f5f;
--error-extra-color: #d22a2a;
--colorful-error-color: #ff5f5f;
--colorful-error-extra-color: #d22a2a;
}

View file

@ -6,6 +6,6 @@
--text-color: #eee;
--error-color: #da3333;
--error-extra-color: #791717;
--extra-error-color: #da3333;
--extra-error-extra-color: #791717;
--colorful-error-color: #da3333;
--colorful-error-extra-color: #791717;
}

View file

@ -6,8 +6,8 @@
--text-color: #fff;
--error-color: #da3333;
--error-extra-color: #791717;
--extra-error-color: #da3333;
--extra-error-extra-color: #791717;
--colorful-error-color: #da3333;
--colorful-error-extra-color: #791717;
}
#menu{

View file

@ -6,8 +6,8 @@
--text-color: #f2f2f2;
--error-color: #f758a0;
--error-extra-color: #732e51;
--extra-error-color: #f758a0;
--extra-error-extra-color: #732e51;
--colorful-error-color: #f758a0;
--colorful-error-extra-color: #732e51;
}

View file

@ -6,6 +6,6 @@
--text-color: #ebdbb2;
--error-color: #fb4934;
--error-extra-color: #cc241d;
--extra-error-color: #fb4934;
--extra-error-extra-color: #cc241d;
--colorful-error-color: #fb4934;
--colorful-error-extra-color: #cc241d;
}

View file

@ -6,6 +6,6 @@
--text-color: #3c3836;
--error-color: #cc241d;
--error-extra-color: #9d0006;
--extra-error-color: #cc241d;
--extra-error-extra-color: #9d0006;
--colorful-error-color: #cc241d;
--colorful-error-extra-color: #9d0006;
}

11
public/themes/joker.css Normal file
View file

@ -0,0 +1,11 @@
:root {
--bg-color: #1a0e25;
--main-color: #99de1e;
--caret-color: #99de1e;
--sub-color: #7554a3;
--text-color: #e9e2f5;
--error-color: #e32b2b;
--error-extra-color: #A62626;
--colorful-error-color: #e32b2b;
--colorful-error-extra-color: #A62626;
}

View file

@ -6,6 +6,6 @@
--text-color: #dbe7e8;
--error-color: #a8d400;
--error-extra-color: #668000;
--extra-error-color: #a8d400;
--extra-error-extra-color: #668000;
--colorful-error-color: #a8d400;
--colorful-error-extra-color: #668000;
}

View file

@ -6,6 +6,6 @@
--text-color: #111;
--error-color: #da3333;
--error-extra-color: #791717;
--extra-error-color: #da3333;
--extra-error-extra-color: #791717;
--colorful-error-color: #da3333;
--colorful-error-extra-color: #791717;
}

View file

@ -51,7 +51,7 @@
},
{
"name": "rgb",
"bgColor": "linear-gradient(to left, indigo, blue, green, yellow, orange, red);",
"bgColor": "linear-gradient(to left, #0043ff, #1bdbdb, #27c214, #e0e019, #e01313)",
"textColor": "#fff"
},
{
@ -203,5 +203,26 @@
"name": "olive",
"bgColor": "#e9e5cc",
"textColor": "#92946f"
},
{
"name": "strawberry",
"bgColor": "#e53c58",
"textColor": "#fcfcf8"
},
{
"name": "night_runner",
"bgColor": "#5c4a9c",
"textColor": "#feff04"
},
{
"name": "cyberspace",
"bgColor": "#181c18",
"textColor": "#00ce7c"
},
{
"name": "joker",
"bgColor": "#1a0e25",
"textColor": "#99de1e"
}
]

View file

@ -6,8 +6,8 @@
--text-color: #adffa7;
--error-color: #da3333;
--error-extra-color: #791717;
--extra-error-color: #da3333;
--extra-error-extra-color: #791717;
--colorful-error-color: #da3333;
--colorful-error-extra-color: #791717;
}
#liveWpm, #timerNumber{

View file

@ -6,6 +6,6 @@
--text-color: #e8e8e8;
--error-color: #da3333;
--error-extra-color: #791717;
--extra-error-color: #d7da33;
--extra-error-extra-color: #737917;
--colorful-error-color: #d7da33;
--colorful-error-extra-color: #737917;
}

View file

@ -6,6 +6,6 @@
--sub-color: #94294c;
--error-color: #fff591;
--error-extra-color: #b9b269;
--extra-error-color: #fff591;
--extra-error-extra-color: #b9b269;
--colorful-error-color: #fff591;
--colorful-error-extra-color: #b9b269;
}

View file

@ -6,6 +6,6 @@
--text-color: #fff;
--error-color: #fff591;
--error-extra-color: #b6af68;
--extra-error-color: #fff591;
--extra-error-extra-color: #b6af68;
--colorful-error-color: #fff591;
--colorful-error-extra-color: #b6af68;
}

View file

@ -6,6 +6,6 @@
--text-color: #edf5e1;
--error-color: #f35588;
--error-extra-color: #a3385a;
--extra-error-color: #f35588;
--extra-error-extra-color: #a3385a;
--colorful-error-color: #f35588;
--colorful-error-extra-color: #a3385a;
}

View file

@ -6,6 +6,6 @@
--text-color: #1a2633;
--error-color: #bf616a;
--error-extra-color: #793e44;
--extra-error-color: #bf616a;
--extra-error-extra-color: #793e44;
--colorful-error-color: #bf616a;
--colorful-error-extra-color: #793e44;
}

View file

@ -6,6 +6,6 @@
--text-color: #e3e6eb;
--error-color: #d36a7b;
--error-extra-color: #994154;
--extra-error-color: #d36a7b;
--extra-error-extra-color: #994154;
--colorful-error-color: #d36a7b;
--colorful-error-extra-color: #994154;
}

View file

@ -6,6 +6,6 @@
--text-color: #E6DB74;
--error-color: #F92672;
--error-extra-color: #FD971F;
--extra-error-color: #F92672;
--extra-error-extra-color: #FD971F;
--colorful-error-color: #F92672;
--colorful-error-extra-color: #FD971F;
}

View file

@ -6,8 +6,8 @@
--text-color: #1d1d1d;
--error-color: #bf6464;
--error-extra-color: #793e44;
--extra-error-color: #8fadc9;
--extra-error-extra-color: #667c91;
--colorful-error-color: #8fadc9;
--colorful-error-extra-color: #667c91;
}
#top .logo .bottom{

View file

@ -6,6 +6,6 @@
--text-color: #1cbaac;
--error-color: #da3333;
--error-extra-color: #791717;
--extra-error-color: #da3333;
--extra-error-extra-color: #791717;
--colorful-error-color: #da3333;
--colorful-error-extra-color: #791717;
}

View file

@ -0,0 +1,11 @@
:root {
--bg-color: #212121;
--main-color: #feff04;
--caret-color: #feff04;
--sub-color: #5c4a9c;
--text-color: #e8e8e8;
--error-color: #da3333;
--error-extra-color: #791717;
--colorful-error-color: #da3333;
--colorful-error-extra-color: #791717;
}

View file

@ -6,6 +6,6 @@
--text-color: #d8dee9;
--error-color: #bf616a;
--error-extra-color: #793e44;
--extra-error-color: #bf616a;
--extra-error-extra-color: #793e44;
--colorful-error-color: #bf616a;
--colorful-error-extra-color: #793e44;
}

View file

@ -6,8 +6,8 @@
--text-color: #f7f5f1;
--error-color: #dd452e;
--error-extra-color: #9e3423;
--extra-error-color: #dd452e;
--extra-error-extra-color: #9e3423;
--colorful-error-color: #dd452e;
--colorful-error-extra-color: #9e3423;
}
#menu .button:nth-child(1){

View file

@ -6,6 +6,6 @@
--text-color: #373731;
--error-color: #cf2f2f;
--error-extra-color: #a22929;
--extra-error-color: #cf2f2f;
--extra-error-extra-color: #a22929;
--colorful-error-color: #cf2f2f;
--colorful-error-extra-color: #a22929;
}

View file

@ -6,6 +6,6 @@
--text-color:#f2efed;
--error-color: #bf616a;
--error-extra-color: #793e44;
--extra-error-color: #e03d4e;
--extra-error-extra-color: #aa2f3b;
--colorful-error-color: #e03d4e;
--colorful-error-extra-color: #aa2f3b;
}

View file

@ -6,6 +6,6 @@
--text-color: #e5f4f4;
--error-color: #da3333;
--error-extra-color: #791717;
--extra-error-color: #da3333;
--extra-error-extra-color: #791717;
--colorful-error-color: #da3333;
--colorful-error-extra-color: #791717;
}

View file

@ -6,6 +6,6 @@
--text-color: #e2dad0;
--error-color: #33bbda;
--error-extra-color: #176b79;
--extra-error-color: #33bbda;
--extra-error-extra-color: #176779;
--colorful-error-color: #33bbda;
--colorful-error-extra-color: #176779;
}

View file

@ -6,6 +6,6 @@
--text-color: #1d1b17;
--error-color: #bf616a;
--error-extra-color: #793e44;
--extra-error-color: #bf616a;
--extra-error-extra-color: #793e44;
--colorful-error-color: #bf616a;
--colorful-error-extra-color: #793e44;
}

View file

@ -6,8 +6,8 @@
--text-color: #eee;
--error-color: #eee;
--error-extra-color: #b3b3b3;
--extra-error-color: #eee;
--extra-error-extra-color: #b3b3b3;
--colorful-error-color: #eee;
--colorful-error-extra-color: #b3b3b3;
}
@keyframes rgb{

View file

@ -6,6 +6,6 @@
--text-color:#323437;
--error-color: #da3333;
--error-extra-color: #791717;
--extra-error-color: #da3333;
--extra-error-extra-color: #791717;
--colorful-error-color: #da3333;
--colorful-error-extra-color: #791717;
}

View file

@ -6,6 +6,6 @@
--text-color: #d1d0c5;
--error-color: #ca4754;
--error-extra-color: #7e2a33;
--extra-error-color: #ca4754;
--extra-error-extra-color: #7e2a33;
--colorful-error-color: #ca4754;
--colorful-error-extra-color: #7e2a33;
}

View file

@ -6,8 +6,8 @@
--text-color: #eee;
--error-color: #fff;
--error-extra-color: #d8d8d8;
--extra-error-color: #fff;
--extra-error-extra-color: #d8d8d8;
--colorful-error-color: #fff;
--colorful-error-extra-color: #d8d8d8;
}
@keyframes shadow {

View file

@ -0,0 +1,11 @@
:root {
--bg-color: #f37f83;
--main-color: #fcfcf8;
--caret-color: #fcfcf8;
--sub-color: #e53c58;
--text-color: #fcfcf8;
--error-color: #fcd23f;
--error-extra-color: #d7ae1e;
--colorful-error-color: #fcd23f;
--colorful-error-extra-color: #d7ae1e;
}

View file

@ -6,6 +6,6 @@
--text-color: #d6dbd9;
--error-color: #fb4934;
--error-extra-color: #cc241d;
--extra-error-color: #fb4934;
--extra-error-extra-color: #cc241d;
--colorful-error-color: #fb4934;
--colorful-error-extra-color: #cc241d;
}

View file

@ -7,8 +7,8 @@
--text-color: #130f1a;
--error-color: #ffe23e;
--error-extra-color: #fff1c3;
--extra-error-color: #ffe23e;
--extra-error-extra-color: #fff1c3;
--colorful-error-color: #ffe23e;
--colorful-error-extra-color: #fff1c3;
}
.word.error{

View file

@ -6,6 +6,6 @@
--text-color: #e7eae0;
--error-color: #a61717;
--error-extra-color: #731010;
--extra-error-color: #a61717;
--extra-error-extra-color: #731010;
--colorful-error-color: #a61717;
--colorful-error-extra-color: #731010;
}

View file

@ -6,6 +6,6 @@
--text-color: #f1ebf1;
--error-color: #573ca9;
--error-extra-color: #3d2b77;
--extra-error-color: #28cafe;
--extra-error-extra-color: #25a9ce;
--colorful-error-color: #28cafe;
--colorful-error-extra-color: #25a9ce;
}

View file

@ -6,6 +6,6 @@
--text-color: #eeeae4;
--error-color: #af3735;
--error-extra-color: #7e2a29;
--extra-error-color: #af3735;
--extra-error-extra-color: #7e2a29;
--colorful-error-color: #af3735;
--colorful-error-extra-color: #7e2a29;
}