aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--frontend/src/styles/test.scss7
-rw-r--r--frontend/src/ts/pages/settings.ts3
-rw-r--r--frontend/src/ts/test/funbox/funbox-functions.ts8
-rw-r--r--frontend/src/ts/test/words-generator.ts10
-rw-r--r--packages/funbox/src/list.ts8
-rw-r--r--packages/funbox/src/types.ts1
6 files changed, 33 insertions, 4 deletions
diff --git a/frontend/src/styles/test.scss b/frontend/src/styles/test.scss
index 8a437be05..2d06e5bb2 100644
--- a/frontend/src/styles/test.scss
+++ b/frontend/src/styles/test.scss
@@ -1338,6 +1338,13 @@ body.fb-nospace {
}
}
+/* funbox underscore_spaces */
+body.fb-underscore-spaces {
+ #words .word {
+ margin: 0.5em 0;
+ }
+}
+
/* funbox arrows */
body.fb-arrows {
#words .word {
diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts
index 5b7e507d6..2f1cf76b0 100644
--- a/frontend/src/ts/pages/settings.ts
+++ b/frontend/src/ts/pages/settings.ts
@@ -612,6 +612,9 @@ async function fillSettingsPage(): Promise<void> {
/_/g,
" "
)}</div>`;
+ } else if (funbox.name === "underscore_spaces") {
+ // Display as "underscore_spaces". Does not replace underscores with spaces.
+ funboxElHTML += `<div class="funbox button" data-config-value='${funbox.name}' aria-label="${funbox.description}" data-balloon-pos="up" data-balloon-length="fit">${funbox.name}</div>`;
} else {
funboxElHTML += `<div class="funbox button" data-config-value='${
funbox.name
diff --git a/frontend/src/ts/test/funbox/funbox-functions.ts b/frontend/src/ts/test/funbox/funbox-functions.ts
index a0fe543d7..2cb71b303 100644
--- a/frontend/src/ts/test/funbox/funbox-functions.ts
+++ b/frontend/src/ts/test/funbox/funbox-functions.ts
@@ -26,7 +26,7 @@ export type FunboxFunctions = {
getWord?: (wordset?: Wordset, wordIndex?: number) => string;
punctuateWord?: (word: string) => string;
withWords?: (words?: string[]) => Promise<Wordset>;
- alterText?: (word: string) => string;
+ alterText?: (word: string, wordIndex: number, wordsBound: number) => string;
applyConfig?: () => void;
applyGlobalCSS?: () => void;
clearGlobal?: () => void;
@@ -584,6 +584,12 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
return GetText.getMorse(word);
},
},
+ underscore_spaces: {
+ alterText(word: string, wordIndex: number, limit: number): string {
+ if (wordIndex === limit - 1) return word; // don't add underscore to the last word
+ return word + "_";
+ },
+ },
crt: {
applyGlobalCSS(): void {
const isSafari = /^((?!chrome|android).)*safari/i.test(
diff --git a/frontend/src/ts/test/words-generator.ts b/frontend/src/ts/test/words-generator.ts
index 7dabe7ef3..d2461d9ac 100644
--- a/frontend/src/ts/test/words-generator.ts
+++ b/frontend/src/ts/test/words-generator.ts
@@ -346,10 +346,14 @@ function getFunboxWord(
return word;
}
-function applyFunboxesToWord(word: string): string {
+function applyFunboxesToWord(
+ word: string,
+ wordIndex: number,
+ wordsBound: number
+): string {
for (const fb of getActiveFunboxes()) {
if (fb.functions?.alterText) {
- word = fb.functions.alterText(word);
+ word = fb.functions.alterText(word, wordIndex, wordsBound);
}
}
return word;
@@ -911,7 +915,7 @@ export async function getNextWord(
}
}
- randomWord = applyFunboxesToWord(randomWord);
+ randomWord = applyFunboxesToWord(randomWord, wordIndex, wordsBound);
console.debug("Word:", randomWord);
diff --git a/packages/funbox/src/list.ts b/packages/funbox/src/list.ts
index b1be30981..9038e3867 100644
--- a/packages/funbox/src/list.ts
+++ b/packages/funbox/src/list.ts
@@ -406,6 +406,14 @@ const list: Record<FunboxName, FunboxMetadata> = {
frontendFunctions: ["alterText"],
name: "instant_messaging",
},
+ underscore_spaces: {
+ description: "Underscores_are_better.",
+ canGetPb: false,
+ difficultyLevel: 0,
+ properties: ["ignoresLanguage", "ignoresLayout", "nospace"],
+ frontendFunctions: ["alterText"],
+ name: "underscore_spaces",
+ },
ALL_CAPS: {
description: "WHY ARE WE SHOUTING?",
canGetPb: false,
diff --git a/packages/funbox/src/types.ts b/packages/funbox/src/types.ts
index c410a911f..cd9e0c481 100644
--- a/packages/funbox/src/types.ts
+++ b/packages/funbox/src/types.ts
@@ -39,6 +39,7 @@ export type FunboxName =
| "backwards"
| "ddoouubblleedd"
| "instant_messaging"
+ | "underscore_spaces"
| "ALL_CAPS";
export type FunboxForcedConfig = Record<string, string[] | boolean[]>;