Commit d18c374f authored by nanahira's avatar nanahira

add username by paniuncle

parent 274abb39
...@@ -15,13 +15,16 @@ ...@@ -15,13 +15,16 @@
<div class="col-lg-1"> <div class="col-lg-1">
<input type="text" class="form-control" id="http" value="http" placeholder="http"> <input type="text" class="form-control" id="http" value="http" placeholder="http">
</div> </div>
<div class="col-lg-3"> <div class="col-lg-2">
<input type="text" class="form-control" id="ip" value="" placeholder="IP"> <input type="text" class="form-control" id="ip" value="" placeholder="IP">
</div> </div>
<div class="col-lg-1"> <div class="col-lg-1">
<input type="text" class="form-control" id="port" value="" placeholder="port"> <input type="text" class="form-control" id="port" value="" placeholder="port">
</div> </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"> <input type="password" class="form-control" id="password" value="" placeholder="password">
</div> </div>
<div class="col-lg-4"> <div class="col-lg-4">
......
...@@ -15,6 +15,7 @@ $(function(){ ...@@ -15,6 +15,7 @@ $(function(){
$("#ip").val(params["ip"]); $("#ip").val(params["ip"]);
$("#port").val(params["port"]); $("#port").val(params["port"]);
$("#password").val(params["password"]); $("#password").val(params["password"]);
$("#username").val(params["username"]);
}); });
function parseQueryString() { function parseQueryString() {
...@@ -31,7 +32,10 @@ function parseQueryString() { ...@@ -31,7 +32,10 @@ function parseQueryString() {
} }
function loadrooms() { 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); $.getJSON(url, listroom);
$("#open_button").removeClass("btn-success"); $("#open_button").removeClass("btn-success");
} }
...@@ -123,49 +127,49 @@ function listroom(data) { ...@@ -123,49 +127,49 @@ function listroom(data) {
function shout() { function shout() {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
function stop() { function stop() {
if (confirm("Are you sure to stop the server?")) { if (confirm("Are you sure to stop the server?")) {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
} }
function welcome() { function welcome() {
if ($("#shout").val().length) { if ($("#shout").val().length) {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
else { else {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
} }
function load_tips() { function load_tips() {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
function load_dialogues() { function load_dialogues() {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
function ban_player() { function ban_player() {
if (confirm("Are you sure to ban this player?")) { if (confirm("Are you sure to ban this player?")) {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
} }
function kick_room() { function kick_room() {
if (confirm("Are you sure to terminate this duel?")) { if (confirm("Are you sure to terminate this duel?")) {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
} }
...@@ -173,12 +177,12 @@ function start_death() { ...@@ -173,12 +177,12 @@ function start_death() {
if (confirm("Are you sure to start Extra Duel?")) { if (confirm("Are you sure to start Extra Duel?")) {
if ($("#shout").val().length) { if ($("#shout").val().length) {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
else { else {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
} }
...@@ -187,12 +191,12 @@ function cancel_death() { ...@@ -187,12 +191,12 @@ function cancel_death() {
if (confirm("Are you sure to cancel Extra Duel?")) { if (confirm("Are you sure to cancel Extra Duel?")) {
if ($("#shout").val().length) { if ($("#shout").val().length) {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
else { else {
$("#message_callback").text('...'); $("#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); $.getJSON(url, shoutcallback);
} }
} }
......
...@@ -15,13 +15,16 @@ ...@@ -15,13 +15,16 @@
<div class="col-lg-1"> <div class="col-lg-1">
<input type="text" class="form-control" id="http" value="http" placeholder="http"> <input type="text" class="form-control" id="http" value="http" placeholder="http">
</div> </div>
<div class="col-lg-3"> <div class="col-lg-2">
<input type="text" class="form-control" id="ip" value="" placeholder="IP"> <input type="text" class="form-control" id="ip" value="" placeholder="IP">
</div> </div>
<div class="col-lg-1"> <div class="col-lg-1">
<input type="text" class="form-control" id="port" value="" placeholder="port"> <input type="text" class="form-control" id="port" value="" placeholder="port">
</div> </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"> <input type="password" class="form-control" id="password" value="" placeholder="password">
</div> </div>
<div class="col-lg-4"> <div class="col-lg-4">
......
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
<div class="col-lg-2"> <div class="col-lg-2">
<input type="text" class="form-control" id="port" value="" placeholder="Port"> <input type="text" class="form-control" id="port" value="" placeholder="Port">
</div> </div>
<div class="col-lg-2">
<input type="text" class="form-control" id="username" value="" placeholder="Username">
</div>
<div class="col-lg-2"> <div class="col-lg-2">
<input type="password" class="form-control" id="password" value="" placeholder="Password"> <input type="password" class="form-control" id="password" value="" placeholder="Password">
</div> </div>
...@@ -89,7 +92,7 @@ $(function(){ ...@@ -89,7 +92,7 @@ $(function(){
$("#ip").val(params["ip"]); $("#ip").val(params["ip"]);
$("#port").val(params["port"]); $("#port").val(params["port"]);
$("#password").val(params["password"]); $("#password").val(params["password"]);
$("#username").val(params["username"]);
$("#filesel").change(function() { $("#filesel").change(function() {
upload_decks(); upload_decks();
}); });
...@@ -122,7 +125,8 @@ function login() { ...@@ -122,7 +125,8 @@ function login() {
ip=$("#ip").val(); ip=$("#ip").val();
port=$("#port").val(); port=$("#port").val();
password=$("#password").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) { es.onmessage = function(e) {
output(e.data); output(e.data);
...@@ -230,7 +234,7 @@ function openapi(api, msg, confirm2) { ...@@ -230,7 +234,7 @@ function openapi(api, msg, confirm2) {
$("#filesel").click(); $("#filesel").click();
} }
else if (!confirm2 || confirm(confirm2)) { 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]) { if (apis[api]) {
apis[api].callback(data); apis[api].callback(data);
} }
...@@ -249,7 +253,7 @@ function upload_decks() { ...@@ -249,7 +253,7 @@ function upload_decks() {
formData.append('upload['+i+']', filesel.files[i]); formData.append('upload['+i+']', filesel.files[i]);
} }
$.ajax({ $.ajax({
url: "http://"+ip+":"+port+"/api/upload_decks?password="+password, url: "http://"+ip+":"+port+"/api/upload_decks?username="+username+"password="+password,
type: 'POST', type: 'POST',
cache: false, cache: false,
data: formData, data: formData,
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
</div> </div>
<div class="col-lg-2"> <div class="col-lg-2">
<input type="text" class="form-control" id="port" value="" placeholder="Port"> <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>
<div class="col-lg-2"> <div class="col-lg-2">
<input type="password" class="form-control" id="password" value="" placeholder="Password"> <input type="password" class="form-control" id="password" value="" placeholder="Password">
...@@ -82,6 +85,7 @@ $(function(){ ...@@ -82,6 +85,7 @@ $(function(){
$("#ip").val(params["ip"]); $("#ip").val(params["ip"]);
$("#port").val(params["port"]); $("#port").val(params["port"]);
$("#password").val(params["password"]); $("#password").val(params["password"]);
$("#username").val(params["username"]);
}); });
function parseQueryString() { function parseQueryString() {
...@@ -101,7 +105,8 @@ function login() { ...@@ -101,7 +105,8 @@ function login() {
ip=$("#ip").val(); ip=$("#ip").val();
port=$("#port").val(); port=$("#port").val();
password=$("#password").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) { es.onmessage = function(e) {
var data_li = $('<li>'+ e.data +'</li>'); var data_li = $('<li>'+ e.data +'</li>');
data_li.appendTo($("#output")); data_li.appendTo($("#output"));
...@@ -124,7 +129,7 @@ function clear() { ...@@ -124,7 +129,7 @@ function clear() {
} }
function openapi(api) { 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>'); var data_li = $('<li>'+ data.message +'</li>');
data_li.appendTo($("#output")); data_li.appendTo($("#output"));
}); });
......
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
<div class="col-lg-1"> <div class="col-lg-1">
<input type="text" class="form-control" id="port" value="" placeholder="port"> <input type="text" class="form-control" id="port" value="" placeholder="port">
</div> </div>
<div class="col-lg-3">
<input type="text" class="form-control" id="username" value="" placeholder="username">
</div>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="password" class="form-control" id="password" value="" placeholder="password"> <input type="password" class="form-control" id="password" value="" placeholder="password">
</div> </div>
...@@ -75,6 +78,7 @@ $(function(){ ...@@ -75,6 +78,7 @@ $(function(){
$("#ip").val(params["ip"]); $("#ip").val(params["ip"]);
$("#port").val(params["port"]); $("#port").val(params["port"]);
$("#password").val(params["password"]); $("#password").val(params["password"]);
$("#username").val(params["username"]);
}); });
function parseQueryString() { function parseQueryString() {
...@@ -91,21 +95,21 @@ function parseQueryString() { ...@@ -91,21 +95,21 @@ function parseQueryString() {
} }
function loadreplays() { 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); $.getJSON(url, listreplay);
$("#open_button").removeClass("btn-success"); $("#open_button").removeClass("btn-success");
} }
function clearreplays() { function clearreplays() {
if (confirm("确实要清空记录吗?")) { 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); $.getJSON(url, clearreplays_success);
$("#empty_button").removeClass("btn-success"); $("#empty_button").removeClass("btn-success");
} }
} }
function packreplays() { 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() { function clearreplays_success() {
...@@ -135,7 +139,7 @@ function listreplay(data) { ...@@ -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.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>"+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); tbody.append(tr);
......
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
<div class="col-lg-2"> <div class="col-lg-2">
<input type="text" class="form-control" id="port" value="" placeholder="Port"> <input type="text" class="form-control" id="port" value="" placeholder="Port">
</div> </div>
<div class="col-lg-2">
<input type="username" class="form-control" id="username" value="" placeholder="Username">
</div>
<div class="col-lg-2"> <div class="col-lg-2">
<input type="password" class="form-control" id="password" value="" placeholder="Password"> <input type="password" class="form-control" id="password" value="" placeholder="Password">
</div> </div>
...@@ -113,6 +116,8 @@ $(function(){ ...@@ -113,6 +116,8 @@ $(function(){
$("#ip").val(params["ip"]); $("#ip").val(params["ip"]);
$("#port").val(params["port"]); $("#port").val(params["port"]);
$("#password").val(params["password"]); $("#password").val(params["password"]);
$("#username").val(params["username"]);
$("#message").val($("#message-head").val()+$("#message-body").val()+$("#message-other").val()); $("#message").val($("#message-head").val()+$("#message-body").val()+$("#message-other").val());
}); });
...@@ -134,7 +139,8 @@ function login() { ...@@ -134,7 +139,8 @@ function login() {
ip=$("#ip").val(); ip=$("#ip").val();
port=$("#port").val(); port=$("#port").val();
password=$("#password").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) { es.onmessage = function(e) {
var data_li = $('<li>'+ e.data +'</li>'); var data_li = $('<li>'+ e.data +'</li>');
data_li.appendTo($("#output")); data_li.appendTo($("#output"));
...@@ -168,7 +174,7 @@ function clear() { ...@@ -168,7 +174,7 @@ function clear() {
} }
function openapi(api) { 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>'); var data_li = $('<li>'+ data.message +'</li>');
data_li.appendTo($("#output")); 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