Commit 6e1792c1 authored by nanahira's avatar nanahira

add query conditions

parent 581339d8
...@@ -34,12 +34,24 @@ ...@@ -34,12 +34,24 @@
</div> </div>
<div class="container"> <div class="container">
<div class="row buttons"> <div class="row buttons">
<div class="col-lg-12"> <div class="col-lg-4">
<button class="btn btn-default" id="open_button">刷新</button> <button class="btn btn-default" id="open_button">刷新</button>
<button class="btn btn-default" id="empty_button">清空记录</button> <button class="btn btn-default" id="empty_button">清空记录</button>
<button class="btn btn-default" id="pack_button">打包下载录像</button> <button class="btn btn-default" id="pack_button">打包下载录像</button>
共有<span id="num">0</span>场决斗 共有<span id="num">0</span>场决斗
</div> </div>
<div class="col-lg-3">
<input type="text" class="form-control" id="roomname" value="" placeholder="房名">
</div>
<div class="col-lg-1">
<input type="text" class="form-control" id="duelcount" value="" placeholder="决斗局数">
</div>
<div class="col-lg-3">
<input type="text" class="form-control" id="playername" value="" placeholder="玩家名">
</div>
<div class="col-lg-1">
<input type="text" class="form-control" id="score" value="" placeholder="分数">
</div>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
...@@ -74,7 +86,11 @@ $(function(){ ...@@ -74,7 +86,11 @@ $(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"]); $("#username").val(params["username"]);
$("#roomname").val(params["roomname"]);
$("#duelcount").val(params["duelcount"]);
$("#playername").val(params["playername"]);
$("#score").val(params["score"]);
}); });
function parseQueryString() { function parseQueryString() {
...@@ -98,22 +114,28 @@ function get_value(name) { ...@@ -98,22 +114,28 @@ function get_value(name) {
return encodeURIComponent($(name).val()); return encodeURIComponent($(name).val());
} }
function getPossibleTextValue(fieldName, realQueryKey) {
const fullFieldName = `#${fieldName}`;
const realQueryKey = queryKey || fieldName;
return (get_value(fullFieldName) ? `&${realQueryKey}=${get_value(fullFieldName)}` : "");
}
function loadreplays() { function loadreplays() {
var url=get_http() + "/api/duellog?callback=?"+ (get_value("#username") ? "&username="+get_value("#username") : "") +(get_value("#password") ? "&pass="+get_value("#password") : ""); var url=get_http() + "/api/duellog?callback=?"+ getPossibleTextValue("username") + getPossibleTextValue("password", "pass") + getPossibleTextValue("roomname") + getPossibleTextValue("duelcount") + getPossibleTextValue("playername") + getPossibleTextValue("score");
$.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=get_http() + "/api/clearlog?callback=?"+ (get_value("#username") ? "&username="+get_value("#username") : "") +(get_value("#password") ? "&pass="+get_value("#password") : ""); var url=get_http() + "/api/clearlog?callback=?"+ getPossibleTextValue("username") + getPossibleTextValue("password", "pass");
$.getJSON(url, clearreplays_success); $.getJSON(url, clearreplays_success);
$("#empty_button").removeClass("btn-success"); $("#empty_button").removeClass("btn-success");
} }
} }
function packreplays() { function packreplays() {
window.open(get_http() + "/api/archive.zip?username="+get_value("#username")+"&pass="+get_value("#password")); window.open(get_http() + "/api/archive.zip?placeholder=1"+ getPossibleTextValue("username") + getPossibleTextValue("password", "pass") + getPossibleTextValue("roomname") + getPossibleTextValue("duelcount") + getPossibleTextValue("playername")) + getPossibleTextValue("score");
} }
function clearreplays_success() { function clearreplays_success() {
......
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