File size: 1,937 Bytes
046723b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function redirectToVersion(version) {
    var currentUrl = window.location.href.split('?')[0]; // Base URL without query parameters
    var anchor = '';

    // Check if there is an anchor
    if (currentUrl.indexOf('#') !== -1) {
        anchor = currentUrl.substring(currentUrl.indexOf('#'));
        currentUrl = currentUrl.substring(0, currentUrl.indexOf('#'));
    }

    window.location.href = currentUrl + '?version=' + version + anchor;
}

function setupDateWidget() {
    $(document).on('keydown', function (event) {
        var $selectElement = $('#preview-version');
        var $selectedOption = $selectElement.find('option:selected');

        if ($selectedOption.length) {
            if (event.key === 'ArrowLeft' && $selectedOption.prev().length) {
                redirectToVersion($selectedOption.prev().val());
            } else if (event.key === 'ArrowRight' && $selectedOption.next().length) {
                redirectToVersion($selectedOption.next().val());
            }
        }
    });

    $('#preview-version').on('change', function () {
        redirectToVersion($(this).val());
    });

    var $selectedOption = $('#preview-version option:selected');

    if ($selectedOption.length) {
        var $prevOption = $selectedOption.prev();
        var $nextOption = $selectedOption.next();

        if ($prevOption.length) {
            $('#btn-previous').attr('href', '?version=' + $prevOption.val());
        } else {
            $('#btn-previous').remove();
        }

        if ($nextOption.length) {
            $('#btn-next').attr('href', '?version=' + $nextOption.val());
        } else {
            $('#btn-next').remove();
        }
    }
}

$(document).ready(function () {
    if ($('#preview-version').length) {
        setupDateWidget();
    }

    $('#diff-col > pre').highlightLines([
        {
            'color': '#ee0000',
            'lines': triggered_line_numbers
        }
    ]);
});