From b255b7d6b6beda0a1ddc46b614f36f2148b3df0f Mon Sep 17 00:00:00 2001 From: KozakLordOfMatrix Date: Thu, 18 Jun 2026 20:50:26 +0300 Subject: [PATCH] fix: shorten sv_SE speed unit and improve usage stats submission reliability --- apps/locale/locales.js | 2 +- loader.js | 33 ++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/apps/locale/locales.js b/apps/locale/locales.js index 91121190ad1..25432b07841 100644 --- a/apps/locale/locales.js +++ b/apps/locale/locales.js @@ -288,7 +288,7 @@ var locales = { lang: "sv_SE", decimal_point: ",", thousands_sep: ".", - speed: "km/tim", + speed: "km/h", distance: { 0: "m", 1: "km" }, temperature: "°C", ampm: { 0: "fm", 1: "em" }, diff --git a/loader.js b/loader.js index 24483979dcc..8ec6bf17d7e 100644 --- a/loader.js +++ b/loader.js @@ -1,7 +1,7 @@ -if (window.location.host=="banglejs.com") { +if (window.location.host==="banglejs.com") { document.getElementById("apploaderlinks").innerHTML = 'This is the official Bangle.js App Loader - you can also try the Development Version for the most recent apps.'; -} else if (window.location.host=="espruino.github.io") { +} else if (window.location.host==="espruino.github.io") { document.title += " [Development]"; document.getElementById("apploaderlinks").innerHTML = 'This is the development Bangle.js App Loader - you can also try the Official Version for stable apps.'; @@ -76,7 +76,7 @@ function onRefreshMyApps() { var submittedUsageInfo = ""; /* Send usage stats to servers if it has changed */ -function sendUsageStats() { +async function sendUsageStats() { if (!SETTINGS.sendUsageStats) return; // not allowed! if (device.uid === undefined) return; // no data yet! if (!device.appsInstalled.length) return; // no installed apps or disconnected @@ -90,18 +90,21 @@ function sendUsageStats() { // Do a quick check for unchanged data to reduce server load if (usageInfo != submittedUsageInfo) { console.log("sendUsageStats: Submitting usage stats..."); - var xmlhttp = new XMLHttpRequest(); // new HttpRequest instance - xmlhttp.open("POST", "https://banglejs.com/submit_app_stats.php", true /*async*/); - xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xmlhttp.onload = (e) => { - if (xmlhttp.readyState === 4) - console.log(`sendUsageStats (${xmlhttp.status}): ${xmlhttp.responseText}`); - }; - xmlhttp.onerror = (e) => { - console.error("sendUsageStats ERROR: "+xmlhttp.statusText); - }; - xmlhttp.send(usageInfo); - submittedUsageInfo = usageInfo; + try { + const response = await fetch("https://banglejs.com/submit_app_stats.php", { + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: usageInfo + }); + if (response.ok) { + console.log(`sendUsageStats (${response.status}): ${await response.text()}`); + submittedUsageInfo = usageInfo; // Only update on success + } else { + console.error(`sendUsageStats ERROR (${response.status}): ${response.statusText}`); + } + } catch (e) { + console.error("sendUsageStats ERROR: " + e.message); + } } }