Merge branch 'master' into newads

This commit is contained in:
Miodec 2023-02-23 14:20:19 +01:00
commit c5b4fc6be9
12 changed files with 50 additions and 0 deletions

View file

@ -17,8 +17,39 @@ import format from "date-fns/format";
import { Auth } from "../firebase";
import { skipXpBreakdown } from "../elements/account-button";
import * as FunboxList from "./funbox/funbox-list";
import { debounce } from "throttle-debounce";
const debouncedZipfCheck = debounce(250, () => {
Misc.checkIfLanguageSupportsZipf(Config.language).then((supports) => {
if (supports === "no") {
Notifications.add(
`${Misc.capitalizeFirstLetter(
Config.language.replace(/_/g, " ")
)} does not support Zipf funbox, because the list is not ordered by frequency. Please try another word list.`,
0,
7
);
}
if (supports === "unknown") {
Notifications.add(
`${Misc.capitalizeFirstLetter(
Config.language.replace(/_/g, " ")
)} may not support Zipf funbox, because we don't know if it's ordered by frequency or not. If you would like to add this label, please contact us.`,
0,
7
);
}
});
});
ConfigEvent.subscribe((eventKey, eventValue) => {
if (
(eventKey === "language" || eventKey === "funbox") &&
(eventValue as string).split("#").includes("zipf")
) {
debouncedZipfCheck();
}
if (eventValue === undefined || typeof eventValue !== "boolean") return;
if (eventKey === "flipTestColors") flipColors(eventValue);
if (eventKey === "colorfulMode") colorful(eventValue);

View file

@ -23,6 +23,7 @@ declare namespace MonkeyTypes {
leftToRight: boolean;
noLazyMode?: boolean;
ligatures?: boolean;
orderedByFrequency?: boolean;
words: string[];
accents: Accents;
bcp47?: string;

View file

@ -1402,3 +1402,12 @@ export function dreymarIndex(arrayLength: number): number {
const W = Math.ceil(h);
return W - 1;
}
export async function checkIfLanguageSupportsZipf(
language: string
): Promise<"yes" | "no" | "unknown"> {
const lang = await getLanguage(language);
if (lang.orderedByFrequency === true) return "yes";
if (lang.orderedByFrequency === false) return "no";
return "unknown";
}

View file

@ -2,6 +2,7 @@
"name": "english",
"leftToRight": true,
"noLazyMode": true,
"orderedByFrequency": true,
"words": [
"the",
"be",

View file

@ -2,6 +2,7 @@
"name": "english_10k",
"leftToRight": true,
"noLazyMode": true,
"orderedByFrequency": true,
"words": [
"the",
"of",

View file

@ -2,6 +2,7 @@
"name": "english_1k",
"leftToRight": true,
"noLazyMode": true,
"orderedByFrequency": true,
"words": [
"the",
"of",

View file

@ -2,6 +2,7 @@
"name": "english_25k",
"leftToRight": true,
"noLazyMode": true,
"orderedByFrequency": false,
"words": [
"plug",
"rounders",

View file

@ -2,6 +2,7 @@
"name": "english_450k",
"leftToRight": true,
"noLazyMode": true,
"orderedByFrequency": false,
"words": [
"a",
"AA",

View file

@ -2,6 +2,7 @@
"name": "english_5k",
"leftToRight": true,
"noLazyMode": true,
"orderedByFrequency": false,
"words": [
"a",
"abandon",

View file

@ -3,6 +3,7 @@
"leftToRight": true,
"_comment": "Sourced from: https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings",
"noLazyMode": true,
"orderedByFrequency": false,
"words": [
"caused",
"ultimately",

View file

@ -3,6 +3,7 @@
"leftToRight": true,
"_comment": "Sourced from: https://en.wikipedia.org/wiki/Wikipedia:List_of_English_contractions",
"noLazyMode": true,
"orderedByFrequency": false,
"words": [
"a'ight",
"ain't",

View file

@ -4,6 +4,7 @@
"_comment": "Sourced from https://www.panopy.com/iphone/secret-ada/double-letter-words.html and https://grammar.yourdictionary.com/word-lists/words-with-double-letters.html",
"ligatures": false,
"noLazyMode": true,
"orderedByFrequency": false,
"bcp47": "en-US",
"words": [
"been",