Sequence Diagram: Removed eval from popup handling

This commit is contained in:
Ashish Jain
2021-10-14 21:02:18 +02:00
parent 18ecf479b1
commit 4a50995906
3 changed files with 29 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
import common from '../common/common';
import { addFunction } from '../../interactionDb';
export const drawRect = function (elem, rectData) {
const rectElem = elem.append('rect');
@@ -25,6 +26,17 @@ const sanitizeUrl = function (s) {
.replace(/javascript:/g, '');
};
const addPopupInteraction = (id, actorCnt) => {
addFunction(() => {
const arr = document.querySelectorAll(id);
arr[0].addEventListener('mouseover', function () {
popupMenuUpFunc('actor' + actorCnt + '_popup');
});
arr[0].addEventListener('mouseout', function () {
popupMenuDownFunc('actor' + actorCnt + '_popup');
});
});
};
export const drawPopup = function (elem, actor, minMenuWidth, textAttrs, forceMenus) {
if (actor.links === undefined || actor.links === null || Object.keys(actor.links).length === 0) {
return { height: 0, width: 0 };
@@ -39,21 +51,11 @@ export const drawPopup = function (elem, actor, minMenuWidth, textAttrs, forceMe
displayValue = 'block !important';
}
// const a = function () {
// popupMenuUpFunc('actor' + actorCnt + '_popup');
// };
// const b = function () {
// popupMenuDownFunc('actor' + actorCnt + '_popup');
// };
const g = elem.append('g');
g.attr('id', 'actor' + actorCnt + '_popup');
g.attr('class', 'actorPopupMenu');
g.attr('display', displayValue);
g.attr('onmouseover', popupMenu('actor' + actorCnt + '_popup'));
g.attr('onmouseout', popdownMenu('actor' + actorCnt + '_popup'));
// g.on('onmouseover', a);
// g.on('onmouseout', b);
addPopupInteraction('#actor' + actorCnt + '_popup', actorCnt);
var actorClass = '';
if (typeof rectData.class !== 'undefined') {
actorClass = ' ' + rectData.class;
@@ -342,15 +344,10 @@ const drawActorTypeParticipant = function (elem, actor, conf) {
g = boxpluslineGroup.append('g');
actor.actorCnt = actorCnt;
// const a = function () {
// popupMenuUpFunc('actor' + actorCnt + '_popup');
// };
// const b = function () {
// popupMenuDownFunc('actor' + actorCnt + '_popup');
// };
if (actor.links != null) {
g.attr('onmouseover', popupMenu('actor' + actorCnt + '_popup'));
g.attr('onmouseout', popdownMenu('actor' + actorCnt + '_popup'));
g.attr('id', 'root-' + actorCnt);
addPopupInteraction('#root-' + actorCnt, actorCnt);
}
}
@@ -397,6 +394,7 @@ const drawActorTypeParticipant = function (elem, actor, conf) {
actor.height = bounds.height;
height = bounds.height;
}
return height;
};