diff --git a/functions/index.js b/functions/index.js index a05be6a60..8b1ab4b69 100644 --- a/functions/index.js +++ b/functions/index.js @@ -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 { diff --git a/src/js/commandline.js b/src/js/commandline.js index c460784be..cff7c05ca 100644 --- a/src/js/commandline.js +++ b/src/js/commandline.js @@ -696,7 +696,7 @@ let commands = { display: "Toggle Monkey", visible: false, exec: () => { - $("#monkey").toggleClass("hidden"); + toggleMonkey(); }, }, ], diff --git a/src/js/db.js b/src/js/db.js index bf723fb07..2fece1743 100644 --- a/src/js/db.js +++ b/src/js/db.js @@ -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 { diff --git a/src/js/misc.js b/src/js/misc.js index ba9ecce52..b3250d430 100644 --- a/src/js/misc.js +++ b/src/js/misc.js @@ -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; +} diff --git a/src/js/monkey.js b/src/js/monkey.js index a49182dd7..e151bf2ba 100644 --- a/src/js/monkey.js +++ b/src/js/monkey.js @@ -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(); } - diff --git a/src/js/script.js b/src/js/script.js index 691b6c3f4..7edfd07de 100644 --- a/src/js/script.js +++ b/src/js/script.js @@ -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(`
${tag.name}
`); - 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; diff --git a/src/js/userconfig.js b/src/js/userconfig.js index b7e10eaa3..72c2a75fe 100644 --- a/src/js/userconfig.js +++ b/src/js/userconfig.js @@ -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); diff --git a/src/sass/style.scss b/src/sass/style.scss index 5745dd5ef..23fcd33e7 100644 --- a/src/sass/style.scss +++ b/src/sass/style.scss @@ -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 { diff --git a/static/index.html b/static/index.html index 91e7a4973..bccb47e6a 100644 --- a/static/index.html +++ b/static/index.html @@ -1229,6 +1229,12 @@ +
+
+ + + +
@@ -1554,6 +1560,7 @@
squarepy
AnalystBot
ze_or
+
Richard Blythin
Jiangtian Li
Dessle
Craig
diff --git a/static/m1.png b/static/m1.png index be9199b5d..0541332bb 100644 Binary files a/static/m1.png and b/static/m1.png differ diff --git a/static/m1_fast.png b/static/m1_fast.png new file mode 100644 index 000000000..5bd7d6d81 Binary files /dev/null and b/static/m1_fast.png differ diff --git a/static/m2.png b/static/m2.png index 6dbfbde12..df9cefa65 100644 Binary files a/static/m2.png and b/static/m2.png differ diff --git a/static/m2_fast.png b/static/m2_fast.png new file mode 100644 index 000000000..35f87eae4 Binary files /dev/null and b/static/m2_fast.png differ diff --git a/static/m3_fast.png b/static/m3_fast.png new file mode 100644 index 000000000..5f877caf6 Binary files /dev/null and b/static/m3_fast.png differ diff --git a/static/m4.png b/static/m4.png index 269b5b73e..e0b942974 100644 Binary files a/static/m4.png and b/static/m4.png differ diff --git a/static/m4_fast.png b/static/m4_fast.png new file mode 100644 index 000000000..66c7c927a Binary files /dev/null and b/static/m4_fast.png differ diff --git a/static/themes/_list.json b/static/themes/_list.json index b8d7261db..888583c77 100644 --- a/static/themes/_list.json +++ b/static/themes/_list.json @@ -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" +} ] diff --git a/static/themes/copper.css b/static/themes/copper.css new file mode 100644 index 000000000..ff42da09b --- /dev/null +++ b/static/themes/copper.css @@ -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; +} diff --git a/static/themes/rosé_pine.css b/static/themes/rose_pine.css similarity index 85% rename from static/themes/rosé_pine.css rename to static/themes/rose_pine.css index b3d50743c..293598ed9 100644 --- a/static/themes/rosé_pine.css +++ b/static/themes/rose_pine.css @@ -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; diff --git a/static/themes/rosé_pine_dawn.css b/static/themes/rose_pine_dawn.css similarity index 85% rename from static/themes/rosé_pine_dawn.css rename to static/themes/rose_pine_dawn.css index 0d673ed09..849209c86 100644 --- a/static/themes/rosé_pine_dawn.css +++ b/static/themes/rose_pine_dawn.css @@ -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; diff --git a/static/themes/rosé_pine_moon.css b/static/themes/rose_pine_moon.css similarity index 85% rename from static/themes/rosé_pine_moon.css rename to static/themes/rose_pine_moon.css index c1d934033..0ed3bf97d 100644 --- a/static/themes/rosé_pine_moon.css +++ b/static/themes/rose_pine_moon.css @@ -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;