-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
65 lines (59 loc) · 1.85 KB
/
app.js
File metadata and controls
65 lines (59 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var cddec, cdcon, canvas, chart;
var opts = {
'line-width': 3,
'maxWidth': 90,
'line-length': 50,
'text-margin': 10,
'font-size': 14,
'font-weight':'bold',
'font-color': 'rbg(60,60,60)',
// 'font': 'normal',
// 'font-family': 'calibri',
// 'font-weight': 'normal',
'line-color': 'rbg(60,60,60)',
'element-color': 'rbg(60,60,60)',
'fill': 'rgb(243,243,243)',
'yes-text': 'Yes',
'no-text': 'No',
'arrow-end': 'block',
'scale': 1
};
window.onload = function () {
cddec = document.getElementById("code-declare");
cdcon = document.getElementById("code-connect");
canvas = document.getElementById("canvas");
cdcon.oninput = cddec.oninput = function () {
updateChart();
}
updateChart();//calling initially to load demo chart
};
function PrintDiv() {
var div = document.getElementById("canvas").children[0];
(function saveSvg(svgEl, name) {
svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
var svgData = svgEl.outerHTML;
var preface = '<?xml version="1.0" standalone="no"?>\r\n';
var svgBlob = new Blob([preface, svgData], { type: "image/svg+xml;charset=utf-8" });
var svgUrl = URL.createObjectURL(svgBlob);
var downloadLink = document.createElement("a");
downloadLink.href = svgUrl;
downloadLink.download = name;
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
})(div, "flowchart.svg");
}
function updateChart() {
try {
var code = cddec.value + "\n" + cdcon.value;
if (chart) {
canvas.innerHTML = '';
}
chart = flowchart.parse(code);
chart.drawSVG('canvas',opts);
}
catch (err) {
chart = document.getElementById("canvas");
console.log(err);
}
}