Skip to content

Commit bdf8089

Browse files
committed
Add an ESLint config for use with datatracker javascript and apply it to
document_timeline.js. Also, I consider the graphical timeline stuff stable, so I'll use this commit to say: Branch ready for merge. - Legacy-Id: 10566
1 parent 0f1c823 commit bdf8089

2 files changed

Lines changed: 31 additions & 9 deletions

File tree

.eslintrc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
rules: {
3+
indent: [2, 4],
4+
camelcase: 0,
5+
"require-jsdoc": 0,
6+
quotes: [2, "double"],
7+
"no-multiple-empty-lines": [2, {max: 2}],
8+
"quote-props": [2, "as-needed"],
9+
"brace-style": [2, "1tbs", {allowSingleLine: true}]
10+
},
11+
env: {
12+
browser: true,
13+
jquery: true
14+
},
15+
globals: {
16+
d3: true
17+
},
18+
extends: "google"
19+
};

ietf/static/ietf/js/document_timeline.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ var width;
1010

1111
function offset(d, i) {
1212
// increase the y offset if the document name changed in this revision
13-
if (i > 0 && data[i - 1].name !== d.name || d.rev.match("^rfc\d+$"))
13+
if (i > 0 && data[i - 1].name !== d.name || d.rev.match("^rfc\d+$")) {
1414
bar_y += bar_height;
15+
}
1516
return "translate(" + x_scale(d.published) + ", " + bar_y + ")";
1617
}
1718

1819

1920
function bar_width(d, i) {
20-
if (i < data.length - 1)
21+
if (i < data.length - 1) {
2122
return x_scale(data[i + 1].published) - x_scale(d.published);
23+
}
2224
}
2325

2426

@@ -62,8 +64,9 @@ function draw_timeline() {
6264
bar_height = parseFloat($("body").css("line-height"));
6365

6466
var div = $("#timeline");
65-
if (div.is(":empty"))
67+
if (div.is(":empty")) {
6668
div.append("<svg></svg>");
69+
}
6770
var chart = d3.select("#timeline svg").attr("width", width);
6871

6972
var gradient = chart.append("defs")
@@ -120,7 +123,7 @@ function draw_timeline() {
120123
g.append("text")
121124
.attr({
122125
x: 3,
123-
y: bar_height/2
126+
y: bar_height / 2
124127
})
125128
.text(function(d) { return d.rev; });
126129

@@ -146,7 +149,7 @@ function draw_timeline() {
146149
chart.append("g")
147150
.attr({
148151
class: "y axis",
149-
transform: "translate(10, " + bar_height/2 + ")"
152+
transform: "translate(10, " + bar_height / 2 + ")"
150153
})
151154
.call(y_axis)
152155
.selectAll("text")
@@ -162,17 +165,17 @@ function draw_timeline() {
162165

163166

164167
d3.json("doc.json", function(error, json) {
165-
if (error) return;
166-
data = json["rev_history"];
168+
if (error) { return; }
169+
data = json.rev_history;
167170

168171
if (data.length) {
169172
// make js dates out of publication dates
170173
data.forEach(function(d) { d.published = new Date(d.published); });
171174

172175
// add pseudo entry 185 days after last rev (when the ID will expire)
173176
var pseudo = new Date(data[data.length - 1].published.getTime() +
174-
1000*60*60*24*185);
175-
data.push({ name: "", rev: "", published: pseudo});
177+
1000 * 60 * 60 * 24 * 185);
178+
data.push({name: "", rev: "", published: pseudo});
176179
draw_timeline();
177180
}
178181
});

0 commit comments

Comments
 (0)