diff options
Diffstat (limited to 'app/assets/javascripts/line_highlighter.js')
-rw-r--r-- | app/assets/javascripts/line_highlighter.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/app/assets/javascripts/line_highlighter.js b/app/assets/javascripts/line_highlighter.js index b6b96fe7bd5..dd868bb9f4c 100644 --- a/app/assets/javascripts/line_highlighter.js +++ b/app/assets/javascripts/line_highlighter.js @@ -1,4 +1,4 @@ -/* eslint-disable func-names, no-var, no-underscore-dangle, no-param-reassign, consistent-return, one-var, no-else-return */ +/* eslint-disable func-names, no-underscore-dangle, no-param-reassign, consistent-return, no-else-return */ import $ from 'jquery'; @@ -82,13 +82,13 @@ LineHighlighter.prototype.highlightHash = function(newHash) { }; LineHighlighter.prototype.clickHandler = function(event) { - var current, lineNumber, range; + let range; event.preventDefault(); this.clearHighlight(); - lineNumber = $(event.target) + const lineNumber = $(event.target) .closest('a') .data('lineNumber'); - current = this.hashToRange(this._hash); + const current = this.hashToRange(this._hash); if (!(current[0] && event.shiftKey)) { // If there's no current selection, or there is but Shift wasn't held, // treat this like a single-line selection. @@ -121,12 +121,11 @@ LineHighlighter.prototype.clearHighlight = function() { // // Returns an Array LineHighlighter.prototype.hashToRange = function(hash) { - var first, last, matches; // ?L(\d+)(?:-(\d+))?$/) - matches = hash.match(/^#?L(\d+)(?:-(\d+))?$/); + const matches = hash.match(/^#?L(\d+)(?:-(\d+))?$/); if (matches && matches.length) { - first = parseInt(matches[1], 10); - last = matches[2] ? parseInt(matches[2], 10) : null; + const first = parseInt(matches[1], 10); + const last = matches[2] ? parseInt(matches[2], 10) : null; return [first, last]; } else { return [null, null]; @@ -160,7 +159,7 @@ LineHighlighter.prototype.highlightRange = function(range) { // Set the URL hash string LineHighlighter.prototype.setHash = function(firstLineNumber, lastLineNumber) { - var hash; + let hash; if (lastLineNumber) { hash = `#L${firstLineNumber}-${lastLineNumber}`; } else { |