曲を投稿できるようにする
This commit is contained in:
@@ -203,16 +203,18 @@ class SongSelect{
|
||||
})
|
||||
|
||||
// カスタムメニュー
|
||||
this.songs.push({
|
||||
title: "ソースコード",
|
||||
skin: this.songSkin.sourceCode,
|
||||
action: "sourceCode",
|
||||
});
|
||||
this.songs.push({
|
||||
title: "曲を投稿",
|
||||
skin: this.songSkin.upload,
|
||||
action: "upload",
|
||||
});
|
||||
// this.songs.push({
|
||||
// title: "ソースコード",
|
||||
// skin: this.songSkin.sourceCode,
|
||||
// action: "sourceCode",
|
||||
// });
|
||||
for (let i = 0; i < 10; i++) {
|
||||
this.songs.push({
|
||||
title: "曲を投稿!",
|
||||
skin: this.songSkin.upload,
|
||||
action: "upload",
|
||||
});
|
||||
}
|
||||
|
||||
this.songs.push({
|
||||
title: strings.back,
|
||||
@@ -842,8 +844,8 @@ class SongSelect{
|
||||
} else if (currentSong.action === "upload") {
|
||||
this.playSound("se_don");
|
||||
setTimeout(() => {
|
||||
open("https://upload.taikoapp.uk/","_blank");
|
||||
}, 500);
|
||||
window.location.href = "/upload/";
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
this.pointer(false)
|
||||
|
||||
27
public/upload/index.html
Normal file
27
public/upload/index.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>太鼓ウェブあっぷろーだー</title>
|
||||
<link rel="stylesheet" href="./style.css">
|
||||
<script src="./upload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>太鼓ウェブあっぷろーだー</h1>
|
||||
|
||||
<form id="upload-form" enctype="multipart/form-data">
|
||||
<label for="file_tja">TJA ファイル:</label>
|
||||
<input type="file" name="file_tja" accept=".tja" required><br>
|
||||
|
||||
<label for="file_music">音楽ファイル:</label>
|
||||
<input type="file" name="file_music" accept=".ogg,.mp3,.wav" required><br>
|
||||
|
||||
<br>
|
||||
<button type="button" onclick="uploadFiles()">今すぐ投稿! (30秒ほどかかる場合があります)</button>
|
||||
</form>
|
||||
|
||||
<br>
|
||||
<div id="error-view"></div>
|
||||
</body>
|
||||
</html>
|
||||
3
public/upload/style.css
Normal file
3
public/upload/style.css
Normal file
@@ -0,0 +1,3 @@
|
||||
#error-view {
|
||||
white-space: pre-line;
|
||||
}
|
||||
27
public/upload/upload.js
Normal file
27
public/upload/upload.js
Normal file
@@ -0,0 +1,27 @@
|
||||
function uploadFiles() {
|
||||
const form = document.getElementById('upload-form');
|
||||
const formData = new FormData(form);
|
||||
|
||||
fetch('/upload', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
.then(res => {
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
} else {
|
||||
throw new Error(res.url + " で " + res.status.toString() + " が発生しました。");
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert("おめでとう!ファイルの投稿に成功しました!");
|
||||
} else {
|
||||
throw new Error(data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('エラー:', error);
|
||||
document.getElementById("error-view").textContent = error;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user