From a345566680c623c5b1606d3aeb9e3f076bf368e2 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 30 Oct 2017 21:13:38 -0400 Subject: [PATCH] add file input handling to filetype js --- frontend/templates/manage_ebooks.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/templates/manage_ebooks.html b/frontend/templates/manage_ebooks.html index 157cf690..d5458586 100644 --- a/frontend/templates/manage_ebooks.html +++ b/frontend/templates/manage_ebooks.html @@ -10,6 +10,7 @@ onload = function(){ var urlInput = document.getElementById('id_url'); var formatInput = document.getElementById('id_format'); + var fileInput = document.getElementById('id_file'); urlInput.oninput = function(){ if(urlInput.value.endsWith('.pdf')){ formatInput.value = 'pdf' @@ -24,6 +25,20 @@ onload = function(){ formatInput.value = 'html' }; }; + fileInput.onchange = function(){ + if(fileInput.value.endsWith('.pdf')){ + formatInput.value = 'pdf' + } + else if(fileInput.value.endsWith('.epub')){ + formatInput.value = 'epub' + } + else if(fileInput.value.endsWith('.mobi')){ + formatInput.value = 'mobi' + } + else if(fileInput.value.endsWith('.html')){ + formatInput.value = 'html' + }; + }; };