summaryrefslogtreecommitdiff
path: root/assets/js/components/comment-highlight.js
blob: cc0b9bc04f452f8f1e0f83ce3ab7120a02766479 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
KB.on('dom.ready', function () {
    function highlightComment() {
        if (window.location.hash.indexOf('#comment-') === 0) {
            var commentElement = KB.find(window.location.hash);

            if (commentElement) {
                var commentsElement = document.querySelectorAll('.comment');

                commentsElement.forEach(function (element) {
                    KB.dom(element).removeClass('comment-highlighted');
                });

                commentElement.addClass('comment-highlighted');
            }
        }
    }

    window.addEventListener('hashchange', highlightComment);

    highlightComment();
});