Commit 99cd9220 authored by nanahira's avatar nanahira

add English dashboard

parent 3323d0b9
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SRVPro Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/style.css" rel="stylesheet">
</head>
<body>
<header class="container">
<h1 class="title">SRVPro Dashboard</h1>
</header>
<div class="container">
<div class="row grid">
<div class="col-lg-1">
<input type="text" class="form-control" id="http" value="http" placeholder="http">
</div>
<div class="col-lg-3">
<input type="text" class="form-control" id="ip" value="" placeholder="IP">
</div>
<div class="col-lg-1">
<input type="text" class="form-control" id="port" value="" placeholder="port">
</div>
<div class="col-lg-3">
<input type="password" class="form-control" id="password" value="" placeholder="password">
</div>
<div class="col-lg-4">
<button class="btn btn-default" id="open_button">Refresh</button>
<button class="btn btn-default" id="auto_button">Auto Refresh</button>
<span id="num">0</span> Rooms in total
</div>
</div>
<div class="row buttons">
<div class="col-lg-12">
<input type="text" class="form-control" id="shout" value="" placeholder="Shout">
</div>
</div>
<div class="row buttons">
<div class="col-lg-12">
<button class="btn btn-default" id="shout_button" data-toggle="tooltip" title="Send public messages to the server.">Shout</button>
<button class="btn btn-default" id="stop_button" data-toggle="tooltip" title="Forbid creating new rooms, but will not affect the current rooms.">Stop Server</button>
<button class="btn btn-default" id="welcome_button" data-toggle="tooltip" title="Edit welcome Message.">Welcome</button>
<button class="btn btn-default" id="tips_button" data-toggle="tooltip" title="Refresh hints.">Hint</button>
<button class="btn btn-default" id="dialogues_button" data-toggle="tooltip" title="Refresh dialogues.">Dialogue</button>
<button class="btn btn-default" id="ban_button" data-toggle="tooltip" title="Ban player">Ban</button>
<button class="btn btn-default" id="kick_button" data-toggle="tooltip" title="Terminate a room. Input the room ID for a specific room, or 'all' for all rooms.">Terminate</button>
<button class="btn btn-default" id="death_button" data-toggle="tooltip" title="Start Extra Duel. Input the room ID for a specific room, or leave blank for all rooms.">Extra Duel</button>
<button class="btn btn-default" id="deathcancel_button" data-toggle="tooltip" title="Cancel Extra Duel. Input the room ID for a specific room, or leave blank for all rooms.">Cancel Extra Duel</button>
<span id="message_callback"></span>
</div>
</div>
</div>
<div class="container">
<hr>
<div class="row">
<div class="col-lg-12">
<table class="table table-striped" id="rooms">
<thead>
<th width="5%">ID</th>
<th width="10%">Name</th>
<th width="35%">Player 1</th>
<th width="35%">Player 2</th>
<th width="15%">Status</th>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@2.2.4/dist//jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script src="/dashboard-script.js"></script>
<script src="http://s4.cnzz.com/z_stat.php?id=1255875151&web_id=1255875151"></script>
</body>
</html>
$(function(){
$("body").tooltip({selector: "[data-toggle='tooltip']", trigger: "hover"});
$("#open_button").click(loadrooms);
$("#auto_button").click(autoload);
$("#shout_button").click(shout);
$("#stop_button").click(stop);
$("#welcome_button").click(welcome);
$("#tips_button").click(load_tips);
$("#dialogues_button").click(load_dialogues);
$("#ban_button").click(ban_player);
$("#kick_button").click(kick_room);
$("#death_button").click(start_death);
$("#deathcancel_button").click(cancel_death);
var params=parseQueryString();
$("#ip").val(params["ip"]);
$("#port").val(params["port"]);
$("#password").val(params["password"]);
});
function parseQueryString() {
//http://stackoverflow.com/questions/523266/how-can-i-get-a-specific-parameter-from-location-search
var str = window.location.search;
var objURL = {};
str.replace(
new RegExp( "([^?=&]+)(=([^&]*))?", "g" ),
function( $0, $1, $2, $3 ){
objURL[ $1 ] = $3;
}
);
return objURL;
}
function loadrooms() {
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/getrooms?callback=?"+ ($("#password").val() ? "&pass="+$("#password").val() : "");
$.getJSON(url, listroom);
$("#open_button").removeClass("btn-success");
}
function autoload() {
if (window.autoLoad) {
window.clearInterval(window.autoLoad);
window.autoLoad=false;
$("#message_callback").text("关闭自动刷新");
}
else {
if (!$("#password").val()) {
alert("请输入密码");
return;
}
window.autoLoad=window.setInterval(loadrooms,1000);
}
}
function playerinfo(player, mode) {
if (!player)
return "";
var info = player.name;
if (player.status) {
var status = "";
if (mode == 1)
status = status + "得分: " + player.status.score + " " ;
if (mode != 2 || player.pos % 2 == 0)
status = status + "LP: "+ player.status.lp;
if (mode != 2)
status = status + " 卡数: "+ player.status.cards;
if (status != "")
info = info + " <em>(" + status + ")</em>";
}
if (player.ip)
info = info +"<br><code>IP: " + player.ip + "</code>";
return info;
}
function listroom(data) {
$("#open_button").addClass("btn-success");
$("#num").text(data.rooms.length);
var tbody=$("<tbody></tbody>");
for (i in data.rooms) {
var room=data.rooms[i];
var tr=$("<tr></tr>");
room.duelers=[];
room.watchers=[];
for (j in room.users) {
if (room.users[j].pos==7) {
room.watchers.push(room.users[j]);
}
else {
room.duelers.push(room.users[j]);
}
}
tr.append($("<td>"+room.roomid+"</td>"));
tr.append($("<td>"+ ((room.needpass == "true") ? "<span class='glyphicon glyphicon-lock'></span>" : "") + room.roomname+ "</td>"));
if (room.roommode != 2) {
tr.append($("<td>"+playerinfo(room.duelers[0], room.roommode)+"</td>"));
tr.append($("<td>"+playerinfo(room.duelers[1], room.roommode)+"</td>"));
}
else {
tr.append($("<td>"+playerinfo(room.duelers[0], 2)+"<br>"+playerinfo(room.duelers[1], 2)+"</td>"));
tr.append($("<td>"+playerinfo(room.duelers[2], 2)+"<br>"+playerinfo(room.duelers[3], 2)+"</td>"));
}
var watchlist="";
if (room.watchers.length) {
for (j in room.watchers) {
watchlist+=room.watchers[j].name+"\r\n";
}
}
tr.append($("<td>"+ (watchlist ? "<span class='glyphicon glyphicon-eye-open' data-toggle='tooltip' title='" + watchlist + "'></span>" : "") + room.istart +"</td>"));
tbody.append(tr);
}
$("#rooms tbody").remove();
$("#rooms").append(tbody);
}
function shout() {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?shout=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
function stop() {
if (confirm("Are you sure to stop the server?")) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?stop=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
function welcome() {
if ($("#shout").val().length) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?welcome=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
else {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?getwelcome=1&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
function load_tips() {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?loadtips=1&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
function load_dialogues() {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?loaddialogues=1&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
function ban_player() {
if (confirm("Are you sure to ban this player?")) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?ban=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
function kick_room() {
if (confirm("Are you sure to terminate this duel?")) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?kick=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
function start_death() {
if (confirm("Are you sure to start Extra Duel?")) {
if ($("#shout").val().length) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?death=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
else {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?death=all&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
}
function cancel_death() {
if (confirm("Are you sure to cancel Extra Duel?")) {
if ($("#shout").val().length) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?deathcancel=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
else {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?deathcancel=all&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
}
function shoutcallback(data) {
$("#message_callback").text(data[0]);
if (data[1]) {
$("#shout").val(data[1]);
}
}
\ No newline at end of file
......@@ -70,213 +70,7 @@
<script src="https://cdn.jsdelivr.net/npm/jquery@2.2.4/dist//jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script>
$(function(){
$("body").tooltip({selector: "[data-toggle='tooltip']", trigger: "hover"});
$("#open_button").click(loadrooms);
$("#auto_button").click(autoload);
$("#shout_button").click(shout);
$("#stop_button").click(stop);
$("#welcome_button").click(welcome);
$("#tips_button").click(load_tips);
$("#dialogues_button").click(load_dialogues);
$("#ban_button").click(ban_player);
$("#kick_button").click(kick_room);
$("#death_button").click(start_death);
$("#deathcancel_button").click(cancel_death);
var params=parseQueryString();
$("#ip").val(params["ip"]);
$("#port").val(params["port"]);
$("#password").val(params["password"]);
});
function parseQueryString() {
//http://stackoverflow.com/questions/523266/how-can-i-get-a-specific-parameter-from-location-search
var str = window.location.search;
var objURL = {};
str.replace(
new RegExp( "([^?=&]+)(=([^&]*))?", "g" ),
function( $0, $1, $2, $3 ){
objURL[ $1 ] = $3;
}
);
return objURL;
}
function loadrooms() {
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/getrooms?callback=?"+ ($("#password").val() ? "&pass="+$("#password").val() : "");
$.getJSON(url, listroom);
$("#open_button").removeClass("btn-success");
}
function autoload() {
if (window.autoLoad) {
window.clearInterval(window.autoLoad);
window.autoLoad=false;
$("#message_callback").text("关闭自动刷新");
}
else {
if (!$("#password").val()) {
alert("请输入密码");
return;
}
window.autoLoad=window.setInterval(loadrooms,1000);
}
}
function playerinfo(player, mode) {
if (!player)
return "";
var info = player.name;
if (player.status) {
var status = "";
if (mode == 1)
status = status + "得分: " + player.status.score + " " ;
if (mode != 2 || player.pos % 2 == 0)
status = status + "LP: "+ player.status.lp;
if (mode != 2)
status = status + " 卡数: "+ player.status.cards;
if (status != "")
info = info + " <em>(" + status + ")</em>";
}
if (player.ip)
info = info +"<br><code>IP: " + player.ip + "</code>";
return info;
}
function listroom(data) {
$("#open_button").addClass("btn-success");
$("#num").text(data.rooms.length);
var tbody=$("<tbody></tbody>");
for (i in data.rooms) {
var room=data.rooms[i];
var tr=$("<tr></tr>");
room.duelers=[];
room.watchers=[];
for (j in room.users) {
if (room.users[j].pos==7) {
room.watchers.push(room.users[j]);
}
else {
room.duelers.push(room.users[j]);
}
}
tr.append($("<td>"+room.roomid+"</td>"));
tr.append($("<td>"+ ((room.needpass == "true") ? "<span class='glyphicon glyphicon-lock'></span>" : "") + room.roomname+ "</td>"));
if (room.roommode != 2) {
tr.append($("<td>"+playerinfo(room.duelers[0], room.roommode)+"</td>"));
tr.append($("<td>"+playerinfo(room.duelers[1], room.roommode)+"</td>"));
}
else {
tr.append($("<td>"+playerinfo(room.duelers[0], 2)+"<br>"+playerinfo(room.duelers[1], 2)+"</td>"));
tr.append($("<td>"+playerinfo(room.duelers[2], 2)+"<br>"+playerinfo(room.duelers[3], 2)+"</td>"));
}
var watchlist="";
if (room.watchers.length) {
for (j in room.watchers) {
watchlist+=room.watchers[j].name+"\r\n";
}
}
tr.append($("<td>"+ (watchlist ? "<span class='glyphicon glyphicon-eye-open' data-toggle='tooltip' title='" + watchlist + "'></span>" : "") + room.istart +"</td>"));
tbody.append(tr);
}
$("#rooms tbody").remove();
$("#rooms").append(tbody);
}
function shout() {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?shout=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
function stop() {
if (confirm("确实要停服吗?")) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?stop=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
function welcome() {
if ($("#shout").val().length) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?welcome=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
else {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?getwelcome=1&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
function load_tips() {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?loadtips=1&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
function load_dialogues() {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?loaddialogues=1&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
function ban_player() {
if (confirm("确实要封禁该玩家吗?")) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?ban=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
function kick_room() {
if (confirm("确实要中止这个房间的决斗吗?")) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?kick=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
function start_death() {
if (confirm("确实要开始加时赛吗?")) {
if ($("#shout").val().length) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?death=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
else {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?death=all&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
}
function cancel_death() {
if (confirm("确实要取消加时赛吗?")) {
if ($("#shout").val().length) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?deathcancel=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
else {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?deathcancel=all&pass=" + $("#password").val() + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
}
function shoutcallback(data) {
$("#message_callback").text(data[0]);
if (data[1]) {
$("#shout").val(data[1]);
}
}
</script>
<script src="/dashboard-script.js"></script>
<script src="http://s4.cnzz.com/z_stat.php?id=1255875151&web_id=1255875151"></script>
</body>
......
......@@ -13,7 +13,7 @@
<div class="container">
<div class="row">
<div class="col-lg-12">
<p><a href="dashboard.html">Dashboard (房间管理)</a></p>
<p><a href="dashboard-en.html">Dashboard</a> (<a href="dashboard.html">房间管理</a>)</p>
<p><a href="pre-dashboard.html">Pre-Release Dashboard (先行卡更新)</a></p>
<p><a href="deck-dashboard.html">Deck Dashboard (竞赛模式卡组管理)</a></p>
<p><a href="replay-dashboard.html">Replay Dashboard (竞赛模式录像管理)</a></p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment