OSDN Git Service

Bug fix for network setting display
authorkeisuke fukawa <keisuke@karesansui-project.info>
Thu, 10 Jun 2010 02:43:00 +0000 (11:43 +0900)
committerkeisuke fukawa <keisuke@karesansui-project.info>
Thu, 10 Jun 2010 02:43:00 +0000 (11:43 +0900)
karesansui/templates/default/hostby1networksettings/hostby1networksettings.part
karesansui/templates/default/hostby1networksettingsgeneral/hostby1networksettingsgeneral.part
karesansui/templates/default/hostby1networksettingsnicby1/hostby1networksettingsnicby1.input
karesansui/templates/default/hostby1networksettingsnicby1/hostby1networksettingsnicby1.part

index e6413a0..229225f 100644 (file)
@@ -2,75 +2,8 @@
 <%inherit file="../include/common.part" />
 <script type="text/javascript">
 <!--
-$(document).ready(function(){
-
-
-// init
-tool_invalid("#edit_settings");
-
-$("#action>a").hover(
-    function(){tool_over(this);},
-    function(){tool_over(this);}
-).mousedown(function(){
-    var id = $(this).attr("id");
-    tool_active(this);
-});
-
-renew_main_event("#tool_renew", "${ctx.homepath}${ctx.path}");
-
-$("#device_tab td").each(function(){
-    $(this).click(function(){
-        var target = $(this).attr("id");
-
-        var target_val = target.split("_");
-
-        unbind_event();
-        switch(target_val[0]){
-            case "general":
-                ajax_get("#settings_value", 
-                 "${ctx.homepath}/host/${host_id}/networksettings/general.part",
-                 null);
-                tool_reset("#edit_settings");
-                bind_edit_event();
-                break;
-            case "nic":
-                ajax_get("#settings_value",
-                 "${ctx.homepath}/host/${host_id}/networksettings/nic/" + target_val[1] + ".part",
-                 null);
-                tool_reset("#edit_settings");
-                if(target_val[1].substr(0,3) == "eth") {
-                  bind_edit_event();
-                } else {
-                  tool_invalid("#edit_settings");
-                }
-                break;
-            default:
-                _ajax_alert_on("ERROR", "${_('Received an unexpected value.')}");
-        }
-        // icon active
-        $("#device_tab td").each(function(){
-            if($(this).attr("id") != target){
-                $(this).removeClass("device_active");
-            } else {
-                $(this).addClass("device_active");
-            }
-        });
-
-    });
-});
-
-    $("#general_tab").click();
-
-});
-// lib
 function get_target_id(){
-    var target_id = null;
-    $("#device_tab td").each(function(){
-        if($(this).hasClass("device_active") == true){
-            target_id = $(this).attr("id");
-        }
-    });
-    return target_id;
+    return $("#device_tab td.device_active").attr("id");
 }
 
 function bind_edit_event() {
@@ -79,7 +12,7 @@ function bind_edit_event() {
         var val = target_id.split("_");
         var edit_url;
 
-        if(val[1] == ""){
+        if(val[1] == "" || val[1] == undefined){
             edit_url = "${ctx.homepath}/host/${host_id}/networksettings/" + val[0] + ".part?mode=input";
         } else {
             edit_url = "${ctx.homepath}/host/${host_id}/networksettings/" + val[0] + "/" + val[1] + ".part?mode=input";
@@ -96,7 +29,57 @@ function unbind_event() {
     $("#edit_settings").unbind("click.edit");
 }
 
--->
+$(document).ready(function(){
+    $("#action>a").hover(
+        function(){tool_over(this);},
+        function(){tool_over(this);}
+    ).mousedown(function(){
+        var id = $(this).attr("id");
+        tool_active(this);
+    });
+
+    $("#device_tab td").each(function(){
+        $(this).click(function(){
+            var target = $(this).attr("id");
+            var target_val = target.split("_");
+            $("#settings_value").html('<div align="center"><img src="${ctx.homepath}/static/images/now-loading.gif" alt="Now Loading" /></div>');
+            unbind_event();
+
+            switch(target_val[0]){
+                case "general":
+                    ajax_get("#settings_value", 
+                             "${ctx.homepath}/host/${host_id}/networksettings/general.part",
+                             null,
+                             true);
+                    tool_reset("#edit_settings");
+                    bind_edit_event();
+                    break;
+                case "nic":
+                    ajax_get("#settings_value",
+                             "${ctx.homepath}/host/${host_id}/networksettings/nic/" + target_val[1] + ".part",
+                             null,
+                             true);
+                    tool_reset("#edit_settings");
+                    if(target_val[1].substr(0,3) == "eth") {
+                        bind_edit_event();
+                    } else {
+                        tool_invalid("#edit_settings");
+                    }
+                    break;
+                default:
+                    _ajax_alert_on("ERROR", "${_('Received an unexpected value.')}");
+            }
+            // icon active
+            $("#device_tab td.device_active").removeClass("device_active");
+            $(this).addClass("device_active");
+        });
+    });
+
+    tool_invalid("#edit_settings");
+    renew_main_event("#tool_renew", "${ctx.homepath}${ctx.path}");
+    $("#general_tab").click();
+});
+// -->
 </script>
                     <div id="settings_dialog"></div>
                     <div id="action">
@@ -126,33 +109,30 @@ function unbind_event() {
                     <div class="alert"></div>
                     <div id="view">
                         <div id="device">
-
-<table width="99.8%" cellspacing="1" border="0" style="background-color:#bcbcbc;">
-    <tr>
-        <td style="background-color:#E4E4DD; padding:0px; text-align:left;" bgcolor="#FFFFFF" width="20%" valign="top">
-            <table id="device_tab" width="100%" cellspacing="0" border="0" style="background-color:#e4e4dd;">
-                <tr>
-                    <td id="general_tab" style="font-size:10px;">
-                                           <img src="${ctx.homepath}/static/images/device-console.png">
-                        <span class="status">${_('General Settings')}</span>
-                    </td>
-                </tr>
+                            <table width="99.8%" cellspacing="1" border="0" style="background-color:#bcbcbc;">
+                                <tr>
+                                    <td style="background-color:#E4E4DD; padding:0px; text-align:left;" bgcolor="#FFFFFF" width="20%" valign="top">
+                                        <table id="device_tab" width="100%" cellspacing="0" border="0" style="background-color:#e4e4dd;">
+                                            <tr>
+                                                <td id="general" style="font-size:10px;">
+                                                           <img src="${ctx.homepath}/static/images/device-console.png">
+                                                    <span class="status">${_('General Settings')}</span>
+                                                </td>
+                                            </tr>
 % for dev in sorted(current.keys()):
-                <tr>
-                    <td id="nic_${dev}" style="font-size:10px;" width="100">
-                        <img src="${ctx.homepath}/static/images/device-network.png">
-                        <span class="status">${_('Device')} ${dev}</span>
-                    </td>
-                </tr>
+                                            <tr>
+                                                <td id="nic_${dev}" style="font-size:10px;" width="100">
+                                                    <img src="${ctx.homepath}/static/images/device-network.png">
+                                                    <span class="status">${_('Device')} ${dev}</span>
+                                                </td>
+                                            </tr>
 % endfor
-            </table>
-        </td>
-        <td bgcolor="#FFFFFF" valign="top" id="settings_value" width="80%" style="padding:30px;">
-        </td>
-    </tr>
-</table>
-
-
+                                        </table>
+                                    </td>
+                                    <td bgcolor="#FFFFFF" valign="top" id="settings_value" width="80%" style="padding:30px;">
+                                    </td>
+                                </tr>
+                            </table>
                         </div>
                     </div>
                     <br style="clear: both;"/>
index a646f07..be8bec6 100644 (file)
@@ -1,13 +1,5 @@
 <%doc>Copyright (C) 2009-2010 HDE, Inc.</%doc>
 <%inherit file="../include/common.part" />
-<script type="text/javascript">
-<!--
-$(document).ready(function(){
-
-
-}
--->
-</script>
 
             <table cellspacing="0" border="0" style="background-color:#bcbcbc;">
                 <tr>
index 218b95f..2612a45 100644 (file)
@@ -74,7 +74,7 @@ $(document).ready(function() {
 
 <div id="nic_setting">
     <form action="${ctx.homepath}${ctx.path}" method="post" id="nic_input_form" name="nic_input_form">
-    
+
         <div class="grayout-head">
             <span class="grayout-title">
                 <a href="#" id="nic" class="path-a"><img src="${ctx.homepath}/static/images/settings-title.gif">${_('Network Device Settings')}</a>
@@ -84,7 +84,7 @@ $(document).ready(function() {
 
         <div class="grayout-contents">
 
-            <div class="grayout-param">${_('Device')}
+            <div class="grayout-param">${_('Device')}</div>
             <div class="grayout-value grayout-form">
                 ${device| h}
             </div>
@@ -92,9 +92,9 @@ $(document).ready(function() {
             <div class="grayout-param">${_('On Boot')}<span id="network_nic_onboot_help" /></div>
             <div class="grayout-value grayout-form">
 % if onboot == "no":
-           <input type='checkbox' name='onboot'> ${_('enable')}
+                <input type='checkbox' name='onboot'> ${_('enable')}
 % else:
-           <input type='checkbox' name='onboot' checked='checked'> ${_('enable')}
+                <input type='checkbox' name='onboot' checked='checked'> ${_('enable')}
 % endif
             </div>
 
@@ -103,9 +103,9 @@ $(document).ready(function() {
                 <select name='bootproto' id="bootproto">
 % for _proto in ['static','dhcp','bootp']:
 % if bootproto == _proto:
-                <option value='${_proto}' selected='selected'>${_proto}</option>
+                    <option value='${_proto}' selected='selected'>${_proto}</option>
 % else:
-                <option value='${_proto}'>${_proto}</option>
+                    <option value='${_proto}'>${_proto}</option>
 % endif
 % endfor
                 </select>
@@ -130,6 +130,6 @@ $(document).ready(function() {
             </div>
 
             <br style="clear: both;"/>
-          </div>
-      </form>
+        </div>
+    </form>
 </div>
index ba9ba15..0f80d6d 100644 (file)
@@ -1,13 +1,5 @@
 <%doc>Copyright (C) 2009-2010 HDE, Inc.</%doc>
 <%inherit file="../include/common.part" />
-<script type="text/javascript">
-<!--
-$(document).ready(function(){
-
-
-}
--->
-</script>
 
             <table cellspacing="0" border="0" style="background-color:#bcbcbc;">
                 <tr>