|
1 | 1 | (function () { |
2 | | - var md = window.markdownit({ |
| 2 | + const md = window.markdownit({ |
3 | 3 | html: true, |
4 | 4 | linkify: true, |
5 | 5 | typographer: true, |
|
17 | 17 | }); |
18 | 18 |
|
19 | 19 | function scrollToLint(lintId) { |
20 | | - var target = document.getElementById(lintId); |
| 20 | + const target = document.getElementById(lintId); |
21 | 21 | if (!target) { |
22 | 22 | return; |
23 | 23 | } |
24 | 24 | target.scrollIntoView(); |
25 | 25 | } |
26 | 26 |
|
27 | 27 | function scrollToLintByURL($scope, $location) { |
28 | | - var removeListener = $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) { |
| 28 | + const removeListener = $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) { |
29 | 29 | scrollToLint($location.path().substring(1)); |
30 | 30 | removeListener(); |
31 | 31 | }); |
32 | 32 | } |
33 | 33 |
|
34 | 34 | function selectGroup($scope, selectedGroup) { |
35 | | - var groups = $scope.groups; |
36 | | - for (var group in groups) { |
| 35 | + const groups = $scope.groups; |
| 36 | + for (const group in groups) { |
37 | 37 | if (groups.hasOwnProperty(group)) { |
38 | | - if (group === selectedGroup) { |
39 | | - groups[group] = true; |
40 | | - } else { |
41 | | - groups[group] = false; |
42 | | - } |
| 38 | + groups[group] = group === selectedGroup; |
43 | 39 | } |
44 | 40 | } |
45 | 41 | } |
|
108 | 104 | }) |
109 | 105 | .controller("lintList", function ($scope, $http, $location, $timeout) { |
110 | 106 | // Level filter |
111 | | - var LEVEL_FILTERS_DEFAULT = {allow: true, warn: true, deny: true, none: true}; |
| 107 | + const LEVEL_FILTERS_DEFAULT = {allow: true, warn: true, deny: true, none: true}; |
112 | 108 | $scope.levels = { ...LEVEL_FILTERS_DEFAULT }; |
113 | 109 | $scope.byLevels = function (lint) { |
114 | 110 | return $scope.levels[lint.level]; |
|
367 | 363 | } |
368 | 364 |
|
369 | 365 | $scope.clearVersionFilters = function () { |
370 | | - for (let filter in $scope.versionFilters) { |
| 366 | + for (const filter in $scope.versionFilters) { |
371 | 367 | $scope.versionFilters[filter] = { enabled: false, minorVersion: null }; |
372 | 368 | } |
373 | 369 | } |
|
378 | 374 |
|
379 | 375 | $scope.updateVersionFilters = function() { |
380 | 376 | for (const filter in $scope.versionFilters) { |
381 | | - let minorVersion = $scope.versionFilters[filter].minorVersion; |
| 377 | + const minorVersion = $scope.versionFilters[filter].minorVersion; |
382 | 378 |
|
383 | 379 | // 1.29.0 and greater |
384 | 380 | if (minorVersion && minorVersion > 28) { |
|
391 | 387 | } |
392 | 388 |
|
393 | 389 | $scope.byVersion = function(lint) { |
394 | | - let filters = $scope.versionFilters; |
| 390 | + const filters = $scope.versionFilters; |
395 | 391 | for (const filter in filters) { |
396 | 392 | if (filters[filter].enabled) { |
397 | | - let minorVersion = filters[filter].minorVersion; |
| 393 | + const minorVersion = filters[filter].minorVersion; |
398 | 394 |
|
399 | 395 | // Strip the "pre " prefix for pre 1.29.0 lints |
400 | | - let lintVersion = lint.version.startsWith("pre ") ? lint.version.substring(4, lint.version.length) : lint.version; |
401 | | - let lintMinorVersion = lintVersion.substring(2, 4); |
| 396 | + const lintVersion = lint.version.startsWith("pre ") ? lint.version.substring(4, lint.version.length) : lint.version; |
| 397 | + const lintMinorVersion = lintVersion.substring(2, 4); |
402 | 398 |
|
403 | 399 | switch (filter) { |
404 | 400 | // "=" gets the highest priority, since all filters are inclusive |
|
441 | 437 |
|
442 | 438 | // Search the description |
443 | 439 | // The use of `for`-loops instead of `foreach` enables us to return early |
444 | | - let terms = searchStr.split(" "); |
445 | | - let docsLowerCase = lint.docs.toLowerCase(); |
| 440 | + const terms = searchStr.split(" "); |
| 441 | + const docsLowerCase = lint.docs.toLowerCase(); |
446 | 442 | for (index = 0; index < terms.length; index++) { |
447 | 443 | // This is more likely and will therefore be checked first |
448 | 444 | if (docsLowerCase.indexOf(terms[index]) !== -1) { |
|
479 | 475 | const clipboard = document.getElementById("clipboard-" + lint.id); |
480 | 476 | if (clipboard) { |
481 | 477 | let resetClipboardTimeout = null; |
482 | | - let resetClipboardIcon = clipboard.innerHTML; |
| 478 | + const resetClipboardIcon = clipboard.innerHTML; |
483 | 479 |
|
484 | 480 | function resetClipboard() { |
485 | 481 | resetClipboardTimeout = null; |
|
511 | 507 | $scope.data = data; |
512 | 508 | $scope.loading = false; |
513 | 509 |
|
514 | | - var selectedGroup = getQueryVariable("sel"); |
| 510 | + const selectedGroup = getQueryVariable("sel"); |
515 | 511 | if (selectedGroup) { |
516 | 512 | selectGroup($scope, selectedGroup.toLowerCase()); |
517 | 513 | } |
518 | 514 |
|
519 | 515 | scrollToLintByURL($scope, $location); |
520 | 516 |
|
521 | 517 | setTimeout(function () { |
522 | | - var el = document.getElementById('filter-input'); |
| 518 | + const el = document.getElementById('filter-input'); |
523 | 519 | if (el) { el.focus() } |
524 | 520 | }, 0); |
525 | 521 | }) |
|
531 | 527 | })(); |
532 | 528 |
|
533 | 529 | function getQueryVariable(variable) { |
534 | | - var query = window.location.search.substring(1); |
535 | | - var vars = query.split('&'); |
536 | | - for (var i = 0; i < vars.length; i++) { |
537 | | - var pair = vars[i].split('='); |
| 530 | + const query = window.location.search.substring(1); |
| 531 | + const vars = query.split('&'); |
| 532 | + for (const entry of vars) { |
| 533 | + const pair = entry.split('='); |
538 | 534 | if (decodeURIComponent(pair[0]) == variable) { |
539 | 535 | return decodeURIComponent(pair[1]); |
540 | 536 | } |
|
0 commit comments