Start named servers by pressing the Enter key

This commit is contained in:
Jeremy Tuloup
2020-02-28 15:17:16 +01:00
parent cff18992ad
commit cfcd85a188

View File

@@ -50,6 +50,17 @@ require(["jquery", "moment", "jhapi", "utils"], function(
}
}
function startServer() {
var row = getRow($(this));
var serverName = row.find(".new-server-name").val();
if (serverName === "") {
// ../spawn/user/ causes a 404, ../spawn/user redirects correctly to the default server
window.location.href = "./spawn/" + user;
} else {
window.location.href = "./spawn/" + user + "/" + serverName;
}
}
function stopServer() {
var row = getRow($(this));
var serverName = row.data("server-name");
@@ -100,14 +111,10 @@ require(["jquery", "moment", "jhapi", "utils"], function(
});
});
$(".new-server-btn").click(function() {
var row = getRow($(this));
var serverName = row.find(".new-server-name").val();
if (serverName === "") {
// ../spawn/user/ causes a 404, ../spawn/user redirects correctly to the default server
window.location.href = "./spawn/" + user;
} else {
window.location.href = "./spawn/" + user + "/" + serverName;
$(".new-server-btn").click(startServer);
$(".new-server-name").on('keypress', function(e) {
if (e.which === 13) {
startServer.call(this);
}
});