add api/bgapi event functions

This commit is contained in:
Seven Du 2013-08-13 08:30:52 +08:00
parent 3ec15cce68
commit 3901ff4ddd
1 changed files with 27 additions and 0 deletions

View File

@ -783,3 +783,30 @@ function eventCallback(data) {
} }
} }
// execute api
function api(cmdstr)
{
cmdarr = cmdstr.split(" ");
cmd = cmdarr.shift();
arg = escape(cmdarr.join(" "));
arg = arg ? "?" + arg : "";
url = "/txtapi/" + cmd + arg;
$.get(url, function(data){
console.log(data);
});
return url;
}
//execute bgapi
function bgapi(cmd)
{
api("bgapi " + cmd);
}
// subscribe event
function event(e)
{
cmd = "event json " + e;
socket.send(cmd);
return cmd;
}