From 3901ff4dddf6553c985f9a000398a1af918f36f6 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Tue, 13 Aug 2013 08:30:52 +0800 Subject: [PATCH] add api/bgapi event functions --- htdocs/portal/assets/js/fsportal.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/htdocs/portal/assets/js/fsportal.js b/htdocs/portal/assets/js/fsportal.js index cf9f87f1fe..f76c371d23 100644 --- a/htdocs/portal/assets/js/fsportal.js +++ b/htdocs/portal/assets/js/fsportal.js @@ -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; +}