make 'mac' field on an interface editable.
authorStephen Soltesz <soltesz@cs.princeton.edu>
Wed, 24 Jun 2009 19:04:14 +0000 (19:04 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Wed, 24 Jun 2009 19:04:14 +0000 (19:04 +0000)
planetlab/nodes/interface.js
planetlab/nodes/interface.php

index e97487f..434333e 100644 (file)
@@ -104,6 +104,25 @@ function networkHelper () {
   $('broadcast').value=derived[1];
 }
 
+function macChecker(id, optional) {
+  var error= macCheckerSilent($(id).value);
+  if (error) {
+    Form.Element.focus($(id));
+    alert(error);
+  }
+}
+
+function macCheckerSilent(macAdd) {
+       var RegExPattern = /^[0-9a-fA-F:]+$/;
+       if (!(macAdd.match(RegExPattern)) || macAdd.length != 17) 
+       {
+               return "Invalid MAC Address";
+       } else {
+               return "";
+       }
+}
+
 /* check one */
 function subnetChecker (id, optional) {
   var error= subnetCheckerSilent([id,optional]);
index 6f7e922..5a8af9b 100644 (file)
@@ -111,9 +111,11 @@ $details->th_td("DNS 2",$interface['dns2'],"dns2",array('width'=>15,
 $details->space();
 $details->th_td("BW limit (bps)",$interface['bwlimit'],"bwlimit",array('width'=>11));
 $details->th_td("Hostname",$interface['hostname'],"hostname");
+$details->th_td("Mac address",$interface['mac'],"mac", array('onChange'=>'macChecker("mac", true)'));
+
 # xxx should the user be allowed to change this ?
-$mac=$interface['mac'];
-if ($mac) $details->th_td("MAC address",$mac);
+//$mac=$interface['mac'];
+//if ($mac) $details->th_td("MAC address",$mac);
 
 // the buttons
 $update_button = $form->submit_html ("update-interface","Update",