forked from aboutcode-org/scancode-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.html
More file actions
264 lines (248 loc) · 10 KB
/
template.html
File metadata and controls
264 lines (248 loc) · 10 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<!DOCTYPE html>
<html lang="en">
{#
<!--
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/scancode-toolkit for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
-->
#}
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=UTF-8;charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ScanCode scan results for: {{ scanned_path }}</title>
<link href="{{ assets_dir }}/style.min.css" rel="stylesheet"/>
<link href="{{ assets_dir }}/bootstrap.min.css" rel="stylesheet"/>
<link href="{{ assets_dir }}/jquery.dataTables.min.css" rel="stylesheet"/>
<link href="{{ assets_dir }}/main.css" rel="stylesheet"/>
<link href="{{ assets_dir }}/simple-sidebar.css" rel="stylesheet"/>
<style type="text/css">
#tree {
max-height: 70vh;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<span class="navbar-brand icon-primary"><a href="https://github.com/nexB/scancode-toolkit/" target="_blank"><strong>ScanCode version {{ version }}</strong></a></span>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="{{ assets_dir }}/help.html" target="_blank">Help</a></li>
<li><a href="http://www.nexb.com" target="_blank">Made by nexB</a></li>
</ul>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="row" id = "scan-result-header">
<div class="col-md-4">
<strong>scan results for:</strong>
</div>
<div class = "col-md-8" id = "file-path">
<p>{{ scanned_path }}</p>
</div>
</div>
<div class="col-md-4" id="leftCol">
<div id="tree" style="overflow-x:scroll; overflow-y:auto;"></div>
</div>
<div id="tabbar" class="col-md-8">
<ul class="nav nav-tabs">
<li id="tab4" class="active"><a data-toggle="tab" href="#chart">License Summary</a></li>
<li id="tab5"><a data-toggle="tab" href="#">Copyright Summary</a></li>
<li id="tab1"><a data-toggle="tab" href="#">Clues</a></li>
<li id="tab2"><a data-toggle="tab" href="#">File Details</a></li>
<li id="tab3"><a data-toggle="tab" href="#">Packages</a></li>
</ul>
<div id="summary">
<p class="total-files"></p>
<svg class="chart"></svg>
</div>
<div id="details">
<table id="data_table" class="data_table display table-wrap" cellspacing="0" width="100%"></table>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container-fluid">
<p class="text-muted">Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
No content created from ScanCode should be considered or used as legal advice. Consult an Attorney for any legal advice.
ScanCode is a free software code scanning tool from nexB Inc. and others.
Visit <a href="http://www.nexb.com/" target="_blank">http://www.nexb.com</a> and <a href="https://github.com/nexB/scancode-toolkit/" target="_blank">https://github.com/nexB/scancode-toolkit/</a> for support and download.
</p>
</div>
</footer>
<script src="{{ assets_dir }}/jquery.min.js"></script>
<script src="{{ assets_dir }}/bootstrap.min.js"></script>
<script src="{{ assets_dir }}/jstree.min.js"></script>
<script src="{{ assets_dir }}/jquery.dataTables.min.js"></script>
<script src="{{ assets_dir }}/d3.min.js" charset="utf-8"></script>
<script src="{{ assets_dir }}/chart.js"></script>
<script src="{{ assets_dir }}/scancode_jstree.js"></script>
<script src="{{ assets_dir }}/scancode_datatable.js"></script>
<script type="text/javascript" src="{{ assets_dir }}/data.js"></script>
<script type="text/javascript">
var dataArray = data;
var currNodeData = null;
var chartOptions = {
name: "License Summary",
margin: 30,
barHeight: 25,
xAxisName: "License Count",
yAxisName: "License Name"
};
// Prepare data for tree and table
$( document ).ready(function() {
// Setup JSTree
var scancodeJSTree = new ScancodeJSTree('#tree', dataArray)
.onNodeSelected(function(e, nodeData) {
// Redraw data table (forces custom filter to rerun)
// TODO: Figure out the tab and only update that table instead of all
table = $('#data_table').DataTable();
table.draw();
currNodeData = nodeData;
resetChartSelect();
});
// Setup DataTable
var scancodeDataTable = new ScancodeDataTable('#data_table', dataArray)
.addFilter(function( settings, data, dataIndex ) {
// Get selected ID in tree
var id = $('#tree').jstree('get_selected')[0];
// keep if column 0 starts with ID (i.e., indexOf(id) == 0)
return id == null || data[0].indexOf(id + '/') == 0 || data[0] == id;
});
$('#button').click(function(){ $('#data_table').toggleClass('ellipsis'); })
// Setup BarChart
var chartData = formatLicenseChartData(data);
var barChart = new BarChart(chartData, chartOptions, '.chart');
$(window).on('resize', barChart.draw);
// Setup Tabs
$( "#tab1" ).click(function() {
$('#details').show();
$('#summary').hide();
scancodeDataTable.showLicenseAndCopyright();
});
$( "#tab2" ).click(function() {
$('#details').show();
$('#summary').hide();
scancodeDataTable.showFileInfo();
});
$( "#tab3" ).click(function() {
$('#details').show();
$('#summary').hide();
scancodeDataTable.showPkgInfo();
});
$("#tab4").click(function() {
$('#details').hide();
$('#summary').show();
resetChart(formatLicenseChartData(filteredData(currNodeData)));
});
$("#tab5").click(function() {
$('#details').hide();
$('#summary').show();
resetChart(formatCopyrightChartData(filteredData(currNodeData)));
});
$("#details").hide();
function resetChartSelect() {
if ($('#tab4').hasClass('active')) {
resetChart(formatLicenseChartData(filteredData(currNodeData)));
} else if($('#tab5').hasClass('active')){
resetChart(formatCopyrightChartData(filteredData(currNodeData)));
}
}
function resetChart(chartData) {
barChart.remove();
barChart = new BarChart(chartData, chartOptions, '.chart');
}
});
// filter the data
function filteredData(nodeData){
if (nodeData == null) {
return data;
}
return $.map(data, function(item){
var pattern = '^' + nodeData.selected[0];
pattern += nodeData.node.children.length > 0 ? '/' : '';
if (item.path.match(pattern)){
return item;
} else {
return;
}
});
}
function formatLicenseChartData(data){
var NO_LICENSES = [{short_name: 'No License Found'}];
// Get license short name and if no license set it to No License Found
var shortNames = $.map(data, function(item){
var licenses;
if (!('licenses' in item)) {
return;
} else if (item.licenses.length > 0) {
licenses = item.licenses;
} else {
licenses = NO_LICENSES;
}
return $.map(licenses, function(license) {
return license.short_name;
});
});
// Get the total number of files
var totalFiles = data.length;
$( "p.total-files" ).text( "Total Files Scanned: " + totalFiles );
return formatChartData(shortNames)
}
function formatCopyrightChartData(data){
var NO_COPYRIGHT = [{holders: ['No Copyright Found']}];
// Get copyright holder and if none set it to No Copyright Found
var holderNames = $.map(data, function(item){
var holders;
if (!('holders' in item)) {
return;
} else if (item.holders.length > 0) {
holders = item.holders;
} else {
holders = NO_COPYRIGHT;
}
return $.map(holders, function(holder) {
return holder.value;
});
});
// Get the total number of files
var totalFiles = data.length;
$( "p.total-files" ).text( "Total Files Scanned: " + totalFiles );
return formatChartData(holderNames)
}
function formatChartData(names) {
// Sum the total number of times the name appears
var count = {};
$.each(names, function(i, name){
count[name] = count[name] + 1 || 1;
});
// Transform license count into array of objects with license name & count
var chartData = $.map(count, function(val, key) {
return {
name: key.substr(0, 80),
val: val
};
});
// Sorts the data highest value to lowest value
chartData.sort(function(a,b){
if (a.val == b.val) {
return a.name.localeCompare(b.name);
} else {
return a.val > b.val ? -1 : 1;
}
});
return chartData;
}
</script>
</body>
</html>