simpledemo.html: Added support for the tell_address api endpoint.

This commit is contained in:
BlueFox 2024-03-30 11:17:27 +01:00
parent c0b5820ff1
commit 201f8bfbfe

View File

@ -142,6 +142,10 @@
<td>Save & Restore playing state (default no)</td>
<td class='text-end' id="updatedLabel_RESTOREPLAYING_table"><span class="placeholder col-4"></span></td>
</tr>
<tr>
<td>Tell address at startup (default yes)</td>
<td class='text-end' id="updatedLabel_TELLADDRESS_table"><span class="placeholder col-4"></span></td>
</tr>
<tr>
<td>WiFi SSID</td>
<td class='text-end' id="updatedLabel_WIFISSID_table"><span class="placeholder col-4"></span></td>
@ -256,7 +260,7 @@
</div>
</div>
<!--PLAYLIST Collapsible -->
<!-- PLAYLIST Collapsible -->
<div class='accordion-item'>
<h2 class='accordion-header'>
<button class='accordion-button collapsed' type='button' data-bs-toggle='collapse'
@ -302,7 +306,7 @@
</div>
</div>
<!--BALANCE Collapsible -->
<!-- BALANCE Collapsible -->
<div class='accordion-item'>
<h2 class='accordion-header'>
<button class='accordion-button collapsed' type='button' data-bs-toggle='collapse'
@ -505,6 +509,30 @@
</div>
</div>
<!-- TELL ADDRESS Collapsible -->
<div class='accordion-item'>
<h2 class='accordion-header'>
<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'>
Tell address
&nbsp;<span class='badge text-bg-warning'>/api/v1/system/tell_address/</span>
</button>
</h2>
<div id='accordion-collapse-tell-address' class='accordion-collapse collapse' data-bs-parent='#accordion'>
<div class='accordion-body'>
<p>At startup, the NetSpeaker tells it's address with Google TTS when in operation mode 0, 2 or 3.
This can be turned on and off. On by default.
</p>
<div class='form-check form-switch'>
<input onclick="http = new XMLHttpRequest();http.open('GET', 'http://' + document.cookie +
'/api/v1/system/tell_address/' + (this.checked ? 'on' : 'off'));http.send();updateStrings();"
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>
</div>
</div>
</div>
</div>
<!-- RESTART Collapsible -->
<div class='accordion-item'>
<h2 class='accordion-header'>
@ -593,6 +621,8 @@
restoreStateSwitch1 = document.getElementById('updatedLabel_RESTORESTATE_switch')
restorePlayingStateLabel1 = document.getElementById('updatedLabel_RESTOREPLAYING_table')
restorePlayingStateSwitch1 = document.getElementById('updatedLabel_RESTOREPLAYING_switch')
tellAddressLabel1 = document.getElementById('updatedLabel_TELLADDRESS_table')
tellAddressSwitch1 = document.getElementById('updatedLabel_TELLADDRESS_switch')
wifiLabel1 = document.getElementById('updatedLabel_WIFISSID_table');
apSsidLabel1 = document.getElementById('updatedLabel_APSSID_table');
apSsidLabel2 = document.getElementById('updatedLabel_APSSID_code');
@ -639,6 +669,7 @@
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";
@ -710,6 +741,18 @@
restorePlayingRequest.open("GET", apiBase + restorePlayingStateApiEndpoint, true);
restorePlayingRequest.send();
/* Tell address parser */
var tellAddressRequest = new XMLHttpRequest();
tellAddressRequest.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var tellAddressValue = JSON.parse(this.responseText).tell_address;
tellAddressLabel1.innerHTML = tellAddressValue ? "yes" : "no";
tellAddressSwitch1.checked = tellAddressValue;
}
}
tellAddressRequest.open("GET", apiBase + tellAddressApiEndpoint, true);
tellAddressRequest.send();
/* WiFi SSID parser */
var wifiRequest = new XMLHttpRequest();
@ -722,6 +765,7 @@
wifiRequest.open("GET", apiBase + wifiApiEndpoint, true);
wifiRequest.send();
/* AP SSID and PSK parser */
var apRequest = new XMLHttpRequest();
apRequest.onreadystatechange = function() {
@ -931,4 +975,7 @@ updatedLabel_RS_YEAR_table_top
updatedLabel_RS_GENRE_table_top
updatedLabel_RS_COPYRIGHT_table_top
updatedLabel_RS_LANGUAGE_table_top
updatedLabel_TELLADDRESS_table
updatedLabel_TELLADDRESS_switch
-->