Improve switch control
diff --git a/gae_proxy/web_ui/config.html b/gae_proxy/web_ui/config.html
index 704861d5f0..6b6174c350 100644
--- a/gae_proxy/web_ui/config.html
+++ b/gae_proxy/web_ui/config.html
@@ -158,16 +158,11 @@
                 }
 
                 if ( result['host_appengine_mode'] == 'gae' ) {
-                    $('#deploy-via-gae').parent().removeClass('switch-off');
-                    $('#deploy-via-gae').parent().addClass('switch-on');
-                    $('#deploy-via-gae').prop('checked', true);
+                    $('#deploy-via-gae').bootstrapSwitch('setState', true);
                 }
 
                 if ( typeof(result['proxy_enable']) != 'undefined' && result['proxy_enable'] != 0 ) {
-                    $('#enable-proxy').parent().removeClass('switch-off');
-                    $('#enable-proxy').parent().addClass('switch-on');
-
-                    $('#enable-proxy').prop('checked', true);
+                    $('#enable-proxy').bootstrapSwitch('setState', true)
                     $('#proxy-options').slideDown();
                 }
                 $('#proxy-type').val(result['proxy_type']);
@@ -176,9 +171,7 @@
                 $('#proxy-username').val(result['proxy_user']);
                 $('#proxy-password').val(result['proxy_passwd']);
                 if ( result['use_ipv6'] == 1 ) {
-                    $('#use-ipv6').parent().removeClass('switch-off');
-                    $('#use-ipv6').parent().addClass('switch-on');
-                    $('#use-ipv6').prop('checked', true);
+                    $('#use-ipv6').bootstrapSwitch('setState', true);
                 }
             },
             error: function(){
diff --git a/gae_proxy/web_ui/deploy.html b/gae_proxy/web_ui/deploy.html
index 22de14bc23..c199112360 100644
--- a/gae_proxy/web_ui/deploy.html
+++ b/gae_proxy/web_ui/deploy.html
@@ -46,21 +46,6 @@ <h2>{{ _( "Deploy XX-Net onto GAE" ) }}</h2>
         });
     });
 </script>
-<script type="text/javascript">
-    $('label[for=advanced-options]').click(function() {
-        var isAdvancedOptionsShown = $('#advanced-options').is(':visible');
-
-        if ( !isAdvancedOptionsShown ) {
-            $('i.icon', this).removeClass('icon-chevron-right');
-            $('i.icon', this).addClass('icon-chevron-down');
-            $('#advanced-options').slideDown();
-        } else {
-            $('i.icon', this).removeClass('icon-chevron-down');
-            $('i.icon', this).addClass('icon-chevron-right');
-            $('#advanced-options').slideUp();
-        }
-    });
-</script>
 <script type="text/javascript">
     $('#log').scroll(function() {
         var preservedHeight = $('#log').height() + 10,
diff --git a/gae_proxy/web_ui/scan_setting.html b/gae_proxy/web_ui/scan_setting.html
index 2fd4c4bc98..ab238cfa23 100644
--- a/gae_proxy/web_ui/scan_setting.html
+++ b/gae_proxy/web_ui/scan_setting.html
@@ -75,10 +75,7 @@
             dataType: 'JSON',
             success: function(result) {
                 if ( result['auto_adjust_scan_ip_thread_num'] != 0 ) {
-                    $( "#auto-adjust-scan-ip-thread-num").parent().removeClass('switch-off');
-                    $( "#auto-adjust-scan-ip-thread-num").parent().addClass('switch-on');
-
-                    $( "#auto-adjust-scan-ip-thread-num").prop('checked', true);
+                    $( "#auto-adjust-scan-ip-thread-num").bootstrapSwitch('setState', true);
                 }
                 $('#scan-ip-thread-num').val(result['scan_ip_thread_num']);
             },
diff --git a/gae_proxy/web_ui/status.html b/gae_proxy/web_ui/status.html
index 2483bca35a..44f15aeaaf 100644
--- a/gae_proxy/web_ui/status.html
+++ b/gae_proxy/web_ui/status.html
@@ -544,10 +544,11 @@ <h3>{{ _( "Diagnostic Info" ) }}</h3>
             dataType: 'JSON',
             success: function(result) {
                 if ( result['show_detail'] != 0 ) {
-                    $( "#show-detail").parent().removeClass('switch-off');
-                    $( "#show-detail").parent().addClass('switch-on');
-                    $( "#show-detail").prop('checked', true);
+                    $( "#show-detail").bootstrapSwitch('setState', true);
                     $( "#details" ).slideDown();
+                } else {
+                    $( "#show-detail").bootstrapSwitch('setState', false);
+                    $( "#details" ).slideUp();
                 }
             }
         });
