Commit 236959cd authored by nanahira's avatar nanahira

encode uri

parent 8e07470c
......@@ -31,8 +31,16 @@ function parseQueryString() {
return objURL;
}
function get_http() {
return $("#http").val() + "://" + $("#ip").val() + ($("#port").val() ? (":" + $("#port").val()) : "");
}
function get_value(name) {
return encodeURIComponent($(name).val());
}
function loadrooms() {
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/getrooms?callback=?"+ ($("#username").val() ? "&username="+$("#username").val() : "") + ($("#password").val() ? "&pass="+$("#password").val() : "");
var url=get_http() + "/api/getrooms?callback=?"+ (get_value("#username") ? "&username="+get_value("#username") : "") + (get_value("#password") ? "&pass="+get_value("#password") : "");
//alert(url);
......@@ -47,7 +55,7 @@ function autoload() {
$("#message_callback").text("OFF");
}
else {
/*if (!$("#password").val()) {
/*if (!get_value("#password")) {
alert("请输入密码");
return;
}*/
......@@ -127,76 +135,76 @@ function listroom(data) {
function shout() {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?shout=" + $("#shout").val() + "&username="+$("#username").val()+"&pass=" + $("#password").val() + "&callback=?";
var url=get_http() + "/api/message?shout=" + get_value("#shout") + "&username="+get_value("#username")+"&pass=" + get_value("#password") + "&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() +"&username="+$("#username").val()+ "&pass=" + $("#password").val() + "&callback=?";
var url=get_http() + "/api/message?stop=" + get_value("#shout") +"&username="+get_value("#username")+ "&pass=" + get_value("#password") + "&callback=?";
$.getJSON(url, shoutcallback);
}
}
function welcome() {
if ($("#shout").val().length) {
if (get_value("#shout").length) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?welcome=" + $("#shout").val() + "&username="+$("#username").val()+"&pass=" + $("#password").val() + "&callback=?";
var url=get_http() + "/api/message?welcome=" + get_value("#shout") + "&username="+get_value("#username")+"&pass=" + get_value("#password") + "&callback=?";
$.getJSON(url, shoutcallback);
}
else {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?getwelcome=1&pass=" + $("#password").val() + "&username="+$("#username").val()+ "&callback=?";
var url=get_http() + "/api/message?getwelcome=1&pass=" + get_value("#password") + "&username="+get_value("#username")+ "&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() + "&username="+$("#username").val() + "&callback=?";
var url=get_http() + "/api/message?loadtips=1&pass=" + get_value("#password") + "&username="+get_value("#username") + "&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() +"&username="+$("#username").val() +"&callback=?";
var url=get_http() + "/api/message?loaddialogues=1&pass=" + get_value("#password") +"&username="+get_value("#username") +"&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() +"&username="+$("#username").val() +"&callback=?";
var url=get_http() + "/api/message?ban=" + get_value("#shout") + "&pass=" + get_value("#password") +"&username="+get_value("#username") +"&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() + "&username="+$("#username").val() +"&callback=?";
var url=get_http() + "/api/message?kick=" + get_value("#shout") + "&pass=" + get_value("#password") + "&username="+get_value("#username") +"&callback=?";
$.getJSON(url, shoutcallback);
}
}
function start_death() {
if (confirm("Are you sure to start Extra Duel?")) {
if ($("#shout").val().length) {
if (get_value("#shout").length) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?death=" + $("#shout").val() + "&pass=" + $("#password").val() +"&username="+$("#username").val() +"&callback=?";
var url=get_http() + "/api/message?death=" + get_value("#shout") + "&pass=" + get_value("#password") +"&username="+get_value("#username") +"&callback=?";
$.getJSON(url, shoutcallback);
}
else {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?death=all&pass=" + $("#password").val() + "&username="+$("#username").val() +"&callback=?";
var url=get_http() + "/api/message?death=all&pass=" + get_value("#password") + "&username="+get_value("#username") +"&callback=?";
$.getJSON(url, shoutcallback);
}
}
}
function cancel_death() {
if (confirm("Are you sure to cancel Extra Duel?")) {
if ($("#shout").val().length) {
if (get_value("#shout").length) {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?deathcancel=" + $("#shout").val() + "&pass=" + $("#password").val() + "&username="+$("#username").val() +"&callback=?";
var url=get_http() + "/api/message?deathcancel=" + get_value("#shout") + "&pass=" + get_value("#password") + "&username="+get_value("#username") +"&callback=?";
$.getJSON(url, shoutcallback);
}
else {
$("#message_callback").text('...');
var url=$("#http").val() + "://" + $("#ip").val() + ":" + $("#port").val() + "/api/message?deathcancel=all&pass=" + $("#password").val() + "&username="+$("#username").val() +"&callback=?";
var url=get_http() + "/api/message?deathcancel=all&pass=" + get_value("#password") + "&username="+get_value("#username") +"&callback=?";
$.getJSON(url, shoutcallback);
}
}
......
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