This commit is contained in:
monkeytypegeorge 2021-02-06 06:14:35 +00:00
commit 8c6f50fa1a
21 changed files with 188 additions and 59 deletions

View file

@ -409,6 +409,9 @@ exports.checkNameAvailability = functions.https.onRequest(
function checkIfPB(uid, obj, userdata) {
let pbs = null;
if (obj.mode == "quote") {
return false;
}
if (obj.funbox !== "none") {
return false;
}
@ -543,6 +546,9 @@ async function checkIfTagPB(uid, obj, userdata) {
if (obj.tags.length === 0) {
return [];
}
if (obj.mode == "quote") {
return [];
}
let dbtags = [];
let restags = obj.tags;
try {

View file

@ -696,7 +696,7 @@ let commands = {
display: "Toggle Monkey",
visible: false,
exec: () => {
$("#monkey").toggleClass("hidden");
toggleMonkey();
},
},
],

View file

@ -263,6 +263,7 @@ export async function db_saveLocalPB(
raw,
consistency
) {
if(mode == "quote") return;
function cont() {
try {
let found = false;
@ -367,6 +368,7 @@ export async function db_saveLocalTagPB(
raw,
consistency
) {
if(mode == "quote") return;
function cont() {
let filteredtag = dbSnapshot.tags.filter((t) => t.id === tagId)[0];
try {

View file

@ -575,3 +575,22 @@ export function isUsernameValid(name) {
if (/^\..*/.test(name.toLowerCase())) return false;
return /^[0-9a-zA-Z_.-]+$/.test(name);
}
export function mapRange(x, in_min, in_max, out_min, out_max) {
let num = ((x - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min;
if (out_min > out_max) {
if (num > out_min) {
num = out_min;
} else if (num < out_max) {
num = out_max;
}
} else {
if (num < out_min) {
num = out_min;
} else if (num > out_max) {
num = out_max;
}
}
return num;
}

View file

@ -1,3 +1,5 @@
import { mapRange } from "./misc";
let left = false;
let right = false;
let elements = {
@ -6,6 +8,12 @@ let elements = {
"01": document.querySelector("#monkey .right"),
11: document.querySelector("#monkey .both"),
};
let elementsFast = {
"00": document.querySelector("#monkey .fast .up"),
10: document.querySelector("#monkey .fast .left"),
"01": document.querySelector("#monkey .fast .right"),
11: document.querySelector("#monkey .fast .both"),
};
let last = "right";
// 0 up
// 1 down
@ -15,14 +23,26 @@ function update() {
Object.keys(elements).forEach((key) => {
elements[key].classList.add("hidden");
});
Object.keys(elementsFast).forEach((key) => {
elementsFast[key].classList.add("hidden");
});
let id = left ? "1" : "0";
id += right ? "1" : "0";
elements[id].classList.remove("hidden");
elementsFast[id].classList.remove("hidden");
}
}
export function updateFastOpacity(num) {
let opacity = mapRange(num, 100, 200, 0, 1);
$("#monkey .fast").animate({ opacity: opacity }, 1000);
let animDuration = mapRange(num, 100, 200, 0.5, 0.01);
if (animDuration == 0.5) animDuration = 0;
$("#monkey").css({ animationDuration: animDuration + "s" });
}
export function type() {
if (!left && last == "right") {
left = true;
@ -42,4 +62,3 @@ export function stop() {
}
update();
}

View file

@ -2225,6 +2225,7 @@ function showResult(difficultyFailed = false) {
if (lpb < stats.wpm && stats.wpm < highestwpm) {
dontShowCrown = true;
}
if (config.mode == "quote") dontShowCrown = true;
if (lpb < stats.wpm) {
//new pb based on local
pbDiff = Math.abs(stats.wpm - lpb);
@ -2295,56 +2296,58 @@ function showResult(difficultyFailed = false) {
$("#result .stats .tags .bottom").append(`
<div tagid="${tag.id}" aria-label="PB: ${tpb}" data-balloon-pos="up">${tag.name}<i class="fas fa-crown hidden"></i></div>
`);
if (tpb < stats.wpm) {
//new pb for that tag
db_saveLocalTagPB(
tag.id,
config.mode,
mode2,
config.punctuation,
config.language,
config.difficulty,
stats.wpm,
stats.acc,
stats.wpmRaw,
consistency
);
$(
`#result .stats .tags .bottom div[tagid="${tag.id}"] .fas`
).removeClass("hidden");
$(`#result .stats .tags .bottom div[tagid="${tag.id}"]`).attr(
"aria-label",
"+" + Misc.roundTo2(stats.wpm - tpb)
);
console.log("new pb for tag " + tag.name);
} else {
wpmOverTimeChart.options.annotation.annotations.push({
enabled: false,
type: "line",
mode: "horizontal",
scaleID: "wpm",
value: tpb,
borderColor: themeColors.sub,
borderWidth: 1,
borderDash: [2, 2],
label: {
backgroundColor: themeColors.sub,
fontFamily: "Roboto Mono",
fontSize: 11,
fontStyle: "normal",
fontColor: themeColors.bg,
xPadding: 6,
yPadding: 6,
cornerRadius: 3,
position: annotationSide,
enabled: true,
content: `${tag.name} PB: ${tpb}`,
},
});
if (annotationSide === "left") {
annotationSide = "right";
if (config.mode != "quote"){
if (tpb < stats.wpm) {
//new pb for that tag
db_saveLocalTagPB(
tag.id,
config.mode,
mode2,
config.punctuation,
config.language,
config.difficulty,
stats.wpm,
stats.acc,
stats.wpmRaw,
consistency
);
$(
`#result .stats .tags .bottom div[tagid="${tag.id}"] .fas`
).removeClass("hidden");
$(`#result .stats .tags .bottom div[tagid="${tag.id}"]`).attr(
"aria-label",
"+" + Misc.roundTo2(stats.wpm - tpb)
);
// console.log("new pb for tag " + tag.name);
} else {
annotationSide = "left";
wpmOverTimeChart.options.annotation.annotations.push({
enabled: false,
type: "line",
mode: "horizontal",
scaleID: "wpm",
value: tpb,
borderColor: themeColors.sub,
borderWidth: 1,
borderDash: [2, 2],
label: {
backgroundColor: themeColors.sub,
fontFamily: "Roboto Mono",
fontSize: 11,
fontStyle: "normal",
fontColor: themeColors.bg,
xPadding: 6,
yPadding: 6,
cornerRadius: 3,
position: annotationSide,
enabled: true,
content: `${tag.name} PB: ${tpb}`,
},
});
if (annotationSide === "left") {
annotationSide = "right";
} else {
annotationSide = "left";
}
}
}
});
@ -2828,6 +2831,7 @@ function startTest() {
updateLiveWpm(wpmAndRaw.wpm, wpmAndRaw.raw);
wpmHistory.push(wpmAndRaw.wpm);
rawHistory.push(wpmAndRaw.raw);
Monkey.updateFastOpacity(wpmAndRaw.wpm);
let acc = Misc.roundTo2(
(accuracyStats.correct /
@ -3024,6 +3028,8 @@ function restartTest(withSameWordset = false, nosave = false) {
},
125,
async () => {
$("#monkey .fast").stop(true, true).css("opacity", 0);
$("#monkey").stop(true, true).css({ animationDuration: "0s" });
$("#typingTest").css("opacity", 0).removeClass("hidden");
if (!withSameWordset) {
sameWordset = false;

View file

@ -74,6 +74,7 @@ let defaultConfig = {
minAcc: "off",
minAccCustom: 90,
showLiveAcc: false,
monkey: false,
};
let cookieConfig = null;
@ -1272,6 +1273,29 @@ function setLanguage(language, nosave) {
if (!nosave) saveConfigToCookie();
}
function toggleMonkey(nosave) {
config.monkey = !config.monkey;
if (config.monkey) {
$("#monkey").removeClass("hidden");
} else {
$("#monkey").addClass("hidden");
}
if (!nosave) saveConfigToCookie();
}
function setMonkey(monkey, nosave) {
if (monkey === null || monkey === undefined) {
monkey = false;
}
config.monkey = monkey;
if (config.monkey) {
$("#monkey").removeClass("hidden");
} else {
$("#monkey").addClass("hidden");
}
if (!nosave) saveConfigToCookie();
}
function setCapsLockBackspace(capsLockBackspace, nosave) {
if (capsLockBackspace === null || capsLockBackspace === undefined) {
capsLockBackspace = false;
@ -1479,7 +1503,7 @@ function setFontSize(fontSize, nosave) {
function applyConfig(configObj) {
if (configObj == null || configObj == undefined) {
Notifications.add("Could not apply config", -1);
Notifications.add("Could not apply config", -1, 3);
return;
}
Object.keys(defaultConfig).forEach((configKey) => {
@ -1550,6 +1574,7 @@ function applyConfig(configObj) {
setStartGraphsAtZero(configObj.startGraphsAtZero, true);
setStrictSpace(configObj.strictSpace, true);
setMode(configObj.mode, true);
setMonkey(configObj.monkey, true);
try {
setEnableAds(configObj.enableAds, true);

View file

@ -3386,6 +3386,9 @@ key {
width: 308px;
height: 0;
margin: 0 auto;
animation: shake;
animation-duration: 0s;
animation-iteration-count: infinite;
div {
height: 200px;
width: 308px;
@ -3403,6 +3406,32 @@ key {
.both {
background-image: url("../m4.png");
}
.fast {
.up {
background-image: url("../m3_fast.png");
}
.left {
background-image: url("../m1_fast.png");
}
.right {
background-image: url("../m2_fast.png");
}
.both {
background-image: url("../m4_fast.png");
}
}
}
@keyframes shake {
0% {
transform: translate(4px, 0) rotate(0deg);
}
50% {
transform: translate(-4px, 0) rotate(0deg);
}
100% {
transform: translate(4px, 0) rotate(0deg);
}
}
.keymap {

View file

@ -1229,6 +1229,12 @@
<div class="left hidden"></div>
<div class="right hidden"></div>
<div class="both hidden"></div>
<div class="fast">
<div class="up"></div>
<div class="left hidden"></div>
<div class="right hidden"></div>
<div class="both hidden"></div>
</div>
</div>
<div id="premidTestMode" class="hidden"></div>
<div id="premidSecondsLeft" class="hidden"></div>
@ -1554,6 +1560,7 @@
<div>squarepy</div>
<div>AnalystBot</div>
<div>ze_or</div>
<div>Richard Blythin</div>
<div>Jiangtian Li</div>
<div>Dessle</div>
<div>Craig</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

BIN
static/m1_fast.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

BIN
static/m2_fast.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
static/m3_fast.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

BIN
static/m4_fast.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View file

@ -490,18 +490,23 @@
"textColor": "#f6f5f5"
},
{
"name": "rosé_pine",
"name": "rose_pine",
"bgColor": "#1f1d27",
"textColor": "#e0def4"
},
{
"name": "rosé_pine_moon",
"name": "rose_pine_moon",
"bgColor": "#2a273f",
"textColor": "#e0def4"
},
{
"name": "rosé_pine_dawn",
"name": "rose_pine_dawn",
"bgColor": "#fffaf3",
"textColor": "#575279"
}
},
{
"name": "copper",
"bgColor": "#442f29",
"textColor": "#e7e0de"
}
]

11
static/themes/copper.css Normal file
View file

@ -0,0 +1,11 @@
:root {
--bg-color: #442f29;
--main-color: #b46a55;
--caret-color: #c25c42;
--sub-color: #7ebab5;
--text-color: #e7e0de;
--error-color: #a32424;
--error-extra-color: #ec0909;
--colorful-error-color: #a32424;
--colorful-error-extra-color: #ec0909;
}

View file

@ -3,7 +3,7 @@
--main-color: #9ccfd8; /*Color after typing, monkeytype logo, WPM Number acc number etc*/
--caret-color: #f6c177; /*Cursor Color*/
--sub-color: #c4a7e7; /*WPM text color of scrollbar and general color, before typed color*/
--text-color: #e0def4 ; /*Color of text after hovering over it*/
--text-color: #e0def4; /*Color of text after hovering over it*/
--error-color: #eb6f92;
--error-extra-color: #ebbcba;
--colorful-error-color: #eb6f92;

View file

@ -3,7 +3,7 @@
--main-color: #56949f; /*Color after typing, monkeytype logo, WPM Number acc number etc*/
--caret-color: #ea9d34; /*Cursor Color*/
--sub-color: #c4a7e7; /*WPM text color of scrollbar and general color, before typed color*/
--text-color: #286983 ; /*Color of text after hovering over it*/
--text-color: #286983; /*Color of text after hovering over it*/
--error-color: #b4637a;
--error-extra-color: #d7827e;
--colorful-error-color: #b4637a;

View file

@ -3,7 +3,7 @@
--main-color: #9ccfd8; /*Color after typing, monkeytype logo, WPM Number acc number etc*/
--caret-color: #f6c177; /*Cursor Color*/
--sub-color: #c4a7e7; /*WPM text color of scrollbar and general color, before typed color*/
--text-color: #e0def4 ; /*Color of text after hovering over it*/
--text-color: #e0def4; /*Color of text after hovering over it*/
--error-color: #eb6f92;
--error-extra-color: #ebbcba;
--colorful-error-color: #eb6f92;