(function () { var md = window.markdownit({ html: true, linkify: true, typographer: true, highlight: function (str, lang) { if (lang && hljs.getLanguage(lang)) { try { return '
' +
                        hljs.highlight(lang, str, true).value +
                        '
'; } catch (__) {} } return '
' + md.utils.escapeHtml(str) + '
'; } }); function scrollToLint(lintId) { var target = document.getElementById(lintId); if (!target) { return; } target.scrollIntoView(); } function scrollToLintByURL($scope) { var removeListener = $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) { scrollToLint(window.location.hash.slice(1)); removeListener(); }); } function selectGroup($scope, selectedGroup) { var groups = $scope.groups; for (var group in groups) { if (groups.hasOwnProperty(group)) { if (group === selectedGroup) { groups[group] = true; } else { groups[group] = false; } } } } angular.module("clippy", []) .filter('markdown', function ($sce) { return function (text) { return $sce.trustAsHtml( md.render(text || '') // Oh deer, what a hack :O .replace(' minorVersion) { return false; } break; default: return true } } } return true; } $scope.byGroups = function (lint) { return $scope.groups[lint.group]; }; $scope.bySearch = function (lint, index, array) { let searchStr = $scope.search; // It can be `null` I haven't missed this value if (searchStr == null || searchStr.length < 3) { return true; } searchStr = searchStr.toLowerCase(); if (searchStr.startsWith("clippy::")) { searchStr = searchStr.slice(8); } // Search by id if (lint.id.indexOf(searchStr.replace("-", "_")) !== -1) { return true; } // Search the description // The use of `for`-loops instead of `foreach` enables us to return early let terms = searchStr.split(" "); let docsLowerCase = lint.docs.toLowerCase(); for (index = 0; index < terms.length; index++) { // This is more likely and will therefor be checked first if (docsLowerCase.indexOf(terms[index]) !== -1) { continue; } if (lint.id.indexOf(terms[index]) !== -1) { continue; } return false; } return true; } $scope.copyToClipboard = function (lint) { const clipboard = document.getElementById("clipboard-" + lint.id); if (clipboard) { let resetClipboardTimeout = null; let resetClipboardIcon = clipboard.innerHTML; function resetClipboard() { resetClipboardTimeout = null; clipboard.innerHTML = resetClipboardIcon; } navigator.clipboard.writeText("clippy::" + lint.id); clipboard.innerHTML = "✓"; if (resetClipboardTimeout !== null) { clearTimeout(resetClipboardTimeout); } resetClipboardTimeout = setTimeout(resetClipboard, 1000); } } // Get data $scope.open = {}; $scope.loading = true; // This will be used to jump into the source code of the version that this documentation is for. $scope.docVersion = window.location.pathname.split('/')[2] || "master"; if (window.location.hash.length > 1) { $scope.search = window.location.hash.slice(1); $scope.open[window.location.hash.slice(1)] = true; scrollToLintByURL($scope); } $http.get('./lints.json') .success(function (data) { $scope.data = data; $scope.loading = false; var selectedGroup = getQueryVariable("sel"); if (selectedGroup) { selectGroup($scope, selectedGroup.toLowerCase()); } scrollToLintByURL($scope); setTimeout(function () { var el = document.getElementById('filter-input'); if (el) { el.focus() } }, 0); }) .error(function (data) { $scope.error = data; $scope.loading = false; }); window.addEventListener('hashchange', function () { // trigger re-render $timeout(function () { $scope.levels = LEVEL_FILTERS_DEFAULT; $scope.search = window.location.hash.slice(1); $scope.open[window.location.hash.slice(1)] = true; scrollToLintByURL($scope); }); return true; }, false); }); })(); function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split('&'); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split('='); if (decodeURIComponent(pair[0]) == variable) { return decodeURIComponent(pair[1]); } } } function setTheme(theme, store) { let enableHighlight = false; let enableNight = false; let enableAyu = false; switch(theme) { case "ayu": enableAyu = true; break; case "coal": case "navy": enableNight = true; break; case "rust": enableHighlight = true; break; default: enableHighlight = true; theme = "light"; break; } document.getElementsByTagName("body")[0].className = theme; document.getElementById("styleHighlight").disabled = !enableHighlight; document.getElementById("styleNight").disabled = !enableNight; document.getElementById("styleAyu").disabled = !enableAyu; if (store) { try { localStorage.setItem('clippy-lint-list-theme', theme); } catch (e) { } } } // loading the theme after the initial load const prefersDark = window.matchMedia("(prefers-color-scheme: dark)"); const theme = localStorage.getItem('clippy-lint-list-theme'); if (prefersDark.matches && !theme) { setTheme("coal", false); } else { setTheme(theme, false); }