about summary refs log tree commit diff
path: root/uploader
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-04-28 12:00:35 -0500
committerFrederick Muriuki Muriithi2025-04-28 12:23:22 -0500
commit1695e07c1de3ed806311b3ebc9ed93f8c8833458 (patch)
treec769f9773a28469b6a368c637dad430eb675dac0 /uploader
parentbe8bd24a8a24e75ac00a362c022836378d9b3c38 (diff)
downloadgn-uploader-1695e07c1de3ed806311b3ebc9ed93f8c8833458.tar.gz
Move generic utility functions to the utils.js file.
Diffstat (limited to 'uploader')
-rw-r--r--uploader/static/js/misc.js6
-rw-r--r--uploader/static/js/utils.js27
-rw-r--r--uploader/templates/base.html2
-rw-r--r--uploader/templates/phenotypes/add-phenotypes-base.html19
4 files changed, 28 insertions, 26 deletions
diff --git a/uploader/static/js/misc.js b/uploader/static/js/misc.js
deleted file mode 100644
index cf7b39e..0000000
--- a/uploader/static/js/misc.js
+++ /dev/null
@@ -1,6 +0,0 @@
-"Miscellaneous functions and event-handlers"
-
-$(".not-implemented").click((event) => {
-    event.preventDefault();
-    alert("This feature is not implemented yet. Please bear with us.");
-});
diff --git a/uploader/static/js/utils.js b/uploader/static/js/utils.js
index 045dd47..1b31661 100644
--- a/uploader/static/js/utils.js
+++ b/uploader/static/js/utils.js
@@ -8,3 +8,30 @@ function trigger_change_event(element) {
     evt = new Event("change");
     element.dispatchEvent(evt);
 }
+
+
+var remove_class = (element, classvalue) => {
+    new_classes = (element.attr("class") || "").split(" ").map((val) => {
+        return val.trim();
+    }).filter((val) => {
+        return ((val !== classvalue) &&
+                (val !== ""))
+    }).join(" ");
+
+    if(new_classes === "") {
+        element.removeAttr("class");
+    } else {
+        element.attr("class", new_classes);
+    }
+};
+
+
+var add_class = (element, classvalue) => {
+    remove_class(element, classvalue);
+    element.attr("class", (element.attr("class") || "") + " " + classvalue);
+};
+
+$(".not-implemented").click((event) => {
+    event.preventDefault();
+    alert("This feature is not implemented yet. Please bear with us.");
+});
diff --git a/uploader/templates/base.html b/uploader/templates/base.html
index 570989a..3c0d0d4 100644
--- a/uploader/templates/base.html
+++ b/uploader/templates/base.html
@@ -154,7 +154,7 @@
     <!--
         local dependencies
       -->
-    <script type="text/javascript" src="/static/js/misc.js"></script>
+    <script type="text/javascript" src="/static/js/utils.js"></script>
     <script type="text/javascript" src="/static/js/datatables.js"></script>
     {%block javascript%}{%endblock%}
   </body>
diff --git a/uploader/templates/phenotypes/add-phenotypes-base.html b/uploader/templates/phenotypes/add-phenotypes-base.html
index a2d9484..6be9cb0 100644
--- a/uploader/templates/phenotypes/add-phenotypes-base.html
+++ b/uploader/templates/phenotypes/add-phenotypes-base.html
@@ -165,25 +165,6 @@
 
 {%block javascript%}
 <script type="text/javascript">
-  var remove_class = (element, classvalue) => {
-      new_classes = (element.attr("class") || "").split(" ").map((val) => {
-          return val.trim();
-      }).filter((val) => {
-          return ((val !== classvalue) &&
-                  (val !== ""))
-      }).join(" ");
-
-      if(new_classes === "") {
-          element.removeAttr("class");
-      } else {
-          element.attr("class", new_classes);
-      }
-  };
-
-  var add_class = (element, classvalue) => {
-      remove_class(element, classvalue);
-      element.attr("class", (element.attr("class") || "") + " " + classvalue);
-  };
 
   $("#chk-published").on("click", (event) => {
       pub_details = $("#fldset-publication-info")