diff --git a/nodes/core/core/58-debug.html b/nodes/core/core/58-debug.html
index 71aae718d..3ab593ac0 100644
--- a/nodes/core/core/58-debug.html
+++ b/nodes/core/core/58-debug.html
@@ -91,7 +91,7 @@
}
});
- var a = function() {
+ (function() {
var content = document.createElement("div");
content.id = "tab-debug";
@@ -114,84 +114,56 @@
var sbc = document.getElementById("debug-content");
- var errornotification = null;
-
var messageCount = 0;
-
- function debugConnect() {
- //console.log("debug ws connecting");
- var path = location.hostname+":"+location.port+document.location.pathname;
- path = path+(path.slice(-1) == "/"?"":"/")+"debug/ws";
- path = "ws"+(document.location.protocol=="https:"?"s":"")+"://"+path;
- var ws = new WebSocket(path);
- ws.onopen = function() {
- if (errornotification) {
- errornotification.close();
- errornotification = null;
- }
- //console.log("debug ws connected");
- }
- ws.onmessage = function(event) {
- var o = JSON.parse(event.data);
- if (o.heartbeat) {
- return;
- }
- //console.log(msg);
- var msg = document.createElement("div");
- msg.onmouseover = function() {
- msg.style.borderRightColor = "#999";
- var n = RED.nodes.node(o.id);
- if (n) {
- n.highlighted = true;
- n.dirty = true;
- }
- RED.view.redraw();
- };
- msg.onmouseout = function() {
- msg.style.borderRightColor = "";
- var n = RED.nodes.node(o.id);
- if (n) {
- n.highlighted = false;
- n.dirty = true;
- }
- RED.view.redraw();
- };
- msg.onclick = function() {
- var node = RED.nodes.node(o.id);
- if (node) {
- RED.view.showWorkspace(node.z);
- }
-
- };
- var name = (o.name?o.name:o.id).toString().replace(/&/g,"&").replace(//g,">");
- var topic = (o.topic||"").toString().replace(/&/g,"&").replace(//g,">");
- var payload = (o.msg||"").toString().replace(/&/g,"&").replace(//g,">");
- msg.className = 'debug-message'+(o.level?(' debug-message-level-'+o.level):'')
- msg.innerHTML = ''+getTimestamp()+''+
- '['+name+']'+
- (o.topic?''+topic+'':'')+
- ''+payload+'';
- var atBottom = (sbc.scrollHeight-messages.offsetHeight-sbc.scrollTop) < 5;
- messageCount++;
- $(messages).append(msg);
-
- if (messageCount > 200) {
- $("#debug-content .debug-message:first").remove();
- messageCount--;
- }
- if (atBottom) {
- $(sbc).scrollTop(sbc.scrollHeight);
+ var handleDebugMessage = function(t,o) {
+ var msg = document.createElement("div");
+ msg.onmouseover = function() {
+ msg.style.borderRightColor = "#999";
+ var n = RED.nodes.node(o.id);
+ if (n) {
+ n.highlighted = true;
+ n.dirty = true;
}
+ RED.view.redraw();
};
- ws.onclose = function() {
- if (errornotification == null) {
- errornotification = RED.notify("Error: Lost connection to server","error",true);
+ msg.onmouseout = function() {
+ msg.style.borderRightColor = "";
+ var n = RED.nodes.node(o.id);
+ if (n) {
+ n.highlighted = false;
+ n.dirty = true;
}
- setTimeout(debugConnect,1000);
+ RED.view.redraw();
+ };
+ msg.onclick = function() {
+ var node = RED.nodes.node(o.id);
+ if (node) {
+ RED.view.showWorkspace(node.z);
+ }
+
+ };
+ var name = (o.name?o.name:o.id).toString().replace(/&/g,"&").replace(//g,">");
+ var topic = (o.topic||"").toString().replace(/&/g,"&").replace(//g,">");
+ var payload = (o.msg||"").toString().replace(/&/g,"&").replace(//g,">");
+ msg.className = 'debug-message'+(o.level?(' debug-message-level-'+o.level):'')
+ msg.innerHTML = ''+getTimestamp()+''+
+ '['+name+']'+
+ (o.topic?''+topic+'':'')+
+ ''+payload+'';
+ var atBottom = (sbc.scrollHeight-messages.offsetHeight-sbc.scrollTop) < 5;
+ messageCount++;
+ $(messages).append(msg);
+
+ if (messageCount > 200) {
+ $("#debug-content .debug-message:first").remove();
+ messageCount--;
}
- }
- debugConnect();
+ if (atBottom) {
+ $(sbc).scrollTop(sbc.scrollHeight);
+ }
+ };
+ RED.comms.subscribe("debug",handleDebugMessage);
$("#debug-tab-clear").click(function() {
$(".debug-message").remove();
@@ -203,7 +175,7 @@
RED.view.redraw();
});
- }();
+ })();