2022-04-30 18:57:23 +09:00
|
|
|
'use strict';
|
2021-04-25 17:27:27 +09:00
|
|
|
|
2022-07-24 19:48:33 +09:00
|
|
|
(() => {
|
|
|
|
|
const post_ajax = (url, data) => {
|
|
|
|
|
const loading = document.getElementById('loading');
|
|
|
|
|
if (loading) {
|
|
|
|
|
loading.style.display = 'block';
|
|
|
|
|
}
|
|
|
|
|
return fetch(`/${package_name}/ajax${url}`, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
cache: 'no-cache',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
|
|
|
},
|
|
|
|
|
body: new URLSearchParams(data),
|
|
|
|
|
})
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((ret) => {
|
|
|
|
|
if (ret.msg) {
|
|
|
|
|
notify(ret.msg, ret.ret);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
notify('요청 실패', 'danger');
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
if (loading) {
|
|
|
|
|
loading.style.display = 'none';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
2021-04-25 17:27:27 +09:00
|
|
|
|
2022-07-24 19:48:33 +09:00
|
|
|
const url = document.getElementById('url');
|
|
|
|
|
const download_btn = document.getElementById('download_btn');
|
2021-04-25 17:27:27 +09:00
|
|
|
|
2022-07-24 19:48:33 +09:00
|
|
|
// 다운로드
|
|
|
|
|
download_btn.addEventListener('click', (event) => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
if (!url.value.startsWith('http')) {
|
|
|
|
|
notify('URL을 입력하세요.', 'warning');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-06 19:25:41 +09:00
|
|
|
post_ajax('/basic/thumbnail', get_formdata('#download'));
|
2022-07-24 19:48:33 +09:00
|
|
|
});
|
|
|
|
|
})();
|