Commit 8a9d0309 authored by Lee Tickett's avatar Lee Tickett Committed by Clement Ho

Remove var from line_highlighter.js

parent dddffc66
/* 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'; import $ from 'jquery';
...@@ -82,13 +82,13 @@ LineHighlighter.prototype.highlightHash = function(newHash) { ...@@ -82,13 +82,13 @@ LineHighlighter.prototype.highlightHash = function(newHash) {
}; };
LineHighlighter.prototype.clickHandler = function(event) { LineHighlighter.prototype.clickHandler = function(event) {
var current, lineNumber, range; let range;
event.preventDefault(); event.preventDefault();
this.clearHighlight(); this.clearHighlight();
lineNumber = $(event.target) const lineNumber = $(event.target)
.closest('a') .closest('a')
.data('lineNumber'); .data('lineNumber');
current = this.hashToRange(this._hash); const current = this.hashToRange(this._hash);
if (!(current[0] && event.shiftKey)) { if (!(current[0] && event.shiftKey)) {
// If there's no current selection, or there is but Shift wasn't held, // If there's no current selection, or there is but Shift wasn't held,
// treat this like a single-line selection. // treat this like a single-line selection.
...@@ -121,12 +121,11 @@ LineHighlighter.prototype.clearHighlight = function() { ...@@ -121,12 +121,11 @@ LineHighlighter.prototype.clearHighlight = function() {
// //
// Returns an Array // Returns an Array
LineHighlighter.prototype.hashToRange = function(hash) { LineHighlighter.prototype.hashToRange = function(hash) {
var first, last, matches;
// ?L(\d+)(?:-(\d+))?$/) // ?L(\d+)(?:-(\d+))?$/)
matches = hash.match(/^#?L(\d+)(?:-(\d+))?$/); const matches = hash.match(/^#?L(\d+)(?:-(\d+))?$/);
if (matches && matches.length) { if (matches && matches.length) {
first = parseInt(matches[1], 10); const first = parseInt(matches[1], 10);
last = matches[2] ? parseInt(matches[2], 10) : null; const last = matches[2] ? parseInt(matches[2], 10) : null;
return [first, last]; return [first, last];
} else { } else {
return [null, null]; return [null, null];
...@@ -160,7 +159,7 @@ LineHighlighter.prototype.highlightRange = function(range) { ...@@ -160,7 +159,7 @@ LineHighlighter.prototype.highlightRange = function(range) {
// Set the URL hash string // Set the URL hash string
LineHighlighter.prototype.setHash = function(firstLineNumber, lastLineNumber) { LineHighlighter.prototype.setHash = function(firstLineNumber, lastLineNumber) {
var hash; let hash;
if (lastLineNumber) { if (lastLineNumber) {
hash = `#L${firstLineNumber}-${lastLineNumber}`; hash = `#L${firstLineNumber}-${lastLineNumber}`;
} else { } else {
......
---
title: Remove var from line_highlighter.js
merge_request: 20108
author: Lee Tickett
type: other
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment