aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2020-04-25 19:40:56 +0300
committerBonfaceKilz2020-04-26 07:05:12 +0300
commitd3d16604a4d78442baffa47aca9a6a5ee49a5ed0 (patch)
tree33abf9f69076859863a6fe61d812e8a41ba5a189
parentdf08a8f191371a5cb0ca30e809809c85fcf62d94 (diff)
downloadbh20-seq-resource-d3d16604a4d78442baffa47aca9a6a5ee49a5ed0.tar.gz
bh20-seq-resource-d3d16604a4d78442baffa47aca9a6a5ee49a5ed0.tar.lz
bh20-seq-resource-d3d16604a4d78442baffa47aca9a6a5ee49a5ed0.zip
Put JS code in its own JS file
-rw-r--r--bh20simplewebuploader/static/main.js37
-rw-r--r--bh20simplewebuploader/templates/form.html39
2 files changed, 39 insertions, 37 deletions
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
new file mode 100644
index 0000000..ab810cd
--- /dev/null
+++ b/bh20simplewebuploader/static/main.js
@@ -0,0 +1,37 @@
+let r = new XMLHttpRequest();
+let test;
+r.open("GET", scriptRoot + "/api/getAllaccessions", true);
+r.onreadystatechange = function () {
+ if (r.readyState != 4 || r.status != 200) return;
+ test = r.responseText;
+ console.log(JSON.parse(test));
+};
+r.send();
+let uploadForm = document.getElementById('metadata_upload_form')
+let uploadFormSpot = document.getElementById('metadata_upload_form_spot')
+let fillForm = document.getElementById('metadata_fill_form')
+let fillFormSpot = document.getElementById('metadata_fill_form_spot')
+
+function setUploadMode() {
+ // Make the upload form the one in use
+ uploadFormSpot.appendChild(uploadForm)
+ fillFormSpot.removeChild(fillForm)
+}
+
+function setFillMode() {
+ // Make the fillable form the one in use
+ uploadFormSpot.removeChild(uploadForm)
+ fillFormSpot.appendChild(fillForm)
+}
+
+function setMode() {
+ // Pick mode based on radio
+ if (document.getElementById('metadata_upload').checked) {
+ setUploadMode()
+ } else {
+ setFillMode()
+ }
+}
+
+// Start in mode appropriate to selected form item
+setMode()
diff --git a/bh20simplewebuploader/templates/form.html b/bh20simplewebuploader/templates/form.html
index 9c272a0..7b1fd98 100644
--- a/bh20simplewebuploader/templates/form.html
+++ b/bh20simplewebuploader/templates/form.html
@@ -151,43 +151,8 @@
<script type="text/javascript">
let scriptRoot = {{ request.script_root|tojson|safe }};
- let r = new XMLHttpRequest();
- let test;
- r.open("GET", scriptRoot + "/api/getAllaccessions", true);
- r.onreadystatechange = function () {
- if (r.readyState != 4 || r.status != 200) return;
- test = r.responseText;
- console.log(JSON.parse(test));
- };
- r.send();
- let uploadForm = document.getElementById('metadata_upload_form')
- let uploadFormSpot = document.getElementById('metadata_upload_form_spot')
- let fillForm = document.getElementById('metadata_fill_form')
- let fillFormSpot = document.getElementById('metadata_fill_form_spot')
-
- function setUploadMode() {
- // Make the upload form the one in use
- uploadFormSpot.appendChild(uploadForm)
- fillFormSpot.removeChild(fillForm)
- }
-
- function setFillMode() {
- // Make the fillable form the one in use
- uploadFormSpot.removeChild(uploadForm)
- fillFormSpot.appendChild(fillForm)
- }
-
- function setMode() {
- // Pick mode based on radio
- if (document.getElementById('metadata_upload').checked) {
- setUploadMode()
- } else {
- setFillMode()
- }
- }
-
- // Start in mode appropriate to selected form item
- setMode()
</script>
+
+<script type="text/javascript" src="/static/main.js"></script>
</body>
</html>