Skip to content

Commit 85255f7

Browse files
committed
Change scope of JS functions
1 parent d00bf68 commit 85255f7

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

resources/js/project-report.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
/*
22
This is what's included in project_diff_report.html
33
to make the violation table work.
4+
5+
It depends on the `project` global var, which is generated
6+
in another JS file by LiquidProjectRenderer
47
*/
58

6-
function makeCodeLink(violation) {
7-
let template = project.source_link_template
8-
template = template.replace('{file}', project.file_index[violation.f])
9-
template = template.replace('{line}', violation.l);
10-
return template
11-
}
9+
$(document).ready(function () {
10+
11+
function makeCodeLink(violation) {
12+
let template = project.source_link_template
13+
template = template.replace('{file}', project.file_index[violation.f])
14+
template = template.replace('{line}', violation.l);
15+
return template
16+
}
1217

13-
function extractFilename(path) {
14-
const pathArray = path.split("/");
15-
return pathArray[pathArray.length - 1];
16-
}
18+
function extractFilename(path) {
19+
const pathArray = path.split("/");
20+
return pathArray[pathArray.length - 1];
21+
}
1722

18-
const cssClass = {
19-
"+": "added",
20-
"-": "removed",
21-
"~": "changed",
22-
}
23+
const cssClass = {
24+
"+": "added",
25+
"-": "removed",
26+
"~": "changed",
27+
}
2328

24-
const typeDisplay = {
25-
"+": "Added",
26-
"-": "Removed",
27-
"~": "Changed",
28-
}
29+
const typeDisplay = {
30+
"+": "Added",
31+
"-": "Removed",
32+
"~": "Changed",
33+
}
2934

30-
$(document).ready(function () {
3135
$('#violationsTable').DataTable({
3236
data: project.violations,
3337
columns: [

0 commit comments

Comments
 (0)