-
Notifications
You must be signed in to change notification settings - Fork 3
/
console.html
79 lines (73 loc) · 2.17 KB
/
console.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
76
77
78
79
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="src/css/console.css">
</head>
<body>
<img id="overlay" src="src/images/consoleOverlay.png">
<div id="container">
<input type="text" class="matField" id="command" onkeypress="return runScript(event)" placeholder="Chat/Command" autocomplete="off">
<button class="send" class="buttonMaterial" onclick="sendMessage()">Send</button>
<button class="restart" class="buttonMaterial" onclick="restartBot()">Restart</button>
<button class="goHome" class="buttonMaterial" onclick="gotoIndex()">Back</button>
</div>
<div id="Space"></div>
<h1 class="spacer">SPACED AREA</h1>
</body>
<script>
var mineflayer = require('mineflayer');
var requireIndex = require('requireindex');
var gui = require('nw.gui');
var win = gui.Window.get();
//Send Command
function sendMessage() {
console.log("message sent");
var sendString = document.getElementById("command").value
document.getElementById('command').value = ""
if (sendString != "") {
if (sendString.startsWith("^")) {
var newSendString = sendString.substring(1);
fakeConsole("You sent the C-B command: " + newSendString,"info")
bot.whisper(bot.username, newSendString)
} else {
fakeConsole("You sent: " + sendString,"info")
bot.chat(sendString)
}
}
}
function runScript(e) {
if (e.keyCode == 13) {
sendMessage()
}
}
function restartBot() {
bot.quit()
console.log("restarted");
setTimeout(location.reload(),500)
}
function gotoIndex() {
bot.quit()
console.log("went back to index");
window.location.replace("index.html");
}
//Fake Log
function fakeConsole(text,type) {
var text = arguments[0]
var type = arguments[1]
var para = document.createElement("P");
var t = document.createTextNode(text);
para.className = type;
para.appendChild(t);
document.getElementById('Space').appendChild(para);
window.scrollTo(0,document.body.scrollHeight);
}
win.on('close', function () {
//win.hide()
if (fs.existsSync("./src/userdata/" + window.name)) {
fs.unlink("./src/userdata/" + window.name)
}
win.close(true);
});
</script>
<script src="src/scripts/botcore.js"></script>
</html>