@ -42,7 +42,7 @@ $( window ).on( "load", function()
// Clears the URL to remove everything off after '?'.
// Clears the URL to remove everything off after '?'.
//var newURL = location.href.split("?")[0];
//var newURL = location.href.split("?")[0];
//window.history.pushState('object', document.title, newURL);
//window.history.pushState('object', document.title, newURL);
console . log ( 'onload fired.' ) ;
//console.log('onload fired.');
/ *
/ *
if ( $ ( "#interface_list" ) . val ( ) ) {
if ( $ ( "#interface_list" ) . val ( ) ) {
@ -53,43 +53,76 @@ $( window ).on( "load", function()
} ) ;
} ) ;
}
}
* /
* /
jQuery . each ( "bcn sn ifn" . split ( " " ) , function ( index , network ) {
$ . getJSON ( '/status/network.json' , { get _param : 'value' } , function ( data ) {
console . log ( 'Network: [' + network + '].' ) ;
$ . each ( data . ips , function ( index , element ) {
if ( $ ( "#" + network + "_count" ) . val ( ) ) {
console . log ( '- entry: [' + index + '], on: [' + element . on + '], address: [' + element . address + '], subnet: [' + element . subnet + '].' ) ;
var count = $ ( "#" + network + "_count" ) . val ( ) ;
console . log ( '- gateway: [' + element . gateway + '], dns: [' + element . dns + '], default gateway: [' + element . default _gateway + '].' ) ;
console . log ( network + ' count: [' + count + '].' ) ;
for ( var i = 1 ; i <= count ; i ++ ) {
// If this is the default gateway, see about setting the Gateway IP and DNS.
var network _name = network + i ;
if ( element . default _gateway == '1' ) {
console . log ( 'Network: [' + network _name + '], BCN IP set: [' + $ ( "#" + network _name + "_ip" ) . val ( ) + '], default: [' + $ ( "#" + network _name + "_ip_default" ) . val ( ) + '].' ) ;
console . log ( 'This is the default gateway interface.' ) ;
if ( $ ( "#" + network _name + "_ip" ) . val ( ) == '' ) {
console . log ( '- Form value for gateway......: [' + $ ( "#gateway" ) . val ( ) + '] and dns: [' + $ ( "#dns" ) . val ( ) + '].' ) ;
var set _ip = '' ;
console . log ( '- Default values for gateway..: [' + $ ( "#gateway_default" ) . val ( ) + '] and dns: [' + $ ( "#dns_default" ) . val ( ) + '].' ) ;
var set _subnet = '' ;
console . log ( '- Interface values for gateway: [' + element . gateway + '] and dns: [' + element . dns + '].' ) ;
var set _gateway = '' ;
if ( ( $ ( "#gateway" ) . val ( ) == '' ) && ( element . gateway ) ) {
var set _dns = '' ;
$ ( "#gateway" ) . val ( element . gateway ) ;
$ . getJSON ( '/status/network.json' , { get _param : 'value' } , function ( data ) {
}
$ . each ( data . ips , function ( index , element ) {
if ( ( $ ( "#dns" ) . val ( ) == '' ) && ( element . dns ) ) {
var on _interface = element . on ;
$ ( "#dns" ) . val ( element . dns ) ;
if ( on _interface . match ( new RegExp ( network _name ) ) ) {
}
console . log ( 'entry: [' + index + '], on: [' + element . on + '], address: [' + element . address + '], subnet: [' + element . subnet + '].' ) ;
}
console . log ( '- gateway: [' + element . gateway + '], dns: [' + element . dns + '], default gateway: [' + element . default _gateway + '].' ) ;
} ) ;
if ( element . default _gateway == '1' ) {
// If DNS or gateway are blank still and we have default values, set them.
if ( $ ( "#gateway" ) . val ( ) == '' ) {
console . log ( 'Form value for gateway......: [' + $ ( "#gateway" ) . val ( ) + '] and dns: [' + $ ( "#dns" ) . val ( ) + '].' ) ;
$ ( "#gateway" ) . val ( element . gateway ) ;
console . log ( 'Interface values for gateway: [' + $ ( "#gateway_default" ) . val ( ) + '] and dns: [' + $ ( "#dns_default" ) . val ( ) + '].' ) ;
} ;
if ( ( $ ( "#gateway" ) . val ( ) == '' ) && ( $ ( "#gateway_default" ) . val ( ) ) ) {
if ( $ ( "#dns" ) . val ( ) == '' ) {
$ ( "#gateway" ) . val ( $ ( "#gateway_default" ) . val ( ) ) ;
$ ( "#dns" ) . var ( element . dns ) ;
}
} ;
if ( ( $ ( "#dns" ) . val ( ) == '' ) && ( $ ( "#dns_default" ) . val ( ) ) ) {
} ;
$ ( "#dns" ) . val ( $ ( "#dns_default" ) . val ( ) ) ;
} ;
}
} ) ;
} ) ;
var default _ip = $ ( "#" + network _name + "_ip_default" ) . val ( ) ;
console . log ( network + ' IP not set. Setting to: [' + default _ip + ']' ) ;
$ ( "#" + network _name + "_ip" ) . val ( default _ip ) ;
} ;
} ;
} ;
} ) ;
} ) ;
//jQuery.each("bcn sn ifn".split(" "), function(index, network) {
// jQuery.each("ifn".split(" "), function(index, network) {
// //console.log('Network: ['+network+'].');
// if($("#"+network+"_count").val()) {
// var count = $("#"+network+"_count").val();
// //console.log(network+' count: ['+count+'].');
// for (var i = 1; i <= count; i++) {
// var network_name = network+i;
// var ip_set = $("#"+network_name+"_ip").val();
// console.log('i: ['+i+'], Network: ['+network_name+'], IP set: ['+ip_set+'], default: ['+$("#"+network_name+"_ip_default").val()+'].');
// if (ip_set == '') {
// console.log('Reading /status/network.json');
// $.ajax({dataType:"json",url:"/status/network.json",data:{get_param:"value"},async:false}), function(data) {
// console.log('Read for: ['+network_name+'].');
// $.each(data.ips, function(index, element) {
// var on_interface = element.on;
// console.log('on_interface: ['+on_interface+'], network_name: ['+network_name+'].');
// //console.log('- entry: ['+index+'], on: ['+element.on+'], address: ['+element.address+'], subnet: ['+element.subnet+'].');
// //console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].');
// if(on_interface.match(new RegExp(network_name))) {
// console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].');
// if (element.default_gateway == '1') {
// if ($("#gateway").val() == '') {
// $("#gateway").val(element.gateway);
// };
// if ($("#dns").val() == '') {
// $("#dns").var(element.dns);
// };
// };
// };
// });
// };
// var default_ip = $("#"+network_name+"_ip_default").val();
// console.log(network+' IP not set. Setting to: ['+default_ip+']');
// $("#"+network_name+"_ip").val(default_ip);
// };
// };
// };
// });
} )
} )