mirror of
				https://github.com/monkeytypegame/monkeytype.git
				synced 2025-10-31 19:26:22 +08:00 
			
		
		
		
	
							parent
							
								
									65857ee857
								
							
						
					
					
						commit
						24ff1becd1
					
				
					 6 changed files with 29 additions and 31 deletions
				
			
		|  | @ -1582,4 +1582,21 @@ export let loadPromise = new Promise((v) => { | |||
|   loadDone = v; | ||||
| }); | ||||
| 
 | ||||
| export function getMode2(mode) { | ||||
|   if (!mode) mode = config.mode; | ||||
|   let mode2 = ""; | ||||
|   if (mode === "time") { | ||||
|     mode2 = config.time; | ||||
|   } else if (mode === "words") { | ||||
|     mode2 = config.words; | ||||
|   } else if (mode === "custom") { | ||||
|     mode2 = "custom"; | ||||
|   } else if (mode === "zen") { | ||||
|     mode2 = "zen"; | ||||
|   } else if (mode === "quote") { | ||||
|     mode2 = TestLogic.randomQuote.id; | ||||
|   } | ||||
|   return mode2; | ||||
| } | ||||
| 
 | ||||
| export default config; | ||||
|  |  | |||
|  | @ -1,6 +1,4 @@ | |||
| import * as Loader from "./elements/loader"; | ||||
| import Config from "./config"; | ||||
| import * as TestLogic from "./test/test-logic"; | ||||
| 
 | ||||
| export function getuid() { | ||||
|   console.error("Only share this uid with Miodec and nobody else!"); | ||||
|  | @ -317,8 +315,8 @@ export async function getLanguage(lang) { | |||
|   } | ||||
| } | ||||
| 
 | ||||
| export async function getCurrentLanguage() { | ||||
|   return await getLanguage(Config.language); | ||||
| export async function getCurrentLanguage(languageName) { | ||||
|   return await getLanguage(languageName); | ||||
| } | ||||
| 
 | ||||
| export function migrateFromCookies() { | ||||
|  | @ -812,23 +810,6 @@ String.prototype.lastIndexOfRegex = function (regex) { | |||
| 
 | ||||
| export const trailingComposeChars = /[\u02B0-\u02FF`´^¨~]+$|⎄.*$/; | ||||
| 
 | ||||
| export function getMode2(mode) { | ||||
|   if (!mode) mode = Config.mode; | ||||
|   let mode2 = ""; | ||||
|   if (mode === "time") { | ||||
|     mode2 = Config.time; | ||||
|   } else if (mode === "words") { | ||||
|     mode2 = Config.words; | ||||
|   } else if (mode === "custom") { | ||||
|     mode2 = "custom"; | ||||
|   } else if (mode === "zen") { | ||||
|     mode2 = "zen"; | ||||
|   } else if (mode === "quote") { | ||||
|     mode2 = TestLogic.randomQuote.id; | ||||
|   } | ||||
|   return mode2; | ||||
| } | ||||
| 
 | ||||
| //https://stackoverflow.com/questions/36532307/rem-px-in-javascript
 | ||||
| export function convertRemToPixels(rem) { | ||||
|   return rem * parseFloat(getComputedStyle(document.documentElement).fontSize); | ||||
|  |  | |||
|  | @ -62,7 +62,7 @@ export async function updatePosition() { | |||
|   } | ||||
| 
 | ||||
|   if (Config.mode != "zen" && $(currentLetter).length == 0) return; | ||||
|   const currentLanguage = await Misc.getCurrentLanguage(); | ||||
|   const currentLanguage = await Misc.getCurrentLanguage(Config.language); | ||||
|   const isLanguageLeftToRight = currentLanguage.leftToRight; | ||||
|   let currentLetterPosLeft = isLanguageLeftToRight | ||||
|     ? currentLetter.offsetLeft | ||||
|  |  | |||
|  | @ -103,7 +103,7 @@ export async function activate(funbox) { | |||
|   $("#funBoxTheme").attr("href", ``); | ||||
|   $("#words").removeClass("nospace"); | ||||
|   $("#words").removeClass("arrows"); | ||||
|   if (await Misc.getCurrentLanguage().ligatures) { | ||||
|   if (await Misc.getCurrentLanguage(Config.language).ligatures) { | ||||
|     if (funbox == "choo_choo" || funbox == "earthquake") { | ||||
|       Notifications.add( | ||||
|         "Current language does not support this funbox mode", | ||||
|  |  | |||
|  | @ -1,9 +1,8 @@ | |||
| import * as TestLogic from "./test-logic"; | ||||
| import * as TestUI from "./test-ui"; | ||||
| import Config from "../config"; | ||||
| import Config, * as UpdateConfig from "../config"; | ||||
| import * as DB from "../db"; | ||||
| import * as TestTimer from "./test-timer"; | ||||
| import * as Misc from "../misc"; | ||||
| 
 | ||||
| export let settings = null; | ||||
| 
 | ||||
|  | @ -33,7 +32,7 @@ function resetCaretPosition() { | |||
| 
 | ||||
| export async function init() { | ||||
|   $("#paceCaret").addClass("hidden"); | ||||
|   let mode2 = Misc.getMode2(); | ||||
|   let mode2 = UpdateConfig.getMode2(); | ||||
|   let wpm; | ||||
|   if (Config.paceCaret === "pb") { | ||||
|     wpm = await DB.getLocalPB( | ||||
|  | @ -46,7 +45,7 @@ export async function init() { | |||
|       Config.funbox | ||||
|     ); | ||||
|   } else if (Config.paceCaret === "average") { | ||||
|     let mode2 = Misc.getMode2(); | ||||
|     let mode2 = UpdateConfig.getMode2(); | ||||
|     wpm = await DB.getUserAverageWpm10( | ||||
|       Config.mode, | ||||
|       mode2, | ||||
|  |  | |||
|  | @ -674,7 +674,7 @@ export function restart( | |||
|         } | ||||
|       } | ||||
| 
 | ||||
|       let mode2 = Misc.getMode2(); | ||||
|       let mode2 = UpdateConfig.getMode2(); | ||||
|       let fbtext = ""; | ||||
|       if (Config.funbox !== "none") { | ||||
|         fbtext = " " + Config.funbox; | ||||
|  | @ -1233,10 +1233,11 @@ export async function addWord() { | |||
|     return; | ||||
|   const language = | ||||
|     Config.mode !== "custom" | ||||
|       ? await Misc.getCurrentLanguage() | ||||
|       ? await Misc.getCurrentLanguage(Config.language) | ||||
|       : { | ||||
|           //borrow the direction of the current language
 | ||||
|           leftToRight: await Misc.getCurrentLanguage().leftToRight, | ||||
|           leftToRight: await Misc.getCurrentLanguage(Config.language) | ||||
|             .leftToRight, | ||||
|           words: CustomText.text, | ||||
|         }; | ||||
|   const wordset = Wordset.withWords(language.words); | ||||
|  | @ -1459,7 +1460,7 @@ function buildCompletedEvent(difficultyFailed) { | |||
|     completedEvent.lang = Config.language.replace(/_\d*k$/g, ""); | ||||
|   } | ||||
| 
 | ||||
|   completedEvent.mode2 = Misc.getMode2(); | ||||
|   completedEvent.mode2 = UpdateConfig.getMode2(); | ||||
| 
 | ||||
|   if (Config.mode === "custom") { | ||||
|     completedEvent.customText = {}; | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue