From 4a5accbd4adf5da09f51b2430876f544302990dc Mon Sep 17 00:00:00 2001 From: BlueFox Date: Sat, 30 Mar 2024 14:36:54 +0100 Subject: [PATCH] simpledemo.html: Added support for changing the tell address language. --- simpledemo.html | 96 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 29 deletions(-) diff --git a/simpledemo.html b/simpledemo.html index 99be39f..92f2021 100644 --- a/simpledemo.html +++ b/simpledemo.html @@ -146,6 +146,10 @@ Tell address at startup (default yes) + + Tell address language (default en) + + WiFi SSID @@ -515,7 +519,7 @@
@@ -529,6 +533,24 @@ class='form-check-input' type='checkbox' role='switch' id='updatedLabel_TELLADDRESS_switch'>
+
+
+ ... + -> + + +
@@ -623,6 +645,8 @@ restorePlayingStateSwitch1 = document.getElementById('updatedLabel_RESTOREPLAYING_switch') tellAddressLabel1 = document.getElementById('updatedLabel_TELLADDRESS_table') tellAddressSwitch1 = document.getElementById('updatedLabel_TELLADDRESS_switch') + tellAddressLangLabel1 = document.getElementById('updatedLabel_TELLADDRESS_LANG_table') + tellAddressLangLabel2 = document.getElementById('updatedLabel_TELLADDRESS_LANG_bottom') wifiLabel1 = document.getElementById('updatedLabel_WIFISSID_table'); apSsidLabel1 = document.getElementById('updatedLabel_APSSID_table'); apSsidLabel2 = document.getElementById('updatedLabel_APSSID_code'); @@ -630,20 +654,20 @@ hostnameLabel2 = document.getElementById('updatedLabel_HOSTNAME_table_bottom'); apPskLabel1 = document.getElementById('updatedLabel_APPSK_table'); apPskLabel2 = document.getElementById('updatedLabel_APPSK_code'); - const playingLabel1 = document.getElementById("updatedLabel_PLAYING_table_top"); - const playingLabel2 = document.getElementById("updatedLabel_PLAYING_table_bottom"); - const rs_plpathLabel1 = document.getElementById("updatedLabel_RS_PLPATH_table_top"); - const rs_plidxLabel1 = document.getElementById("updatedLabel_RS_PLIDX_table_top"); - const rs_pathLabel1 = document.getElementById("updatedLabel_RS_PATH_table_top"); - const rs_typeLabel1 = document.getElementById("updatedLabel_RS_TYPE_table_top"); - const rs_titleLabel1 = document.getElementById("updatedLabel_RS_TITLE_table_top"); - const rs_albumLabel1 = document.getElementById("updatedLabel_RS_ALBUM_table_top"); - const rs_artistLabel1 = document.getElementById("updatedLabel_RS_ARTIST_table_top"); - const rs_tracknrLabel1 = document.getElementById("updatedLabel_RS_TRACKNR_table_top"); - const rs_yearLabel1 = document.getElementById("updatedLabel_RS_YEAR_table_top"); - const rs_genreLabel1 = document.getElementById("updatedLabel_RS_GENRE_table_top"); - const rs_copyrightLabel1 = document.getElementById("updatedLabel_RS_COPYRIGHT_table_top"); - const rs_languageLabel1 = document.getElementById("updatedLabel_RS_LANGUAGE_table_top"); + playingLabel1 = document.getElementById("updatedLabel_PLAYING_table_top"); + playingLabel2 = document.getElementById("updatedLabel_PLAYING_table_bottom"); + rs_plpathLabel1 = document.getElementById("updatedLabel_RS_PLPATH_table_top"); + rs_plidxLabel1 = document.getElementById("updatedLabel_RS_PLIDX_table_top"); + rs_pathLabel1 = document.getElementById("updatedLabel_RS_PATH_table_top"); + rs_typeLabel1 = document.getElementById("updatedLabel_RS_TYPE_table_top"); + rs_titleLabel1 = document.getElementById("updatedLabel_RS_TITLE_table_top"); + rs_albumLabel1 = document.getElementById("updatedLabel_RS_ALBUM_table_top"); + rs_artistLabel1 = document.getElementById("updatedLabel_RS_ARTIST_table_top"); + rs_tracknrLabel1 = document.getElementById("updatedLabel_RS_TRACKNR_table_top"); + rs_yearLabel1 = document.getElementById("updatedLabel_RS_YEAR_table_top"); + rs_genreLabel1 = document.getElementById("updatedLabel_RS_GENRE_table_top"); + rs_copyrightLabel1 = document.getElementById("updatedLabel_RS_COPYRIGHT_table_top"); + rs_languageLabel1 = document.getElementById("updatedLabel_RS_LANGUAGE_table_top"); volumeLabel1 = document.getElementById('updatedLabel_VOLUME_table_top'); volumeLabel2 = document.getElementById('updatedLabel_VOLUME_table_bottom'); volumeRange1 = document.getElementById('updatedLabel_VOLUME_range_bottom'); @@ -664,19 +688,20 @@ function updateStrings() { - apiBase = "http://" + document.cookie; - versionApiEndpoint = "/api/v1/system/version"; - frnameApiEndpoint = "/api/v1/system/name"; - restoreStateApiEndpoint = "/api/v1/system/restore_state/get"; - restorePlayingStateApiEndpoint = "/api/v1/system/restore_playing/get"; - tellAddressApiEndpoint = "/api/v1/system/tell_address/get"; - wifiApiEndpoint = "/api/v1/system/wifi/get_ssid"; - hostnameApiEndpoint = "/api/v1/system/network_name"; - apApiEndpoint = "/api/v1/system/wifi/get_ap_creds"; - playbackInfoApiEndpoint = "/api/v1/playback/info"; - volumeApiEndpoint = "/api/v1/volume/get"; - eqApiEndpoint = "/api/v1/eq/get"; - balanceApiEndpoint = "/api/v1/balance/get"; + apiBase = "http://" + document.cookie; + versionApiEndpoint = "/api/v1/system/version"; + frnameApiEndpoint = "/api/v1/system/name"; + restoreStateApiEndpoint = "/api/v1/system/restore_state/get"; + restorePlayingStateApiEndpoint = "/api/v1/system/restore_playing/get"; + tellAddressApiEndpoint = "/api/v1/system/tell_address/get"; + tellAddressLangStateApiEndpoint = "/api/v1/system/tell_address/lang/get"; + wifiApiEndpoint = "/api/v1/system/wifi/get_ssid"; + hostnameApiEndpoint = "/api/v1/system/network_name"; + apApiEndpoint = "/api/v1/system/wifi/get_ap_creds"; + playbackInfoApiEndpoint = "/api/v1/playback/info"; + volumeApiEndpoint = "/api/v1/volume/get"; + eqApiEndpoint = "/api/v1/eq/get"; + balanceApiEndpoint = "/api/v1/balance/get"; /* Version string parser */ var versionRequest = new XMLHttpRequest(); @@ -741,7 +766,8 @@ restorePlayingRequest.open("GET", apiBase + restorePlayingStateApiEndpoint, true); restorePlayingRequest.send(); - /* Tell address parser */ + + /* Tell address + Tell address lang parser */ var tellAddressRequest = new XMLHttpRequest(); tellAddressRequest.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { @@ -753,6 +779,16 @@ tellAddressRequest.open("GET", apiBase + tellAddressApiEndpoint, true); tellAddressRequest.send(); + var tellAddressLangRequest = new XMLHttpRequest(); + tellAddressLangRequest.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + var tellAddressLangValueString = JSON.parse(this.responseText).tell_address_lang; + tellAddressLangLabel1.innerHTML = tellAddressLangValueString;; + tellAddressLangLabel2.innerHTML = tellAddressLangValueString; + } + } + tellAddressLangRequest.open("GET", apiBase + tellAddressLangStateApiEndpoint, true); + tellAddressLangRequest.send(); /* WiFi SSID parser */ var wifiRequest = new XMLHttpRequest(); @@ -978,4 +1014,6 @@ updatedLabel_RS_LANGUAGE_table_top updatedLabel_TELLADDRESS_table updatedLabel_TELLADDRESS_switch +updatedLabel_TELLADDRESS_LANG_table +updatedLabel_TELLADDRESS_LANG_bottom -->