simpledemo.html: Added support for changing the tell address language.

This commit is contained in:
BlueFox 2024-03-30 14:36:54 +01:00
parent 201f8bfbfe
commit 4a5accbd4a

View File

@ -146,6 +146,10 @@
<td>Tell address at startup (default yes)</td> <td>Tell address at startup (default yes)</td>
<td class='text-end' id="updatedLabel_TELLADDRESS_table"><span class="placeholder col-4"></span></td> <td class='text-end' id="updatedLabel_TELLADDRESS_table"><span class="placeholder col-4"></span></td>
</tr> </tr>
<tr>
<td>Tell address language (default en)</td>
<td class='text-end' id="updatedLabel_TELLADDRESS_LANG_table"><span class="placeholder col-4"></span></td>
</tr>
<tr> <tr>
<td>WiFi SSID</td> <td>WiFi SSID</td>
<td class='text-end' id="updatedLabel_WIFISSID_table"><span class="placeholder col-4"></span></td> <td class='text-end' id="updatedLabel_WIFISSID_table"><span class="placeholder col-4"></span></td>
@ -515,7 +519,7 @@
<button class='accordion-button collapsed' type='button' data-bs-toggle='collapse' <button class='accordion-button collapsed' type='button' data-bs-toggle='collapse'
data-bs-target='#accordion-collapse-tell-address' aria-expanded='true' aria-controls='accordion-collapse-tell-address'> data-bs-target='#accordion-collapse-tell-address' aria-expanded='true' aria-controls='accordion-collapse-tell-address'>
Tell address Tell address
&nbsp;<span class='badge text-bg-warning'>/api/v1/system/tell_address/</span> &nbsp;<span class='badge text-bg-light'>/api/v1/system/tell_address/</span>
</button> </button>
</h2> </h2>
<div id='accordion-collapse-tell-address' class='accordion-collapse collapse' data-bs-parent='#accordion'> <div id='accordion-collapse-tell-address' class='accordion-collapse collapse' data-bs-parent='#accordion'>
@ -529,6 +533,24 @@
class='form-check-input' type='checkbox' role='switch' id='updatedLabel_TELLADDRESS_switch'> class='form-check-input' type='checkbox' role='switch' id='updatedLabel_TELLADDRESS_switch'>
<label class='form-check-label' for='updatedLabel_TELLADDRESS_switch'>Tell address at startup</label> <label class='form-check-label' for='updatedLabel_TELLADDRESS_switch'>Tell address at startup</label>
</div> </div>
<hr> <!-- Horizontal ruler for seperation -->
<div class='input-group mb-3'>
<span class='input-group-text' id='updatedLabel_TELLADDRESS_LANG_bottom'>...</span>
<span class='input-group-text'> -> </span>
<input type='text' class='form-control' placeholder='Language (de/en)' aria-label='New friendly name'
aria-describedby='tellLangChange_BTN_submitLang' id='tellLangChange_newLangInput'>
<button class='btn btn-success' type='button' id='tellLangChange_BTN_submitLang' onclick="
newLang = document.getElementById('tellLangChange_newLangInput').value;
oldLang = document.getElementById('updatedLabel_TELLADDRESS_LANG_bottom').innerHTML;
if(oldLang != newLang) {
http = new XMLHttpRequest();
http.open('GET', 'http://' + document.cookie + '/api/v1/system/tell_address/lang/' + newLang);
http.send();
updateStrings();
}">
Change
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -623,6 +645,8 @@
restorePlayingStateSwitch1 = document.getElementById('updatedLabel_RESTOREPLAYING_switch') restorePlayingStateSwitch1 = document.getElementById('updatedLabel_RESTOREPLAYING_switch')
tellAddressLabel1 = document.getElementById('updatedLabel_TELLADDRESS_table') tellAddressLabel1 = document.getElementById('updatedLabel_TELLADDRESS_table')
tellAddressSwitch1 = document.getElementById('updatedLabel_TELLADDRESS_switch') 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'); wifiLabel1 = document.getElementById('updatedLabel_WIFISSID_table');
apSsidLabel1 = document.getElementById('updatedLabel_APSSID_table'); apSsidLabel1 = document.getElementById('updatedLabel_APSSID_table');
apSsidLabel2 = document.getElementById('updatedLabel_APSSID_code'); apSsidLabel2 = document.getElementById('updatedLabel_APSSID_code');
@ -630,20 +654,20 @@
hostnameLabel2 = document.getElementById('updatedLabel_HOSTNAME_table_bottom'); hostnameLabel2 = document.getElementById('updatedLabel_HOSTNAME_table_bottom');
apPskLabel1 = document.getElementById('updatedLabel_APPSK_table'); apPskLabel1 = document.getElementById('updatedLabel_APPSK_table');
apPskLabel2 = document.getElementById('updatedLabel_APPSK_code'); apPskLabel2 = document.getElementById('updatedLabel_APPSK_code');
const playingLabel1 = document.getElementById("updatedLabel_PLAYING_table_top"); playingLabel1 = document.getElementById("updatedLabel_PLAYING_table_top");
const playingLabel2 = document.getElementById("updatedLabel_PLAYING_table_bottom"); playingLabel2 = document.getElementById("updatedLabel_PLAYING_table_bottom");
const rs_plpathLabel1 = document.getElementById("updatedLabel_RS_PLPATH_table_top"); rs_plpathLabel1 = document.getElementById("updatedLabel_RS_PLPATH_table_top");
const rs_plidxLabel1 = document.getElementById("updatedLabel_RS_PLIDX_table_top"); rs_plidxLabel1 = document.getElementById("updatedLabel_RS_PLIDX_table_top");
const rs_pathLabel1 = document.getElementById("updatedLabel_RS_PATH_table_top"); rs_pathLabel1 = document.getElementById("updatedLabel_RS_PATH_table_top");
const rs_typeLabel1 = document.getElementById("updatedLabel_RS_TYPE_table_top"); rs_typeLabel1 = document.getElementById("updatedLabel_RS_TYPE_table_top");
const rs_titleLabel1 = document.getElementById("updatedLabel_RS_TITLE_table_top"); rs_titleLabel1 = document.getElementById("updatedLabel_RS_TITLE_table_top");
const rs_albumLabel1 = document.getElementById("updatedLabel_RS_ALBUM_table_top"); rs_albumLabel1 = document.getElementById("updatedLabel_RS_ALBUM_table_top");
const rs_artistLabel1 = document.getElementById("updatedLabel_RS_ARTIST_table_top"); rs_artistLabel1 = document.getElementById("updatedLabel_RS_ARTIST_table_top");
const rs_tracknrLabel1 = document.getElementById("updatedLabel_RS_TRACKNR_table_top"); rs_tracknrLabel1 = document.getElementById("updatedLabel_RS_TRACKNR_table_top");
const rs_yearLabel1 = document.getElementById("updatedLabel_RS_YEAR_table_top"); rs_yearLabel1 = document.getElementById("updatedLabel_RS_YEAR_table_top");
const rs_genreLabel1 = document.getElementById("updatedLabel_RS_GENRE_table_top"); rs_genreLabel1 = document.getElementById("updatedLabel_RS_GENRE_table_top");
const rs_copyrightLabel1 = document.getElementById("updatedLabel_RS_COPYRIGHT_table_top"); rs_copyrightLabel1 = document.getElementById("updatedLabel_RS_COPYRIGHT_table_top");
const rs_languageLabel1 = document.getElementById("updatedLabel_RS_LANGUAGE_table_top"); rs_languageLabel1 = document.getElementById("updatedLabel_RS_LANGUAGE_table_top");
volumeLabel1 = document.getElementById('updatedLabel_VOLUME_table_top'); volumeLabel1 = document.getElementById('updatedLabel_VOLUME_table_top');
volumeLabel2 = document.getElementById('updatedLabel_VOLUME_table_bottom'); volumeLabel2 = document.getElementById('updatedLabel_VOLUME_table_bottom');
volumeRange1 = document.getElementById('updatedLabel_VOLUME_range_bottom'); volumeRange1 = document.getElementById('updatedLabel_VOLUME_range_bottom');
@ -664,19 +688,20 @@
function updateStrings() { function updateStrings() {
apiBase = "http://" + document.cookie; apiBase = "http://" + document.cookie;
versionApiEndpoint = "/api/v1/system/version"; versionApiEndpoint = "/api/v1/system/version";
frnameApiEndpoint = "/api/v1/system/name"; frnameApiEndpoint = "/api/v1/system/name";
restoreStateApiEndpoint = "/api/v1/system/restore_state/get"; restoreStateApiEndpoint = "/api/v1/system/restore_state/get";
restorePlayingStateApiEndpoint = "/api/v1/system/restore_playing/get"; restorePlayingStateApiEndpoint = "/api/v1/system/restore_playing/get";
tellAddressApiEndpoint = "/api/v1/system/tell_address/get"; tellAddressApiEndpoint = "/api/v1/system/tell_address/get";
wifiApiEndpoint = "/api/v1/system/wifi/get_ssid"; tellAddressLangStateApiEndpoint = "/api/v1/system/tell_address/lang/get";
hostnameApiEndpoint = "/api/v1/system/network_name"; wifiApiEndpoint = "/api/v1/system/wifi/get_ssid";
apApiEndpoint = "/api/v1/system/wifi/get_ap_creds"; hostnameApiEndpoint = "/api/v1/system/network_name";
playbackInfoApiEndpoint = "/api/v1/playback/info"; apApiEndpoint = "/api/v1/system/wifi/get_ap_creds";
volumeApiEndpoint = "/api/v1/volume/get"; playbackInfoApiEndpoint = "/api/v1/playback/info";
eqApiEndpoint = "/api/v1/eq/get"; volumeApiEndpoint = "/api/v1/volume/get";
balanceApiEndpoint = "/api/v1/balance/get"; eqApiEndpoint = "/api/v1/eq/get";
balanceApiEndpoint = "/api/v1/balance/get";
/* Version string parser */ /* Version string parser */
var versionRequest = new XMLHttpRequest(); var versionRequest = new XMLHttpRequest();
@ -741,7 +766,8 @@
restorePlayingRequest.open("GET", apiBase + restorePlayingStateApiEndpoint, true); restorePlayingRequest.open("GET", apiBase + restorePlayingStateApiEndpoint, true);
restorePlayingRequest.send(); restorePlayingRequest.send();
/* Tell address parser */
/* Tell address + Tell address lang parser */
var tellAddressRequest = new XMLHttpRequest(); var tellAddressRequest = new XMLHttpRequest();
tellAddressRequest.onreadystatechange = function() { tellAddressRequest.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
@ -753,6 +779,16 @@
tellAddressRequest.open("GET", apiBase + tellAddressApiEndpoint, true); tellAddressRequest.open("GET", apiBase + tellAddressApiEndpoint, true);
tellAddressRequest.send(); 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 */ /* WiFi SSID parser */
var wifiRequest = new XMLHttpRequest(); var wifiRequest = new XMLHttpRequest();
@ -978,4 +1014,6 @@ updatedLabel_RS_LANGUAGE_table_top
updatedLabel_TELLADDRESS_table updatedLabel_TELLADDRESS_table
updatedLabel_TELLADDRESS_switch updatedLabel_TELLADDRESS_switch
updatedLabel_TELLADDRESS_LANG_table
updatedLabel_TELLADDRESS_LANG_bottom
--> -->