Skip to content

Commit

Permalink
showing both ethernet and wifi ip on screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Puranjay Rajpal authored and Puranjay Rajpal committed Mar 14, 2018
1 parent 06d65a4 commit 4f91034
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 14 deletions.
75 changes: 61 additions & 14 deletions browser/resources/javascripts/main.js
Expand Up @@ -57,33 +57,40 @@ $(document).ready(function() {
}
}

var ethernetConnected = 0;



var checkConnection = function() {
$.get("http://localhost:8000/network/eth0")
.done(function(data) {
if (data.state.address) {
ethernetConnected = 1;
//$("#ip-address").text("IP ADDRESS: " + data.state.address);
assignIp(data);
} else {
$.get("http://localhost:8000/network/wlan")
.done(function(data) {
if (data.state.address) {
assignIp(data);
} else {
noConnection();
}
})
.fail(function() {
noConnection();
});
}
else{
ethernetConnected = 0;
$.get("http://localhost:8000/network/wlan")
.done(function(data) {
if (data.state.address) {
assignIpNoEth(data);
} else {
noConnection();
}
})
.fail(function() {
noConnection();
});
}

})
.fail(function() {
ethernetConnected = 0;
$.get("http://localhost:8000/network/wlan")
.done(function(data) {
if (data.state.address) {
assignIp(data);
assignIpNoEth(data);
} else {
noConnection();
}
Expand All @@ -92,19 +99,59 @@ $(document).ready(function() {
noConnection();
});
});

$.get("http://localhost:8000/network/wlan")
.done(function(data) {
if (data.state.address && ethernetConnected) {
//$("#ip-address").text("IP ADDRESS: " + data.state.address);
assignIpWifi(data);
}

else{

noWifi();

}

})
.fail(function() {

noWifi();

});

}

checkConnection();

var assignIp = function(data) {
$(".span-message").hide();
$(".ip-text").show().text("IP ADDRESS: ");
$(".ip-text").show().text("ETHERNET IP: ");
$(".ip-value").show().text(data.state.address);
}

var assignIpNoEth = function(data) {
$(".span-message").hide();
$(".ip-text").show().text("WIFI IP: ");
$(".ip-value").show().text(data.state.address);
}

var assignIpWifi = function(data) {
$(".span-message").hide();
$(".ip-wifi-text").show().text("WIFI IP: ");
$(".ip-wifi-value").show().text(data.state.address);
}

var noWifi = function(data){
$(".ip-wifi-text").hide();
$(".ip-wifi-value").hide();
}

var noConnection = function() {
$(".ip-text").hide();
$(".ip-value").hide();
$(".ip-wifi-text").hide();
$(".ip-wifi-value").hide();
$(".span-message").show().text("No network connection");
}

Expand Down
3 changes: 3 additions & 0 deletions browser/resources/splash.html
Expand Up @@ -39,6 +39,9 @@
<div id="ip-address">
<span class="span-text ip-text"></span>
<span class="span-value ip-value"></span>
<br>
<span class="span-text ip-wifi-text"></span>
<span class="span-value ip-wifi-value"></span>
<span class="span-message ip-message"></span>
</div>
<div id="version">
Expand Down

0 comments on commit 4f91034

Please sign in to comment.