summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-04-13 12:59:54 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2017-04-13 12:59:54 +0200
commit393b140beab0ab124ff4143e2df0baed9cb4c4e3 (patch)
treed21bbe13181d13f846d0e056b9d191a92b4872b7
parent187c9da9855ef8759a3bd386177cc8eb8c76f147 (diff)
downloadbridge-393b140beab0ab124ff4143e2df0baed9cb4c4e3.tar.gz
bridge-393b140beab0ab124ff4143e2df0baed9cb4c4e3.zip
subscribe to all notifications on dashboard
-rw-r--r--index.html23
1 files changed, 11 insertions, 12 deletions
diff --git a/index.html b/index.html
index a99c6ca..4c0fa64 100644
--- a/index.html
+++ b/index.html
@@ -58,12 +58,15 @@
};
// connect
- client.connect("web", "web", () => notif("connected to socket", "purple"),
- (err) => notif("error connecting to socket: " + JSON.stringify(err), "red"));
+ client.connect("web", "web", () => {
+ notif("connected to socket", "purple");
+ client.subscribe("/topic/#", (msg) => {
+ let name = "";
+ if (msg.headers.destination.indexOf("player") != -1)
+ name = msg.headers.destination.substring(
+ "/topic/player.".length);
+ else name = "global";
- let subscribe = (name) => {
- // subscribe
- client.subscribe("/topic/player." + name, (msg) => {
notif(msg.body, "grey");
switch (msg.body) {
case "search_fail":
@@ -77,14 +80,14 @@
}
msg.ack();
}, {"ack": "client"});
- }
+ },
+ (err) => notif("error connecting to socket: " + JSON.stringify(err), "red"));
$("#update-form").submit((e) => {
e.preventDefault();
let ign = $("#update-name").val(),
force = $("#update-force").is(":checked");
- subscribe(ign);
if (force) {
$.post("/api/player/" + ign + "/search");
} else {
@@ -93,10 +96,7 @@
});
$("#update-random-form").submit((e) => {
e.preventDefault();
- $.post("/api/player").done((resp) => {
- notif(resp.name + ": random user", "green");
- subscribe(resp.name);
- });
+ $.post("/api/player");
});
$("#get-samples-form").submit((e) => {
e.preventDefault();
@@ -108,7 +108,6 @@
$("#crunch-form").submit((e) => {
e.preventDefault();
let ign = $("#crunch-name").val();
- subscribe(ign);
$.post("/api/player/" + ign + "/crunch");
});
$("#crunchglobal-form").submit((e) => {