-
Notifications
You must be signed in to change notification settings - Fork 1
/
upload-gui.html
75 lines (72 loc) · 2.18 KB
/
upload-gui.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Extension Tester</title>
<style>
body {
background-color: #222;
color: #ddd;
font-family: Arial, sans-serif;
padding: 20px;
}
h2 {
color: #fff;
}
label {
color: #aaa;
}
input[type="file"], input[type="text"], button {
background-color: #333;
color: #ddd;
border: 1px solid #666;
padding: 8px;
margin-bottom: 10px;
}
input[type="file"] {
width: 100%;
}
button {
cursor: pointer;
}
#response {
margin-top: 20px;
}
a {
color: #4af;
}
</style>
</head>
<body>
<h2>Snail IDE Extension Tester</h2>
<p>Test your extensions without an http-server by using this tool.</p>
<br>
<p>Note: Files are only stored for 15 minutes, then they are deleted, but if the OpenSnail repository gets a new commit, they will immeditaly reset. Do NOT use this in projects you plan on sharing they WILL be corrupted. Only use this to test.</p>
<form id="uploadForm" enctype="multipart/form-data">
<label for="file">Choose a JavaScript file:</label><br>
<input type="file" id="file" name="extension" accept=".js"><br>
<label for="extensionName">Extension Name (before random code):</label><br>
<input type="text" id="extensionName" name="extensionName"><br><br>
<button type="submit">Upload</button>
</form>
<div id="response"></div>
<script>
document.getElementById('uploadForm').addEventListener('submit', async function(event) {
event.preventDefault();
const form = event.target;
const formData = new FormData(form);
try {
const response = await fetch('/api/upload', {
method: 'POST',
body: formData
});
const data = await response.text();
document.getElementById('response').innerHTML = `File uploaded successfully. Extension URL: <a href="${data}" target="_blank">${data}</a>`;
} catch (error) {
document.getElementById('response').textContent = `Error: ${error.message}`;
}
});
</script>
</body>
</html>