forked from fzaninotto/CodeFlower
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
119 lines (113 loc) · 4.09 KB
/
index.html
File metadata and controls
119 lines (113 loc) · 4.09 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<!-- Use the Source, Luke -->
<head>
<title>Swarmbase: Visualize Source code</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link type="text/css" rel="stylesheet" href="stylesheets/bootstrap.min.css"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="stylesheets/bootstrap-responsive.min.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Rosario:400,700' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="stylesheets/style.css"/>
<style type="text/css">
circle.node {
cursor: pointer;
stroke: #000;
stroke-width: .5px;
}
circle.node.directory {
stroke: #9ecae1;
stroke-width: 2px;
}
circle.node.collapsed {
stroke: #555;
}
.nodetext {
fill: #252929;
font-weight: bold;
text-shadow: 0 0 0.2em white;
}
line.link {
fill: none;
stroke: #9ecae1;
stroke-width: 1.5px;
}
</style>
</head>
<body>
<div class="content">
<div class="container">
<form class="form-inline">
<fieldset>
<label>Data source:</label>
<select id="project">
<option value="data/swarmbase.json">swarmbase / swarmbase</option>
</select>
</fieldset>
</form>
<h1>Source code visualization</h1>
<div id="visualization"></div>
<h2>Input data</h2>
<form id="jsonInput">
<fieldset>
<textarea id="jsonData"></textarea>
<div class="pull-right">
<button type="submit" class="btn btn-primary btn-large">Update</button>
</div>
</fieldset>
</form>
<h2>Convert CLOC to JSON</h2>
<form id="jsonConverter">
<fieldset>
<select name="origin">
<option value="cloc" selected>Origin: cloc</option>
<option value="ws">Origin: wc</option>
</select>
<textarea id="metricsData"></textarea>
<div class="pull-right">
<button type="submit" class="btn btn-primary btn-large">Convert</button>
</div>
</fieldset>
</form>
</div>
</div>
<script type="text/javascript" src="javascripts/d3/d3.js"></script>
<script type="text/javascript" src="javascripts/d3/d3.geom.js"></script>
<script type="text/javascript" src="javascripts/d3/d3.layout.js"></script>
<script type="text/javascript" src="javascripts/CodeFlower.js"></script>
<script type="text/javascript" src="javascripts/dataConverter.js"></script>
<script type="text/javascript">
var currentCodeFlower;
var createCodeFlower = function(json) {
// update the jsonData textarea
document.getElementById('jsonData').value = JSON.stringify(json);
// remove previous flower to save memory
if (currentCodeFlower) currentCodeFlower.cleanup();
// adapt layout size to the total number of elements
// var total = countElements(json);
// w = parseInt(Math.sqrt(total) * 30, 10);
// h = parseInt(Math.sqrt(total) * 30, 10);
// element count resulted in unused screen area
const w = parseInt(window.innerWidth * .7, 10)
const h = parseInt(window.innerWidth * .7, 10)
// create a new CodeFlower
currentCodeFlower = new CodeFlower("#visualization", w, h).update(json);
};
d3.json('data.json', createCodeFlower);
document.getElementById('jsonInput').addEventListener('submit', function(e) {
e.preventDefault();
document.getElementById('visualization').scrollIntoView();
var json = JSON.parse(document.getElementById('jsonData').value);
currentCodeFlower.update(json);
});
document.getElementById('jsonConverter').addEventListener('submit', function(e) {
e.preventDefault();
var origin = this.children[0].children[0].value;
var data = this.children[0].children[1].value;
var json = convertToJSON(data, origin);
document.getElementById('visualization').scrollIntoView();
createCodeFlower(json);
});
</script>
</body>
</html>