
<html class="bx-core bx-win bx-no-touch bx-no-retina bx-chrome">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="description" content="Сравнение документов">
        <title>Слово VS Слово - инструмент для сравнения текстов и таблиц</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <link rel="stylesheet" href="{{ url_for('static', filename='css/diff2html/github.min.css') }}" />
        <link rel="stylesheet" href="{{ url_for('static', filename='css/diff2html/diff2html.min.css') }}" />
        <link rel="stylesheet" href="{{ url_for('static', filename='css/main/main.css') }}" />
        <script type="text/javascript" src="{{ url_for('static', filename='js/diff2html/diff2html-ui.min.js') }}"></script>
        <script type="text/javascript" src="{{ url_for('static', filename='js/main/main.js') }}"></script>
    </head>
    <body>
        <div class="compare-result">
            <div class="container">
                <div id="myDiffElement">

                </div>
            </div>
        </div>

</body>
<script>
    var targetElement = document.getElementById('myDiffElement');
    var configuration = {
        drawFileList: true,
        fileListToggle: true,
        fileListStartVisible: true,
        fileContentToggle: true,
        matching: 'lines',
        diffStyle: 'word',
        matchWordsThreshold: 0.25,
        matchingMaxComparisons:100000,
        maxLineSizeInBlockForComparison:10000,
        outputFormat: 'side-by-side',
        synchronisedScroll: true,
        highlight: true,
        renderNothingWhenEmpty: false,
    };
    
    var diff2htmlUi = new Diff2HtmlUI(targetElement, `{{ diffs }}`, configuration);
    diff2htmlUi.draw();
    diff2htmlUi.highlightCode();
    numbers = document.querySelectorAll( '.d2h-code-side-linenumber' );
    numbers.forEach(function(number) {
        number.addEventListener('click', function(event) {
            var xpath = "//td[contains(@class,'d2h-code-side-linenumber') and normalize-space(text()) = '"+event.target.innerText+"']";
            const result = document.evaluate(
                xpath,
                document,
                null,
                XPathResult.ANY_TYPE,
                null,
            );
            let nodes = [];
            while ((node = result.iterateNext())) {
                if (node.closest('.d2h-file-wrapper').id==event.target.closest('.d2h-file-wrapper').id){
                nodes.push(node);
                }
            }

            nodes[1].closest('.d2h-code-wrapper').style.top = nodes[0].offsetTop - nodes[1].offsetTop;
        });
    });

</script>
</html>
