PWA wifi functions were not attached to DOM elements, only mobile ones. getWifi, setWifi and editWifi bindings were added to both pwa.init and mobile.init functions and DOM elements were bound to the generic functions. Resolves #7

This commit is contained in:
mmcwilliams 2020-05-15 23:06:57 -04:00
parent 319e7a72ae
commit 2e3cc409b0
5 changed files with 16 additions and 9 deletions

View File

@ -73,15 +73,15 @@
Local IP: null
</div>
<div>
<select id="available" class="" onchange="mobile.editWifi();">
<select id="available" class="" onchange="editWifi();">
<option>N/A</option>
</select>
</div>
<div>
<input type="password" id="password" class="" placeholder="Wifi Password" />
</div>
<button id="wifi" class="" onclick="mobile.setWifi();">CONNECT</button>
<button id="wifiRefresh" class="" onclick="mobile.getWifi();">REFRESH WIFI</button>
<button id="wifi" class="" onclick="setWifi();">CONNECT</button>
<button id="wifiRefresh" class="" onclick="getWifi();">REFRESH WIFI</button>
</div>
<div>
<button id="reset" onclick="reset();">RESET</button>

View File

@ -185,11 +185,11 @@ var setState = function (res) {
if (res.sequence == true) {
if (mobile.ble) mobile.ble.active = true;
if (pwa.wble) pwa.ble.active = true;
if (pwa.wble) pwa.wble.active = true;
seqState(true);
} else {
if (mobile.ble) mobile.ble.active = false;
if (pwa.wble) pwa.ble.active = false;
if (pwa.wble) pwa.wble.active = false;
seqState(false);
}
};

View File

@ -82,7 +82,7 @@ mobile.ble.onConnect = function (peripheral, device) {
scan.classList.remove('active');
getState();
mobile.getWifi();
getWifi();
};
mobile.ble.disconnect = function () {
@ -148,6 +148,9 @@ mobile.init = function () {
window.reset = mobile.reset;
window.restart = mobile.restart;
window.update = mobile.update;
window.getWifi = mobile.getWifi;
window.setWifi = mobile.setWifi;
window.editWifi = mobile.editWifi;
//show ble-specific fields in settings
for (let i of bleInputs) {

View File

@ -129,7 +129,7 @@ pwa.wble.onConnect = function (peripheral, device, service) {
scan.classList.remove('active');
getState();
pwa.getWifi();
getWifi();
};
pwa.wble.disconnect = function () {
@ -252,6 +252,9 @@ pwa.init = function () {
window.reset = pwa.reset;
window.restart = pwa.restart;
window.update = pwa.update;
window.getWifi = pwa.getWifi;
window.setWifi = pwa.setWifi;
window.editWifi = pwa.editWifi;
//show ble-specific fields in settings
for (let i of bleInputs) {
@ -497,7 +500,8 @@ pwa.getWifiSuccess = function (res) {
UI.spinner.hide();
UI.overlay.hide();
elem.innerHTML = ''
elem.innerHTML = '';
console.dir(res);
if (!res.available || res.available.length === 0) {
if (elem.classList.contains('active')) {
elem.classList.remove('active');