Skip to content

Commit

Permalink
Addressing code style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreywolf committed Jan 2, 2020
1 parent e6fbfcb commit 7f31e62
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/diagrams/class/classDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const setClickFunc = function(_id, functionName, tooltip) {
funs.push(function() {
const elem = document.querySelector(`[id="${elemId}"]`);
if (elem !== null) {

elem.addEventListener(
'click',
function() {
Expand Down
5 changes: 1 addition & 4 deletions src/diagrams/class/classRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ parser.yy = classDb;
const MERMAID_DOM_ID_PREFIX = 'classid-';
let idCache = {};

let classCnt = 0;
const conf = {
dividerMargin: 10,
padding: 5,
Expand Down Expand Up @@ -433,8 +432,7 @@ const drawClass = function(elem, classDef) {
});

if (classDef.tooltip) {
const tooltip = title
.insert('title')
title.insert('title')
.text(classDef.tooltip);
}

Expand All @@ -445,7 +443,6 @@ const drawClass = function(elem, classDef) {
classInfo.height = classBox.height + conf.padding + 0.5 * conf.dividerMargin;

idCache[id] = classInfo;
classCnt++;
return classInfo;
};

Expand Down
13 changes: 6 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,20 @@ export const sanitize = (text, config) => {
};

export const formatUrl = (linkStr, config) => {
let url = linkStr;
let url = linkStr.trim();

if (config.securityLevel !== 'loose') {
return sanitizeUrl(url);
} else {
url = url.trim();
if (!!url) {
if (url) {
if (config.securityLevel !== 'loose') {
return sanitizeUrl(url);
} else {
if (!/^(https?:)?\/\//i.test(url)) {
url = 'http://' + url;
}
}

return url;
}
}
};

const distance = (p1, p2) =>
p1 && p2 ? Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)) : 0;
Expand Down

0 comments on commit 7f31e62

Please sign in to comment.