Commit d18c374f authored by nanahira's avatar nanahira

add username by paniuncle

parent 274abb39
......@@ -15,13 +15,16 @@
<div class="col-lg-1">
<input type="text" class="form-control" id="http" value="http" placeholder="http">
</div>
<div class="col-lg-3">
<div class="col-lg-2">
<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">
<div class="col-lg-2">
<input type="text" class="form-control" id="username" value="" placeholder="username">
</div>
<div class="col-lg-2">
<input type="password" class="form-control" id="password" value="" placeholder="password">
</div>
<div class="col-lg-4">
......
......@@ -15,6 +15,7 @@ $(function(){
$("#ip").val(params["ip"]);
$("#port").val(params["port"]);
$("#password").val(params["password"]);
$("#username").val(params["username"]);
});
function parseQueryString() {
......@@ -31,7 +32,10 @@ function parseQueryString() {
}
function loadrooms() {
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/getrooms?callback=?"+ ($("#password").val() ? "&pass="+$("#password").val() : "");
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/getrooms?callback=?"+ ($("#username").val() ? "&username="+$("#username").val() : "") + ($("#password").val() ? "&pass="+$("#password").val() : "");
alert(url);
$.getJSON(url, listroom);
$("#open_button").removeClass("btn-success");
}
......@@ -123,49 +127,49 @@ function listroom(data) {
function shout() {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?shout=" + $("#shout").val() + "&pass=" + $("#password").val() + "&callback=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?shout=" + $("#shout").val() + "&username="+$("#username").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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?stop=" + $("#shout").val() +"&username="+$("#username").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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?welcome=" + $("#shout").val() + "&username="+$("#username").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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?getwelcome=1&pass=" + $("#password").val() + "&username="+$("#username").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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?loadtips=1&pass=" + $("#password").val() + "&username="+$("#username").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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?loaddialogues=1&pass=" + $("#password").val() +"&username="+$("#username").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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?ban=" + $("#shout").val() + "&pass=" + $("#password").val() +"&username="+$("#username").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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?kick=" + $("#shout").val() + "&pass=" + $("#password").val() + "&username="+$("#username").val() +"&callback=?";
$.getJSON(url, shoutcallback);
}
}
......@@ -173,12 +177,12 @@ 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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?death=" + $("#shout").val() + "&pass=" + $("#password").val() +"&username="+$("#username").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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?death=all&pass=" + $("#password").val() + "&username="+$("#username").val() +"&callback=?";
$.getJSON(url, shoutcallback);
}
}
......@@ -187,12 +191,12 @@ 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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?deathcancel=" + $("#shout").val() + "&pass=" + $("#password").val() + "&username="+$("#username").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=?";
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?deathcancel=all&pass=" + $("#password").val() + "&username="+$("#username").val() +"&callback=?";
$.getJSON(url, shoutcallback);
}
}
......
......@@ -15,13 +15,16 @@
<div class="col-lg-1">
<input type="text" class="form-control" id="http" value="http" placeholder="http">
</div>
<div class="col-lg-3">
<div class="col-lg-2">
<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">
<div class="col-lg-2">
<input type="text" class="form-control" id="username" value="" placeholder="username">
</div>
<div class="col-lg-2">
<input type="password" class="form-control" id="password" value="" placeholder="password">
</div>
<div class="col-lg-4">
......
......@@ -18,6 +18,9 @@
<div class="col-lg-2">
<input type="text" class="form-control" id="port" value="" placeholder="Port">
</div>
<div class="col-lg-2">
<input type="text" class="form-control" id="username" value="" placeholder="Username">
</div>
<div class="col-lg-2">
<input type="password" class="form-control" id="password" value="" placeholder="Password">
</div>
......@@ -89,7 +92,7 @@ $(function(){
$("#ip").val(params["ip"]);
$("#port").val(params["port"]);
$("#password").val(params["password"]);
$("#username").val(params["username"]);
$("#filesel").change(function() {
upload_decks();
});
......@@ -122,7 +125,8 @@ function login() {
ip=$("#ip").val();
port=$("#port").val();
password=$("#password").val();
var es = new EventSource("http://"+ip+":"+port+"/api/msg?password="+password);
username=$("#username").val();
var es = new EventSource("http://"+ip+":"+port+"/api/msg?username="+username+"&password="+password);
es.onmessage = function(e) {
output(e.data);
......@@ -230,7 +234,7 @@ function openapi(api, msg, confirm2) {
$("#filesel").click();
}
else if (!confirm2 || confirm(confirm2)) {
$.getJSON("http://"+ip+":"+port+"/api/"+ api +"?password="+password + (msg ? "&msg="+encodeURIComponent(msg) : "" ) + "&callback=?", function(data) {
$.getJSON("http://"+ip+":"+port+"/api/"+ api +"?username="+username+"&password="+password + (msg ? "&msg="+encodeURIComponent(msg) : "" ) + "&callback=?", function(data) {
if (apis[api]) {
apis[api].callback(data);
}
......@@ -249,7 +253,7 @@ function upload_decks() {
formData.append('upload['+i+']', filesel.files[i]);
}
$.ajax({
url: "http://"+ip+":"+port+"/api/upload_decks?password="+password,
url: "http://"+ip+":"+port+"/api/upload_decks?username="+username+"password="+password,
type: 'POST',
cache: false,
data: formData,
......
......@@ -17,6 +17,9 @@
</div>
<div class="col-lg-2">
<input type="text" class="form-control" id="port" value="" placeholder="Port">
</div>
<div class="col-lg-2">
<input type="text" class="form-control" id="username" value="" placeholder="Username">
</div>
<div class="col-lg-2">
<input type="password" class="form-control" id="password" value="" placeholder="Password">
......@@ -82,6 +85,7 @@ $(function(){
$("#ip").val(params["ip"]);
$("#port").val(params["port"]);
$("#password").val(params["password"]);
$("#username").val(params["username"]);
});
function parseQueryString() {
......@@ -101,7 +105,8 @@ function login() {
ip=$("#ip").val();
port=$("#port").val();
password=$("#password").val();
var es = new EventSource("http://"+ip+":"+port+"/api/msg?password="+password);
username=$("#username").val();
var es = new EventSource("http://"+ip+":"+port+"/api/msg?username="+username+"password="+password);
es.onmessage = function(e) {
var data_li = $('<li>'+ e.data +'</li>');
data_li.appendTo($("#output"));
......@@ -124,7 +129,7 @@ function clear() {
}
function openapi(api) {
$.getJSON("http://"+ip+":"+port+"/api/"+ api +"?password="+password+"&message="+$("#message").val().replace(/\n/g,"!换行符!")+"&callback=?", function(data) {
$.getJSON("http://"+ip+":"+port+"/api/"+ api +"?username="+username+"&password="+password+"&message="+$("#message").val().replace(/\n/g,"!换行符!")+"&callback=?", function(data) {
var data_li = $('<li>'+ data.message +'</li>');
data_li.appendTo($("#output"));
});
......
......@@ -21,6 +21,9 @@
<div class="col-lg-1">
<input type="text" class="form-control" id="port" value="" placeholder="port">
</div>
<div class="col-lg-3">
<input type="text" class="form-control" id="username" value="" placeholder="username">
</div>
<div class="col-lg-3">
<input type="password" class="form-control" id="password" value="" placeholder="password">
</div>
......@@ -75,6 +78,7 @@ $(function(){
$("#ip").val(params["ip"]);
$("#port").val(params["port"]);
$("#password").val(params["password"]);
$("#username").val(params["username"]);
});
function parseQueryString() {
......@@ -91,21 +95,21 @@ function parseQueryString() {
}
function loadreplays() {
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/duellog?callback=?"+ ($("#password").val() ? "&pass="+$("#password").val() : "");
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/duellog?callback=?"+ ($("#username").val() ? "&username="+$("#username").val() : "") +($("#password").val() ? "&pass="+$("#password").val() : "");
$.getJSON(url, listreplay);
$("#open_button").removeClass("btn-success");
}
function clearreplays() {
if (confirm("确实要清空记录吗?")) {
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/clearlog?callback=?"+ ($("#password").val() ? "&pass="+$("#password").val() : "");
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/clearlog?callback=?"+ ($("#username").val() ? "&username="+$("#username").val() : "") +($("#password").val() ? "&pass="+$("#password").val() : "");
$.getJSON(url, clearreplays_success);
$("#empty_button").removeClass("btn-success");
}
}
function packreplays() {
window.open($("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/archive.zip?pass="+$("#password").val());
window.open($("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/archive.zip?username="+$("#username").val()+"&pass="+$("#password").val());
}
function clearreplays_success() {
......@@ -135,7 +139,7 @@ function listreplay(data) {
tr.append($("<td>"+((duellog.players) ? (duellog.players[2].winner ? "<span class='glyphicon glyphicon-bookmark'></span> " : "") + duellog.players[2].name + "<br>" + duellog.players[3].name : "")+"</td>"));
}
tr.append($("<td>"+duellog.cloud_replay_id+"</td>"));
tr.append($("<td><a href='"+$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/replay/"+duellog.replay_filename+"?pass="+$("#password").val()+"' download><span class='glyphicon glyphicon-download-alt'></span></a></td>"));
tr.append($("<td><a href='"+$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/replay/"+duellog.replay_filename+"?username="+$("#username").val()+"&pass="+$("#password").val()+"' download><span class='glyphicon glyphicon-download-alt'></span></a></td>"));
tbody.append(tr);
......
......@@ -18,6 +18,9 @@
<div class="col-lg-2">
<input type="text" class="form-control" id="port" value="" placeholder="Port">
</div>
<div class="col-lg-2">
<input type="username" class="form-control" id="username" value="" placeholder="Username">
</div>
<div class="col-lg-2">
<input type="password" class="form-control" id="password" value="" placeholder="Password">
</div>
......@@ -113,6 +116,8 @@ $(function(){
$("#ip").val(params["ip"]);
$("#port").val(params["port"]);
$("#password").val(params["password"]);
$("#username").val(params["username"]);
$("#message").val($("#message-head").val()+$("#message-body").val()+$("#message-other").val());
});
......@@ -134,7 +139,8 @@ function login() {
ip=$("#ip").val();
port=$("#port").val();
password=$("#password").val();
var es = new EventSource("http://"+ip+":"+port+"/api/msg?password="+password);
username=$("#username").val();
var es = new EventSource("http://"+ip+":"+port+"/api/msg?username="+username+"&password="+password);
es.onmessage = function(e) {
var data_li = $('<li>'+ e.data +'</li>');
data_li.appendTo($("#output"));
......@@ -168,7 +174,7 @@ function clear() {
}
function openapi(api) {
$.getJSON("http://"+ip+":"+port+"/api/"+ api +"?password="+password+"&message="+$("#message").val().replace(/\n/g,"!换行符!")+"&callback=?", function(data) {
$.getJSON("http://"+ip+":"+port+"/api/"+ api +"?username="+username+"&password="+password+"&message="+$("#message").val().replace(/\n/g,"!换行符!")+"&callback=?", function(data) {
var data_li = $('<li>'+ data.message +'</li>');
data_li.appendTo($("#output"));
});
......
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