Spaces:
Running
Running
Beracles
commited on
Commit
·
b80ece9
1
Parent(s):
320a6ee
update js
Browse files
static/watermelon/reset_game/index.html
CHANGED
|
@@ -21,7 +21,27 @@
|
|
| 21 |
<pre id="messages"></pre>
|
| 22 |
</div>
|
| 23 |
</div>
|
| 24 |
-
<script
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
</body>
|
| 26 |
|
| 27 |
</html>
|
|
|
|
| 21 |
<pre id="messages"></pre>
|
| 22 |
</div>
|
| 23 |
</div>
|
| 24 |
+
<script>
|
| 25 |
+
const url = "ws://pgsoft-ai-patcher-interface.hf.space/watermelon/ws"
|
| 26 |
+
var ws = new WebSocket(url);
|
| 27 |
+
ws.onmessage = function (event) {
|
| 28 |
+
var messages = document.getElementById('messages')
|
| 29 |
+
messages.innerText = event.data
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
function sendMessage(event) {
|
| 33 |
+
var input = document.getElementById("command")
|
| 34 |
+
|
| 35 |
+
var myobj = {
|
| 36 |
+
url: "reset_game",
|
| 37 |
+
data: {
|
| 38 |
+
command: input.value
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
ws.send(JSON.stringify(myobj))
|
| 42 |
+
event.preventDefault()
|
| 43 |
+
}
|
| 44 |
+
</script>
|
| 45 |
</body>
|
| 46 |
|
| 47 |
</html>
|
static/watermelon/reset_game/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
| 1 |
-
// reset_game
|
| 2 |
-
const url = "ws://pgsoft-ai-patcher-interface.hf.space/watermelon/ws"
|
| 3 |
-
var ws = new WebSocket(url);
|
| 4 |
-
ws.onmessage = function (event) {
|
| 5 |
-
var messages = document.getElementById('messages')
|
| 6 |
-
messages.innerText = event.data
|
| 7 |
-
};
|
| 8 |
-
function sendMessage(event) {
|
| 9 |
-
var input = document.getElementById("command")
|
| 10 |
-
|
| 11 |
-
var myobj = {
|
| 12 |
-
url: "reset_game",
|
| 13 |
-
data: {
|
| 14 |
-
command: input.value
|
| 15 |
-
}
|
| 16 |
-
}
|
| 17 |
-
ws.send(JSON.stringify(myobj))
|
| 18 |
-
event.preventDefault()
|
| 19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|