add file input handling to filetype js

pull/43/head^2
eric 2017-10-30 21:13:38 -04:00
parent d04ebbb694
commit a345566680
1 changed files with 15 additions and 0 deletions

View File

@ -10,6 +10,7 @@
onload = function(){ onload = function(){
var urlInput = document.getElementById('id_url'); var urlInput = document.getElementById('id_url');
var formatInput = document.getElementById('id_format'); var formatInput = document.getElementById('id_format');
var fileInput = document.getElementById('id_file');
urlInput.oninput = function(){ urlInput.oninput = function(){
if(urlInput.value.endsWith('.pdf')){ if(urlInput.value.endsWith('.pdf')){
formatInput.value = 'pdf' formatInput.value = 'pdf'
@ -24,6 +25,20 @@ onload = function(){
formatInput.value = 'html' 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'
};
};
}; };
</script> </script>