Skip to content

Commit 06897c2

Browse files
committed
mirrors: prefer template literal strings for JavaScript
1 parent ab93906 commit 06897c2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

mirrors/static/mirror_status.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function mirror_status(container_id, check_loc, log_data, color) {
3939
.attr("width", width + margin.left + margin.right)
4040
.attr("height", height + margin.top + margin.bottom)
4141
.append("g")
42-
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
42+
.attr("transform", `translate(${margin.left},${margin.top})`);
4343

4444
x.domain([
4545
d3.min(data, function(c) { return d3.min(c.logs, function(v) { return v.check_time; }); }),
@@ -53,7 +53,7 @@ function mirror_status(container_id, check_loc, log_data, color) {
5353
/* build the axis lines... */
5454
svg.append("g")
5555
.attr("class", "x axis")
56-
.attr("transform", "translate(0," + height + ")")
56+
.attr("transform", `translate(0,${height})`)
5757
.call(x_axis)
5858
.append("text")
5959
.attr("class", "label")
@@ -100,15 +100,15 @@ function mirror_status(container_id, check_loc, log_data, color) {
100100
.attr("cy", function(d) { return y(d.duration); })
101101
.style("fill", function(d) { return color(d.url); })
102102
.append("title")
103-
.text(function(d) { return d.url + "\n" + d.duration.toFixed(3) + " secs\n" + d.check_time.toUTCString(); });
103+
.text(function(d) { return `${d.url}\n${d.duration.toFixed(3)} secs\n${d.check_time.toUTCString()}`; });
104104

105105
/* add a legend for good measure */
106106
const active = data.map(item => item.url);
107107
const legend = svg.selectAll(".legend")
108108
.data(active)
109109
.enter().append("g")
110110
.attr("class", "legend")
111-
.attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; });
111+
.attr("transform", function(d, i) { return `translate(0,${i * 20})`; });
112112

113113
legend.append("rect")
114114
.attr("x", width - 18)
@@ -162,15 +162,15 @@ function mirror_status(container_id, check_loc, log_data, color) {
162162
}
163163

164164
/* create the containers, defer the actual graph drawing */
165-
const chart_id = 'status-chart-' + check_loc.id;
165+
const chart_id = `status-chart-${check_loc.id}`;
166166
const container = document.querySelector(container_id);
167167
const fragment = document.createDocumentFragment();
168168
const title = document.createElement("h3");
169169
const span = document.createElement("span");
170170
span.setAttribute("class", `fam-flag fam-flag-${check_loc.country_code.toLowerCase()}`);
171171
span.setAttribute("title", check_loc.country);
172172
title.appendChild(span);
173-
title.innerHTML = title.innerHTML + ` ${check_loc.country} (${check_loc.source_ip}), IPv${check_loc.ip_version}`
173+
title.innerHTML = `${title.innerHTML} ${check_loc.country} (${check_loc.source_ip}), IPv${check_loc.ip_version}`
174174
fragment.appendChild(title);
175175
const chart_div = document.createElement("div");
176176
chart_div.setAttribute("id", chart_id);
@@ -181,14 +181,14 @@ function mirror_status(container_id, check_loc, log_data, color) {
181181
container.appendChild(fragment);
182182

183183
setTimeout(function() {
184-
draw_graph('#' + chart_id, cached_data);
184+
draw_graph(`#${chart_id}`, cached_data);
185185
}, 0);
186186

187187
/* then hook up a resize handler to redraw if necessary */
188188
var resize_timeout = null;
189189
const real_resize = function() {
190190
resize_timeout = null;
191-
draw_graph('#' + chart_id, cached_data);
191+
draw_graph(`#${chart_id}`, cached_data);
192192
};
193193
window.addEventListener('resize', function() {
194194
if (resize_timeout) {

0 commit comments

Comments
 (0)