forked from pslacerda/CobolCallGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
89 lines (88 loc) · 4.36 KB
/
index.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<html>
<head>
<title>CCGraph</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<a href="https://github.com/pslacerda/CobolCallGraph"><img src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<section id=controls>
<button onclick="generateDot()">Generate dot graph</button>
<button onclick="generateD3()">Generate d3.js graph</button>
<button onclick="generateExample(program_1, 1)">Example of DOT graph</button>
<button onclick="generateExample(program_1, 2)">Example of d3.js graph</button>
<input type="text" placeholder="Search" />
<section>
<div id=drawarea>
<p>
<h3>Click on button Load to choose your Cobol source file</h3>
</p>
</div>
<footer>
<a href="https://github.com/pslacerda/CobolCallGraph">Project source on GitHub</a><br>
<a href="test.html">Unit Tests</a>
</footer>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/viz.js/1.8.0/viz.js"></script>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src=examples.js></script>
<script src=ccgraph.js></script>
<script src=d3.js></script>
<script src=file_read.js></script>
<script>
const config = {
duplicated_call: false,
program_name: false,
};
d3generator.setSearchInput('input');
function generateExample(source, type = 1) {
let drawarea = document.querySelector('#drawarea');
drawarea.innerHTML = "<h3>Loading...</h3>";
let tree = parseCallGraph(source, config.duplicated_call, config.program_name, {});
if ( type === 1 ) {
var dot = generateDotFile(tree);
var result = Viz(dot, {format: 'svg'});
drawarea.innerHTML = result;
} else {
let tree = parseCallGraph(source, config.duplicated_call, config.program_name, {});
var nodes = {};
// Compute the distinct nodes from the links.
tree.edges = tree.edges.sort();
tree.edges.forEach(function(link) {
link.source = nodes[link.source] || (nodes[link.source] = {name: link.source});
link.target = nodes[link.target] || (nodes[link.target] = {name: link.target});
});
drawarea.innerHTML = "";
d3generator.draw(nodes, tree.edges);
}
}
function generateDot() {
let drawarea = document.querySelector('#drawarea');
drawarea.innerHTML = "<h3>Loading...</h3>";
loadLocalFile(function(fullText) {
try {
let tree = parseCallGraph(fullText, config.duplicated_call, config.program_name, {});
var dot = generateDotFile(tree);
var result = Viz(dot, {format: 'svg'});
drawarea.innerHTML = result;
} catch(e) {
alert(e.message);
}
});
}
function generateD3() {
let drawarea = document.querySelector('#drawarea');
drawarea.innerHTML = "<h3>Loading...</h3>";
loadLocalFile(function(fullText) {
let tree = parseCallGraph(fullText, config.duplicated_call, config.program_name, {});
var nodes = {};
// Compute the distinct nodes from the links.
tree.edges.forEach(function(link) {
link.source = nodes[link.source] || (nodes[link.source] = {name: link.source});
link.target = nodes[link.target] || (nodes[link.target] = {name: link.target});
});
drawarea.innerHTML = "";
d3generator.draw(nodes, tree.edges);
});
}
</script>
<html>