aboutsummaryrefslogtreecommitdiffstats
path: root/src/public/js
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2022-02-11 00:11:52 -0600
committerMatt Strapp <matt@mattstrapp.net>2022-02-11 00:11:52 -0600
commit0fbc317e926b5d80363979ee51a4e3c930014efd (patch)
treebfd8ce0fc829d80a46a2182b759057c25e4894fa /src/public/js
parentGet rid of express-session and use a cookie instead (diff)
downloadee4511w-web-0fbc317e926b5d80363979ee51a4e3c930014efd.tar
ee4511w-web-0fbc317e926b5d80363979ee51a4e3c930014efd.tar.gz
ee4511w-web-0fbc317e926b5d80363979ee51a4e3c930014efd.tar.bz2
ee4511w-web-0fbc317e926b5d80363979ee51a4e3c930014efd.tar.lz
ee4511w-web-0fbc317e926b5d80363979ee51a4e3c930014efd.tar.xz
ee4511w-web-0fbc317e926b5d80363979ee51a4e3c930014efd.tar.zst
ee4511w-web-0fbc317e926b5d80363979ee51a4e3c930014efd.zip
Do a bunch of random things (still no feature parity)
sadge Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to 'src/public/js')
-rw-r--r--src/public/js/form.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/public/js/form.js b/src/public/js/form.js
new file mode 100644
index 0000000..cfa80fd
--- /dev/null
+++ b/src/public/js/form.js
@@ -0,0 +1,17 @@
+document.getElementById('upload').onsubmit = function () {
+ var data = new FormData(document.getElementById('upload'));
+ var xhr = new XMLHttpRequest();
+ xhr.open('POST', '/api/upload');
+ xhr.send(data);
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState == 4 && xhr.status == 200) {
+ var response = JSON.parse(xhr.responseText);
+ if (response.success) {
+ document.getElementById('success').style.display = 'block';
+ } else {
+ document.getElementById('error').style.display = 'block';
+ }
+ }
+ };
+ return false;
+};