This commit is contained in:
a-ill
2023-07-04 21:38:05 +03:00
parent 3515603e93
commit e803d25a37
6 changed files with 29 additions and 10 deletions

View File

@@ -38,7 +38,6 @@ export function px2rem(px) {
*
* @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393
*/
export function getTextWidth(text, font) {
// re-use canvas object for better performance
const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
@@ -109,4 +108,11 @@ export function validatePosNumber(event,input,callback,max) {
else {
callback(input.value)
}
}
export function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}

View File

@@ -92,10 +92,10 @@ export function loadLocaleContent(content,componentName,loaded,callback) {
}
}
getData("/locales/" + locale + "/" + componentName + ".json" ,function(response) {
if (callback!=undefined) {
callback(locale)
}
let parsed = JSON.parse(response)
if (callback!=undefined) {
callback(parsed)
}
content.set(parsed)
loaded = 1
})