mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 09:17:56 +01:00
Separating logic in network/status handler
This commit is contained in:
parent
556fc0dd1e
commit
c4ec82c9a7
@ -144,7 +144,9 @@ function NetworkPanel() {
|
|||||||
}
|
}
|
||||||
console.log("NetworkPanel:retrievedStatus status: ",data.status,data.statusMessage);
|
console.log("NetworkPanel:retrievedStatus status: ",data.status,data.statusMessage);
|
||||||
|
|
||||||
// Determine which network settings to show
|
// if status changed
|
||||||
|
if(data.status != _currentNetworkStatus) {
|
||||||
|
// Determine which network mode ui to show
|
||||||
switch(data.status) {
|
switch(data.status) {
|
||||||
case NetworkAPI.STATUS.NOT_CONNECTED:
|
case NetworkAPI.STATUS.NOT_CONNECTED:
|
||||||
setNetworkMode(NETWORK_MODE.NEITHER);
|
setNetworkMode(NETWORK_MODE.NEITHER);
|
||||||
@ -153,33 +155,33 @@ function NetworkPanel() {
|
|||||||
case NetworkAPI.STATUS.CONNECTING:
|
case NetworkAPI.STATUS.CONNECTING:
|
||||||
case NetworkAPI.STATUS.CONNECTED:
|
case NetworkAPI.STATUS.CONNECTED:
|
||||||
setNetworkMode(NETWORK_MODE.CLIENT);
|
setNetworkMode(NETWORK_MODE.CLIENT);
|
||||||
|
|
||||||
if(data.status == NetworkAPI.STATUS.CONNECTED) {
|
|
||||||
_networkSelector.val(data.ssid);
|
|
||||||
|
|
||||||
_currentNetwork = data.ssid;
|
|
||||||
_currentLocalIP = data.localip;
|
|
||||||
_self.selectNetwork(data.ssid);
|
|
||||||
} else {
|
|
||||||
_currentLocalIP = "";
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NetworkAPI.STATUS.CREATING:
|
case NetworkAPI.STATUS.CREATING:
|
||||||
case NetworkAPI.STATUS.CREATED:
|
case NetworkAPI.STATUS.CREATED:
|
||||||
setNetworkMode(NETWORK_MODE.ACCESS_POINT);
|
setNetworkMode(NETWORK_MODE.ACCESS_POINT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// update info
|
||||||
|
switch(data.status) {
|
||||||
|
case NetworkAPI.STATUS.CONNECTED:
|
||||||
|
_currentNetwork = data.ssid;
|
||||||
|
_currentLocalIP = data.localip;
|
||||||
|
_self.selectNetwork(data.ssid);
|
||||||
|
break;
|
||||||
|
case NetworkAPI.STATUS.CONNECTING_FAILED:
|
||||||
|
case NetworkAPI.STATUS.CONNECTING:
|
||||||
|
_currentLocalIP = "";
|
||||||
|
break;
|
||||||
|
case NetworkAPI.STATUS.CREATING:
|
||||||
|
case NetworkAPI.STATUS.CREATED:
|
||||||
_currentNetwork = undefined;
|
_currentNetwork = undefined;
|
||||||
_self.selectNetwork(NOT_CONNECTED);
|
_self.selectNetwork(NOT_CONNECTED);
|
||||||
_networkSelector.val(NOT_CONNECTED);
|
|
||||||
|
|
||||||
if(data.ssid && data.status == NetworkAPI.STATUS.CREATED) {
|
if(data.ssid && data.status == NetworkAPI.STATUS.CREATED) {
|
||||||
_currentAP = data.ssid;
|
_currentAP = data.ssid;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// update ui
|
||||||
// update ui if status changed
|
|
||||||
if(data.status != _currentNetworkStatus) {
|
|
||||||
updateClientModeUI(data.status,data.statusMessage);
|
updateClientModeUI(data.status,data.statusMessage);
|
||||||
updateAPModeUI(data.status,"");
|
updateAPModeUI(data.status,"");
|
||||||
}
|
}
|
||||||
@ -250,15 +252,16 @@ function NetworkPanel() {
|
|||||||
case NetworkAPI.STATUS.CREATED:
|
case NetworkAPI.STATUS.CREATED:
|
||||||
_btnConnect.removeAttr("disabled");
|
_btnConnect.removeAttr("disabled");
|
||||||
msg = "Not connected";
|
msg = "Not connected";
|
||||||
|
_networkSelector.val(NOT_CONNECTED);
|
||||||
break;
|
break;
|
||||||
case NetworkAPI.STATUS.CONNECTED:
|
case NetworkAPI.STATUS.CONNECTED:
|
||||||
_btnConnect.removeAttr("disabled");
|
_btnConnect.removeAttr("disabled");
|
||||||
|
|
||||||
msg = "Connected to: <b>"+_currentNetwork+"</b>.";
|
msg = "Connected to: <b>"+_currentNetwork+"</b>.";
|
||||||
if(_currentLocalIP != undefined && _currentLocalIP != "") {
|
if(_currentLocalIP != undefined && _currentLocalIP != "") {
|
||||||
var a = "<a href='http://"+_currentLocalIP+"' target='_black'>"+_currentLocalIP+"</a>";
|
var a = "<a href='http://"+_currentLocalIP+"' target='_black'>"+_currentLocalIP+"</a>";
|
||||||
msg += " (IP: "+a+")";
|
msg += " (IP: "+a+")";
|
||||||
}
|
}
|
||||||
|
_networkSelector.val(_currentNetwork);
|
||||||
break;
|
break;
|
||||||
case NetworkAPI.STATUS.CONNECTING:
|
case NetworkAPI.STATUS.CONNECTING:
|
||||||
_btnConnect.attr("disabled", true);
|
_btnConnect.attr("disabled", true);
|
||||||
|
Loading…
Reference in New Issue
Block a user