diff options
author | Niklas | 2011-10-24 14:52:29 +0200 |
---|---|---|
committer | Niklas | 2011-10-24 14:52:29 +0200 |
commit | ce5d32ce282160fa152eb701afad2949fb3f2534 (patch) | |
tree | 5c49b115205891c4f8da9d8fd942ed9df07f5f3f | |
parent | added some config possibilities (diff) | |
download | fbgui-ce5d32ce282160fa152eb701afad2949fb3f2534.tar.gz fbgui-ce5d32ce282160fa152eb701afad2949fb3f2534.tar.xz fbgui-ce5d32ce282160fa152eb701afad2949fb3f2534.zip |
manual conf shows now a no interfaces found message without any form fields.
-rw-r--r-- | src/html/js/networkDiscovery.js | 131 |
1 files changed, 72 insertions, 59 deletions
diff --git a/src/html/js/networkDiscovery.js b/src/html/js/networkDiscovery.js index 1d67eac..7f065d0 100644 --- a/src/html/js/networkDiscovery.js +++ b/src/html/js/networkDiscovery.js @@ -44,73 +44,86 @@ var getInterfaceConf = function (i) { var n = i.options[i.selectedIndex].text(); }; + + var ip4_manualConfigurationDialog = function () { var jsonArr = fbgui.getManualConfInterfaces(); - //jsonArr = eval('(' + jsonArr + ')'); - var c = "<select name='nd_mc_ifname_select' id='nd_mc_ifname_select' onChange='getInterfaceConf(this)'>"; if(jsonArr == "") { - c += "<option>NO INTERFACE</option>"; + var c = "<p>Have not found usable interfaces for manual configuration</p>"; + $("#nd_manual_configuration_dialog").html(c); + $("#nd_manual_configuration_dialog").dialog( + { buttons: { "Cancel": function() { + $(this).dialog("close");}}, + minWidth: 450, + modal: true, + resizable: false, + draggable: false, + open: function(event, ui) { $(".ui-dialog-titlebar-close").hide();} + }); + } else { - jQuery.each(jsonArr, function() { + var c = "<select name='nd_mc_ifname_select' id='nd_mc_ifname_select' onChange='getInterfaceConf(this)'>"; + jQuery.each(jsonArr, function() { c += " <option>"+ this +"</option>"; - } - ); - } - c += "</select>"; - $("#nd_mc_ifname").html(c); + } + ); + + c += "</select>"; + $("#nd_mc_ifname").html(c); - var ifname = $("#nd_mc_ifname_select :selected").text(), - ipaddr = $("#ipaddr"), - netmask = $("#netmask"), - broadcast = $("#broadcast"), - gateway = $("#gateway"), - dns = $("#dns"), - allFields = $([]).add(ipaddr).add(netmask).add(broadcast).add(gateway).add(dns); + var ifname = $("#nd_mc_ifname_select :selected").text(), + ipaddr = $("#ipaddr"), + netmask = $("#netmask"), + broadcast = $("#broadcast"), + gateway = $("#gateway"), + dns = $("#dns"), + allFields = $([]).add(ipaddr).add(netmask).add(broadcast).add(gateway).add(dns); - $("#nd_manual_configuration_dialog").dialog( - { buttons: { "Cancel": function() { - $(this).dialog("close");}, - "Ok": function() { - var bValid = true; - allFields.removeClass("ui-state-error"); - - bValid = bValid && checkLength(ipaddr, "IP-Address", 7, 15); - bValid = bValid && checkLength(netmask, "Netmask Address", 7, 15); - bValid = bValid && checkLength(broadcast, "Broadcast Address", 7, 15); - bValid = bValid && checkLength(gateway, "Gateway Address", 7, 15); - bValid = bValid && checkLength(dns, "DNS Address", 7, 15); - - bValid = bValid && checkRegexp(ipaddr, /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/, "Is not a valid IP-Address! Format has to be e.g.: 192.168.1.2 (max value is 255)"); - bValid = bValid && checkRegexp(netmask, /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/, "Is not a valid IP-Address! Format has to be e.g.: 255.255.255.0 (max value is 255)"); - bValid = bValid && checkRegexp(broadcast, /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/, "Is not a valid IP-Address! Format has to be e.g.: 192.168.1.255 (max value is 255)"); - bValid = bValid && checkRegexp(gateway, /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/, "Is not a valid IP-Address! Format has to be e.g.: 192.168.1.254 (max value is 255)"); - bValid = bValid && checkRegexp(dns, /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/, "Is not a valid IP-Address! Format has to be e.g.: 192.168.1.111 (max value is 255)"); - - if (bValid) { - // put variables into a json object - // send to qt networkdiscovery - var o = {"ifname" : ifname, - "ipaddr" : ipaddr.val(), - "netmask" : netmask.val(), - "broadcast" : broadcast.val(), - "gateway" : gateway.val(), - "dns" : dns.val() } - try { - fbgui.ip4_setManualConfiguration(o); - } catch (e) { - fbgui.notifyCall(e); - } - $(this).dialog("close"); - } } - } , - minWidth: 450, - modal: true, - resizable: false, - draggable: false, - close: function() {allFields.val("").removeClass("ui-state-error");}, - open: function(event, ui) { $(".ui-dialog-titlebar-close").hide();} - }); + $("#nd_manual_configuration_dialog").dialog( + { buttons: { "Cancel": function() { + $(this).dialog("close");}, + "Ok": function() { + var bValid = true; + allFields.removeClass("ui-state-error"); + + bValid = bValid && checkLength(ipaddr, "IP-Address", 7, 15); + bValid = bValid && checkLength(netmask, "Netmask Address", 7, 15); + bValid = bValid && checkLength(broadcast, "Broadcast Address", 7, 15); + bValid = bValid && checkLength(gateway, "Gateway Address", 7, 15); + bValid = bValid && checkLength(dns, "DNS Address", 7, 15); + + bValid = bValid && checkRegexp(ipaddr, /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/, "Is not a valid IP-Address! Format has to be e.g.: 192.168.1.2 (max value is 255)"); + bValid = bValid && checkRegexp(netmask, /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/, "Is not a valid IP-Address! Format has to be e.g.: 255.255.255.0 (max value is 255)"); + bValid = bValid && checkRegexp(broadcast, /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/, "Is not a valid IP-Address! Format has to be e.g.: 192.168.1.255 (max value is 255)"); + bValid = bValid && checkRegexp(gateway, /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/, "Is not a valid IP-Address! Format has to be e.g.: 192.168.1.254 (max value is 255)"); + bValid = bValid && checkRegexp(dns, /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/, "Is not a valid IP-Address! Format has to be e.g.: 192.168.1.111 (max value is 255)"); + + if (bValid) { + // put variables into a json object + // send to qt networkdiscovery + var o = {"ifname" : ifname, + "ipaddr" : ipaddr.val(), + "netmask" : netmask.val(), + "broadcast" : broadcast.val(), + "gateway" : gateway.val(), + "dns" : dns.val() } + try { + fbgui.ip4_setManualConfiguration(o); + } catch (e) { + fbgui.notifyCall(e); + } + $(this).dialog("close"); + } } + } , + minWidth: 450, + modal: true, + resizable: false, + draggable: false, + close: function() {allFields.val("").removeClass("ui-state-error");}, + open: function(event, ui) { $(".ui-dialog-titlebar-close").hide();} + }); + } }; var abortBootDialog = function (m) { |