2017-05-26 18:49:27 -04:00
|
|
|
<div id="consoleWrap">
|
2017-11-25 20:29:58 -05:00
|
|
|
<select id="serverSelection"></select>
|
|
|
|
<hr />
|
|
|
|
<div id="console">
|
|
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
<div class="playerSearchWrap table">
|
|
|
|
<input type="text" class="search tableCell" placeholder="Enter Command..." />
|
|
|
|
<input type="button" class="searchButton tableCell" name="Search" value="Execute" />
|
|
|
|
</div>
|
2017-05-26 18:49:27 -04:00
|
|
|
</div>
|
|
|
|
<script>
|
2017-11-25 20:29:58 -05:00
|
|
|
var cmdResultQueue = [];
|
|
|
|
$(document).ready(function () {
|
|
|
|
cmdResultQueue = [];
|
|
|
|
$.getJSON("/_servers", function (servers) {
|
|
|
|
$.each(servers, function (i, server) {
|
|
|
|
$('select').append("<option value=\"" + server['serverPort'] + "\">" + server['serverName'] + "</option>");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
});
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
function addCommandResult(line) {
|
|
|
|
// $.each(result, function (i, line) {
|
|
|
|
if (line == "You entered an invalid command!" || line == "All commands must start with '!'") {
|
|
|
|
line = getColorForLevel("Banned", line);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
line = getColorForLevel("Trusted", line);
|
|
|
|
}
|
|
|
|
if (cmdResultQueue.length > 12)
|
|
|
|
cmdResultQueue.shift();
|
2017-05-26 18:49:27 -04:00
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
cmdResultQueue.push(line);
|
|
|
|
// });
|
2017-05-26 18:49:27 -04:00
|
|
|
}
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
function formatCommandResults() {
|
|
|
|
$('#console').html("");
|
2017-05-26 18:49:27 -04:00
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
for (i = 0; i < cmdResultQueue.length; i++)
|
|
|
|
$('#console').append("<span class=\"commandResult\">"
|
|
|
|
+ cmdResultQueue[i] + "</span><br/>"
|
|
|
|
);
|
|
|
|
}
|
2017-05-26 18:49:27 -04:00
|
|
|
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
$('.searchButton').click(function () {
|
|
|
|
if ($('.search').val().length > 0) {
|
|
|
|
if ($('.search').val()[0] != '!') {
|
|
|
|
addCommandResult(["All commands must start with '!'"]);
|
|
|
|
formatCommandResults();
|
|
|
|
return false;
|
|
|
|
}
|
2017-05-26 18:49:27 -04:00
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
$.getJSON("/_console?command=" + $('.search').val() + "&server=" + $('select').val(), function (result) {
|
|
|
|
$.each(result, function (i, line) {
|
|
|
|
addCommandResult(line.Message)
|
|
|
|
});
|
|
|
|
}).done(function (data) { formatCommandResults(); $('.search').val(""); });
|
2017-05-26 18:49:27 -04:00
|
|
|
}
|
2017-11-25 20:29:58 -05:00
|
|
|
});
|
2017-05-26 18:49:27 -04:00
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
$(document).keypress(function (e) {
|
|
|
|
if (e.which == 13) {
|
|
|
|
$('.searchButton').click();
|
|
|
|
}
|
|
|
|
});
|
2017-05-26 18:49:27 -04:00
|
|
|
</script>
|