I currently have a div which displays information such as DNS and IP address.
I am trying to trigger an alert if the IP Address variable changes, so I've attempted both listening for changes to the div and the variable itself without much luck. Is there an obvious way to alert or trigger a function if the variable changes?
$(ipv4.ipaddr).change(function() {
alert("IP Changed");
});
And the script used to display the IP addr normally:
if(result.ipv4){
$("#btn-disconnect").show();
$("#btn-disconnect-modem").show();
var ipv4=result.ipv4;
html+="<tr><td>IPAddr</td><td>"+ ipv4.ipaddr+"</td></tr>";
if(ipv4.netmask) html+="<tr><td>Netmask</td><td>"+ ipv4.netmask+"</td></tr>";
if(ipv4.gateway) html+="<tr><td>Gateway</td><td>"+ ipv4.gateway+"</td></tr>";
label_dns="DNS";
for(var i=0;i<ipv4.dns.length;i++){
html+="<tr><td>"+label_dns+"</td><td>"+ ipv4.dns[i] +"</td></tr>";
label_dns="";
}
if(proto=="wwan" || proto=="tethering"||proto=="3g"){
if(result.tx) html+="<tr><td>TX Data</td><td>"+(result.tx/1024/1024>1? ((result.tx/1024/1024).toFixed(2)+" MB"): ((result.tx/1024).toFixed(2) +" KB") )+" </td></tr>";
if(result.rx) html+="<tr><td>RX Data</td><td>"+(result.rx/1024/1024>1? ((result.rx/1024/1024).toFixed(2)+" MB"): ((result.rx/1024).toFixed(2) +" KB") )+"</td></tr>";
}
if(typeof sta_connected === "function") sta_connected();
}else{
if( (proto=="wwan" ||proto=="tethering")){
if(!result.disabled) html+="<tr><td>Connecting to the Internet</td></tr>";
}
if(proto=="wisp" ||proto=="wds"){
if(!result.disabled) html+="<tr><td>Connecting to the Internet</td></tr>";
result.disabled? $("#btn-disconnect").hide():$("#btn-disconnect").show();
}
}
$(section).html(html);
}