import (
"encoding/json"
+ "fmt"
"io"
"net/http"
"os"
defer file.Close()
resp, err := http.Get(url)
- if resp.Status != "200 OK" {
+ if (err != nil) || (resp.Status != "200 OK") {
+ fmt.Println("Error", err)
w.WriteHeader(http.StatusNotFound)
return
}
display: flex;
}
+.success {
+ background-color: rgb(106, 230, 130);
+}
+
#editMenu {
top: 10vh;
left: 25vw;
}
#editMenuUpdateButton {
- .success {
- background-color: rgb(106, 230, 130);
- }
}
}
+#songCreationMenu {
+ top: 10vh;
+ left: 25vw;
+ border-radius: 5px;
+ position: absolute;
+ border: 2px solid gray;
+ background-color: rgb(240, 240, 240);
+ width: 50vw;
+ display: none;
+}
</div>
<div>
- <button>Create New Song</button> <!-- TODO -->
- <button>Upload Song File</button> <!-- TODO -->
+ <button onclick="openCreationMenu()">Create New Song</button> <!-- TODO -->
</div>
<div id="innerSongList">
</div>
</div>
</body>
+ <div id="songCreationMenu">
+ <h1>Song Creation Menu</h1>
+ <hr>
+ <h2>Create a New Song</h2>
+
+ <hr>
+ <h2>Upload a New File with a Link (no YT Links)</h2>
+ <input id="fileUploadLinkLink">Link Here</input><br>
+ <input id="fileUploadLinkName">Name of File Here</input>
+ <button id="fileUploadLinkUploadButton" onclick="uploadFileWithLinkAndName()">Upload!</button>
+ <hr>
+ <h2>Upload a New File </h2>
+
+ <hr>
+ <button onclick="closeCreationMenu()" id="editMenuCloseButton">Close</button>
+ </div>
+
<div id="editMenu">
<div id="innerEditMenu">
}
}
+/**
+ * SONG CREATION MENU
+ **/
+let songCreationMenu = document.getElementById("songCreationMenu")
+
+function closeCreationMenu() {
+ songCreationMenu.style.display = "none"
+}
+
+function openCreationMenu() {
+ songCreationMenu.style.display = "block"
+}
+
+let fileUploadLinkLink = document.getElementById("fileUploadLinkLink")
+let fileUploadLinkName = document.getElementById("fileUploadLinkName")
+let fileUploadLinkUploadButton = document.getElementById("fileUploadLinkUploadButton")
+
+async function uploadFileWithLinkAndName() {
+
+ let link = fileUploadLinkLink.value
+ let name = fileUploadLinkName.value // TODO: again do some checking here
+
+ let response = await fetch("/api/files/createWithURL/" + name, {
+ method: "POST",
+ body: JSON.stringify(link)
+ })
+
+ if (response.status != 200) {
+ alert("Something went wrong uploading the file... harass admin")
+ }
+ else {
+ fileUploadLinkUploadButton.classList = "success"
+
+ await sleep(500)
+
+ fileUploadLinkUploadButton.classList = ""
+ }
+}
+
/**
* SETUP / RUN AT START SECTION
**/