From 15f84de05b88e1f8ce90704419e411aed1a22053 Mon Sep 17 00:00:00 2001
From: kevin <nanhantianyi@126.com>
Date: Mon, 8 Jan 2024 22:36:22 +0800
Subject: [PATCH] fix js error

---
 templates/base.html    | 36 ++----------------------------------
 templates/clients.html | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/templates/base.html b/templates/base.html
index ef16c93..0c2b9ee 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -58,13 +58,13 @@
                 </div>
                 <div class="form-group form-group-sm">
                     <select name="status-selector" id="status-selector" class="custom-select form-control-navbar" style="margin-left: 0.5em; height: 90%; font-size: 14px;">
-                        <!-- THIS SECTION IS OVERRIDDEN BY JS. SEE updateSearchList() function BEFORE EDITING -->
+                        <!-- THIS SECTION IS OVERRIDDEN BY JS. SEE updateSearchList() function in clients.html BEFORE EDITING -->
                         <option value="All">All</option>
                         <option value="Enabled">Enabled</option>
                         <option value="Disabled">Disabled</option>
                         <option value="Connected">Connected</option>
                         <option value="Disconnected">Disconnected</option>
-                        <!-- THIS SECTION IS OVERRIDDEN BY JS. SEE updateSearchList() function BEFORE EDITING -->
+                        <!-- THIS SECTION IS OVERRIDDEN BY JS. SEE updateSearchList() function in clients.html BEFORE EDITING -->
                     </select>
                 </div>
             </form>
@@ -397,8 +397,6 @@
 
             updateApplyConfigVisibility()
 
-            updateSearchList()
-
         });
 
         function addGlobalStyle(css, id) {
@@ -435,36 +433,6 @@
                     }
                 });
         }
-
-        function updateSearchList() {
-            $.getJSON("{{.basePath}}/api/subnet-ranges", null, function(data) {
-                $("#status-selector option").remove();
-                $("#status-selector").append(
-                    $("<option></option>")
-                        .text("All")
-                        .val("All"),
-                    $("<option></option>")
-                        .text("Enabled")
-                        .val("Enabled"),
-                    $("<option></option>")
-                        .text("Disabled")
-                        .val("Disabled"),
-                    $("<option></option>")
-                        .text("Connected")
-                        .val("Connected"),
-                    $("<option></option>")
-                        .text("Disconnected")
-                        .val("Disconnected")
-                );
-                $.each(data, function(index, item) {
-                    $("#status-selector").append(
-                        $("<option></option>")
-                            .text(item)
-                            .val(item)
-                    );
-                });
-            });
-        }
         
         // populateClient function for render new client info
         // on the client page.
diff --git a/templates/clients.html b/templates/clients.html
index 54587a7..8c24d4e 100644
--- a/templates/clients.html
+++ b/templates/clients.html
@@ -362,10 +362,41 @@ Wireguard Clients
                 });
             });
         }
+
+        function updateSearchList() {
+            $.getJSON("{{.basePath}}/api/subnet-ranges", null, function(data) {
+                $("#status-selector option").remove();
+                $("#status-selector").append(
+                    $("<option></option>")
+                        .text("All")
+                        .val("All"),
+                    $("<option></option>")
+                        .text("Enabled")
+                        .val("Enabled"),
+                    $("<option></option>")
+                        .text("Disabled")
+                        .val("Disabled"),
+                    $("<option></option>")
+                        .text("Connected")
+                        .val("Connected"),
+                    $("<option></option>")
+                        .text("Disconnected")
+                        .val("Disconnected")
+                );
+                $.each(data, function(index, item) {
+                    $("#status-selector").append(
+                        $("<option></option>")
+                            .text(item)
+                            .val(item)
+                    );
+                });
+            });
+        }
     </script>
     <script>
         // load client list
         $(document).ready(function () {
+            updateSearchList();
             populateClientList();
         })