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
This commit is contained in:
Lars Eggert 2015-12-10 09:02:58 +00:00
parent 0f1c823a6e
commit bdf8089688
2 changed files with 31 additions and 9 deletions

19
.eslintrc.js Normal file
View file

@ -0,0 +1,19 @@
module.exports = {
rules: {
indent: [2, 4],
camelcase: 0,
"require-jsdoc": 0,
quotes: [2, "double"],
"no-multiple-empty-lines": [2, {max: 2}],
"quote-props": [2, "as-needed"],
"brace-style": [2, "1tbs", {allowSingleLine: true}]
},
env: {
browser: true,
jquery: true
},
globals: {
d3: true
},
extends: "google"
};

View file

@ -10,16 +10,18 @@ var width;
function offset(d, i) {
// increase the y offset if the document name changed in this revision
if (i > 0 && data[i - 1].name !== d.name || d.rev.match("^rfc\d+$"))
if (i > 0 && data[i - 1].name !== d.name || d.rev.match("^rfc\d+$")) {
bar_y += bar_height;
}
return "translate(" + x_scale(d.published) + ", " + bar_y + ")";
}
function bar_width(d, i) {
if (i < data.length - 1)
if (i < data.length - 1) {
return x_scale(data[i + 1].published) - x_scale(d.published);
}
}
function scale_x() {
@ -62,8 +64,9 @@ function draw_timeline() {
bar_height = parseFloat($("body").css("line-height"));
var div = $("#timeline");
if (div.is(":empty"))
if (div.is(":empty")) {
div.append("<svg></svg>");
}
var chart = d3.select("#timeline svg").attr("width", width);
var gradient = chart.append("defs")
@ -162,8 +165,8 @@ function draw_timeline() {
d3.json("doc.json", function(error, json) {
if (error) return;
data = json["rev_history"];
if (error) { return; }
data = json.rev_history;
if (data.length) {
// make js dates out of publication dates