simpledemo.html: Added access point information getters

This commit is contained in:
BlueFox 2024-03-26 19:25:17 +01:00
parent 18789ca7c4
commit 724c763f7f
Signed by: BlueFox
GPG Key ID: 327233DA85435270

View File

@ -146,6 +146,14 @@
<td>WiFi SSID</td>
<td class='text-end' id="updatedLabel_WIFISSID_table"><span class="placeholder col-4"></span></td>
</tr>
<tr>
<td>AP SSID</td>
<td class='text-end' id="updatedLabel_APSSID_table"><span class="placeholder col-4"></span></td>
</tr>
<tr>
<td>AP PSK</td>
<td class='text-end' id="updatedLabel_APPSK_table"><span class="placeholder col-4"></span></td>
</tr>
</tbody>
</table>
</div>
@ -550,6 +558,8 @@
restoreStateLabel1 = document.getElementById('updatedLabel_RESTORESTATE_table')
restorePlayingStateLabel1 = document.getElementById('updatedLabel_RESTOREPLAYING_table')
wifiLabel1 = document.getElementById('updatedLabel_WIFISSID_table');
apSsidLabel1 = document.getElementById('updatedLabel_APSSID_table');
apPskLabel1 = document.getElementById('updatedLabel_APPSK_table');
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");
@ -590,6 +600,7 @@
restoreStateApiEndpoint = "/api/v1/system/restore_state/get";
restorePlayingStateApiEndpoint = "/api/v1/system/restore_playing/get";
wifiApiEndpoint = "/api/v1/system/wifi/get_ssid";
apApiEndpoint = "/api/v1/system/wifi/get_ap_creds";
playbackInfoApiEndpoint = "/api/v1/playback/info";
volumeApiEndpoint = "/api/v1/volume/get";
eqApiEndpoint = "/api/v1/eq/get";
@ -655,6 +666,19 @@
wifiRequest.open("GET", apiBase + wifiApiEndpoint, true);
wifiRequest.send();
/* AP SSID and PSK parser */
var apRequest = new XMLHttpRequest();
apRequest.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var apSsidString = JSON.parse(this.responseText).ap_ssid;
var apPskString = JSON.parse(this.responseText).ap_psk;
apSsidLabel1.innerHTML = apSsidString;
apPskLabel1.innerHTML = apPskString;
}
}
apRequest.open("GET", apiBase + apApiEndpoint, true);
apRequest.send();
/* Playback info parser */
var playbackInfoRequest = new XMLHttpRequest();
playbackInfoRequest.onreadystatechange = function() {