Move sql_edit javascript into its own file
authorKarl O. Pinc <kop@karlpinc.com>
Thu, 26 Sep 2024 20:14:34 +0000 (15:14 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Thu, 26 Sep 2024 20:14:34 +0000 (15:14 -0500)
src/pgwui_sql/static/sql_edit.js [new file with mode: 0644]
src/pgwui_sql/templates/sql_edit.mak

diff --git a/src/pgwui_sql/static/sql_edit.js b/src/pgwui_sql/static/sql_edit.js
new file mode 100644 (file)
index 0000000..7bb0eab
--- /dev/null
@@ -0,0 +1,47 @@
+/* Copyright (C) 2024 The Meme Factory, Inc.  http://www.karlpinc.com/
+     This file is part of PGWUI_SQL.
+    
+     This program is free software: you can redistribute it and/or
+     modify it under the terms of the GNU Affero General Public License
+     as published by the Free Software Foundation, either version 3 of
+     the License, or (at your option) any later version.
+    
+     This program is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public
+     License along with this program.  If not, see
+     <http://www.gnu.org/licenses/>.
+
+  Javascript for the sql edit window.
+  Karl O. Pinc <kop@karlpinc.com>
+*/
+
+function show_search_path() {
+  fetch('${request.route_path("pgwui_sql_db_search_path")|n}')
+    .then((response) => {
+          if (!response.ok) {
+            window.alert('Problem obtaining the search_path');
+          }
+          return response.text();
+          })
+    .then((search_path) => {
+          const sp_elemt = document.getElementById('search_path_id');
+          sp_elemt.value = search_path;
+          })
+    .catch((error) => {
+        window.alert('Problem showing the search_path: ' + error);
+        })
+};
+function toggle_sql_used(elem) {
+  sql_text = document.getElementById('sql_id');
+  if (elem.checked) {
+    sql_text.style.backgroundColor = '#ececec';
+  } else {
+    sql_text.style.backgroundColor = '';
+  }
+};
index e60c3a1ae892408152ce84c2b0525f12e6f0803d..213e4736c4be7407f73d729d1e7035363323dfe2 100644 (file)
 <%block name="top_hr">
 </%block>
 
-<script>
-  function show_search_path() {
-    fetch('${request.route_path("pgwui_sql_db_search_path")|n}')
-      .then((response) => {
-            if (!response.ok) {
-              window.alert('Problem obtaining the search_path');
-            }
-            return response.text();
-            })
-      .then((search_path) => {
-            const sp_elemt = document.getElementById('search_path_id');
-            sp_elemt.value = search_path;
-            })
-      .catch((error) => {
-          window.alert('Problem showing the search_path: ' + error);
-          })
-  };
-  function toggle_sql_used(elem) {
-    sql_text = document.getElementById('sql_id');
-    if (elem.checked) {
-      sql_text.style.backgroundColor = '#ececec';
-    } else {
-      sql_text.style.backgroundColor = '';
-    }
-  };
-</script>
-
 <%def name="sql_row(tab_index)">
       <tr>
         <%self.lib:td_label for_id="search_path_id">
 % else:
     <p>Not logged in.  Close this window and re-open it after logging in.</p>
 % endif
+
+<script defer
+        src="${request.static_url('pgwui_sql:static/sql_edit.js')}">
+</script>