Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
fix also call js handlers for databind messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bartbutenaers committed Nov 15, 2021
1 parent da3d145 commit e049d5c
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions svg_graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,28 @@ div.ui-svg path {
function processCommand(payload, topic){
var selector, elements, attrElements, textElements;
try {
$scope.config.javascriptHandlers.forEach(function(javascriptHandler) {
// The "msg" event handler will be executed somewhere else (i.e. as a message watch)
if (javascriptHandler.action === "msg") {
try {
// Make sure the $scope variable is being used once here inside the handleJsEvent function, to make
// sure it becomes available to be used inside the eval expression.
$scope;

// The javascript event handler source code is base64 encoded, so let's decode it.
var sourceCode = atob(javascriptHandler.sourceCode);

if ($scope.config.enableJsDebugging) { debugger; }

// Execute the specified javascript function.
eval(sourceCode || "");
}
catch(err) {
logError("Error in javascript input msg handler: " + err);
}
}
});

if(topic){
if(topic == "databind"){
//Bind entries in "Input Bindings" TAB
Expand Down Expand Up @@ -1274,28 +1296,6 @@ div.ui-svg path {
}
return;
}

$scope.config.javascriptHandlers.forEach(function(javascriptHandler) {
// The "msg" event handler will be executed somewhere else (i.e. as a message watch)
if (javascriptHandler.action === "msg") {
try {
// Make sure the $scope variable is being used once here inside the handleJsEvent function, to make
// sure it becomes available to be used inside the eval expression.
$scope;

// The javascript event handler source code is base64 encoded, so let's decode it.
var sourceCode = atob(javascriptHandler.sourceCode);

if ($scope.config.enableJsDebugging) { debugger; }

// Execute the specified javascript function.
eval(sourceCode || "");
}
catch(err) {
logError("Error in javascript input msg handler: " + err);
}
}
});

//the payload.command or topic are both valid (backwards compatibility)
var op = payload.command || payload.topic
Expand Down

0 comments on commit e049d5c

Please sign in to comment.