From aa867b4c0b7a19ce36890efbfdae477cd9a3bffd Mon Sep 17 00:00:00 2001 From: tobiichi3227 <86729076+tobiichi3227@users.noreply.github.com> Date: Tue, 21 May 2024 23:04:17 +0800 Subject: [PATCH] feat: auto detect upload file extension for packtype (#61) --- src/static/templ/manage/pro/update.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/static/templ/manage/pro/update.html b/src/static/templ/manage/pro/update.html index cae69cff..90b0945b 100644 --- a/src/static/templ/manage/pro/update.html +++ b/src/static/templ/manage/pro/update.html @@ -39,6 +39,19 @@ }); }); + j_form.find('input.file').on('change', function(e) { + let pack_type_select = j_form.find('select.packtype'); + let filename = $(this)[0].files[0].name; + + if (filename.endsWith(".tar.xz")) { + pack_type_select.val('1'); + } else if (filename.endsWith(".html")) { + pack_type_select.val('2'); + } else if (filename.endsWith(".pdf")) { + pack_type_select.val('3'); + } + }); + j_form.find('button.submit').on('click', function(e) { var name = j_form.find('input.name').val(); var tags = j_form.find('input.tags').val();