diff --git a/launcher/web_ui/config.html b/launcher/web_ui/config.html
index c8b7ee15c4..02b961205d 100644
--- a/launcher/web_ui/config.html
+++ b/launcher/web_ui/config.html
@@ -148,47 +148,25 @@
             dataType: 'JSON',
             success: function(result) {
                 if ( result['auto_start'] != 0 ) {
-                    $( "#auto-start").parent().removeClass('switch-off');
-                    $( "#auto-start").parent().addClass('switch-on');
-
-                    $( "#auto-start").prop('checked', true);
+                    $( "#auto-start").bootstrapSwitch('setState', true);
                 }
                 if ( result['popup_webui'] != 0 ) {
-                    $( "#popup-webui").parent().removeClass('switch-off');
-                    $( "#popup-webui").parent().addClass('switch-on');
-
-                    $( "#popup-webui").prop('checked', true);
+                    $( "#popup-webui").bootstrapSwitch('setState', true);
                 }
                 if ( result['allow_remote_connect'] != 0 ) {
-                    $( "#allow-remote-connect").parent().removeClass('switch-off');
-                    $( "#allow-remote-connect").parent().addClass('switch-on');
-
-                    $( "#allow-remote-connect").prop('checked', true);
+                    $( "#allow-remote-connect").bootstrapSwitch('setState', true);
                 }
                 if ( result['show_systray'] != 0 ) {
-                    $( "#show-systray").parent().removeClass('switch-off');
-                    $( "#show-systray").parent().addClass('switch-on');
-
-                    $( "#show-systray").prop('checked', true);
+                    $( "#show-systray").bootstrapSwitch('setState', true);
                 }
                 if ( result['gae_proxy_enable'] != 0 ) {
-                    $( "#gae_proxy-enable").parent().removeClass('switch-off');
-                    $( "#gae_proxy-enable").parent().addClass('switch-on');
-
-
-                    $( "#gae_proxy-enable").prop('checked', true);
+                    $( "#gae_proxy-enable").bootstrapSwitch('setState', true);
                 }
                 if ( result['php_enable'] != 0 ) {
-                    $( "#php-enable").parent().removeClass('switch-off');
-                    $( "#php-enable").parent().addClass('switch-on');
-
-                    $( "#php-enable").prop('checked', true);
+                    $( "#php-enable").bootstrapSwitch('setState', true);
                 }
                 if ( result['x_tunnel_enable'] != 0 ) {
-                    $( "#x-tunnel-enable").parent().removeClass('switch-off');
-                    $( "#x-tunnel-enable").parent().addClass('switch-on');
-
-                    $( "#x-tunnel-enable").prop('checked', true);
+                    $( "#x-tunnel-enable").bootstrapSwitch('setState', true);
                 }
                 $( "#language").val(result['language']);
                 $( "#check-update").val(result['check_update']);
diff --git a/php_proxy/web_ui/config.html b/php_proxy/web_ui/config.html
index 6fb34ad0f5..bde5d2103c 100644
--- a/php_proxy/web_ui/config.html
+++ b/php_proxy/web_ui/config.html
@@ -98,10 +98,7 @@
                 $('#php-password').val(result['php_password']);
 
                 if ( typeof(result['proxy_enable']) != 'undefined' && result['proxy_enable'] != 0 ) {
-                    $('#enable-front-proxy').parent().removeClass('switch-off');
-                    $('#enable-front-proxy').parent().addClass('switch-on');
-
-                    $('#enable-front-proxy').prop('checked', true);
+                    $('#enable-front-proxy').bootstrapSwitch('setState', true);
                     $('#front-proxy-options').slideDown();
                 }
                 $('#proxy-host').val(result['proxy_host']);
