썸네일 다운로드 기능(+API) 추가

This commit is contained in:
joyfuI
2021-04-25 17:27:27 +09:00
parent e6a7b86670
commit 0cf53d3093
7 changed files with 180 additions and 12 deletions

View File

@@ -0,0 +1,26 @@
"use strict";
const url = document.getElementById('url');
const download_btn = document.getElementById('download_btn');
// 다운로드
download_btn.addEventListener('click', (event) => {
event.preventDefault();
if (!url.value.startsWith('http')) {
notify('URL을 입력하세요.', 'warning');
return;
}
fetch(`/${package_name}/ajax/thumbnail`, {
method: 'POST',
cache: 'no-cache',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
body: get_formdata('#download')
}).then(response => response.json()).then(() => {
notify('분석중..', 'info');
}).catch(() => {
notify('다운로드 요청 실패', 'danger');
});
});