<commit_before><div id="online_translation_notification_form" style="display: none;">
    <h4>Напомнить</h4>
    <div class="otnf_email">
        Email:
        <br>
        <input id="notification_email" type="email">
    </div>
    <div class="otnf_period">
        Напомнить за:
        <br>
        <select id="notification_period">
                        {% for key, value in params.notificationPeriods %}
                <option value="{{ key }}">{{ value }}</option>
                        {% endfor %}
    </select>
</div>
<div>
    <img id="notification_captcha_img" src="{{ path('armd_online_translation_captcha') }}">
    <br>
    Введите код с картинки:
    <br>
    <input id="notification_captcha">
</div>
<div class="otnf_buttons">
    <a id="notification_save" class="button button-orange " href="#">Сохранить напоменание</a>
    <a id="notification_cancel" class="button button-orange " href="#">Отмена</a>
</div>
</div>
<script type="text/javascript">
var countdownTimestamp = {{ entity.date.getTimestamp() }};

function countdown()
{
    var diffSec, days, hours, minutes,
        now = new Date(),
        date = new Date(countdownTimestamp * 1000);

    if (date > now) {
        diffSec = Math.floor((date.getTime() - now.getTime()) / 1000);
        days = Math.floor(diffSec / 60 / 60 / 24);
        hours = Math.floor((diffSec - days * 60 * 60 * 24) / 60 / 60);
        minutes = Math.floor((diffSec - days * 60 * 60 * 24 - hours * 60 * 60) / 60);                

        var dStr, arr1 = [0, 5, 6, 7, 8, 9],
            arr2 = [11, 12, 13, 14, 15, 16, 17, 18, 19];                              

        if ($.inArray(parseInt((days + '').substr(-1)), arr1) != -1
            || $.inArray(parseInt((days + '').substr(-2)), arr2) != -1
        ) {
            dStr = 'дней';
        } else if (parseInt((days + '').substr(-1)) == 1) {
            dStr = 'день';
        } else {
            dStr = 'дня';
        }

        $('#countdown').text(days + ' ' + dStr + ' ' + hours + ' час ' + minutes + ' мин');

        setTimeout(countdown, 5000);
    } else {
        $('#countdown').text('0 дней 0 час 0 мин');
    }
}

$(document).ready(function() {
    countdown();

    $('#online_translation_notification').fancybox({
        openEffect  : 'none',
        closeEffect : 'none',
        scrolling: 'visible'
    });

    $('#notification_cancel').click(function () { $.fancybox.close() });

    $('#notification_save').click(function () {
        if (!$.trim($('#notification_email').val()) || !$.trim($('#notification_captcha').val())) {
            return;
        }

        $.fancybox.close();
        armdMk.startLoadingBlock();
        $.ajax({
            url: '{{ path('armd_online_translation_set_notification') }}',
            type: 'post',
            data: {
                id: {{ entity.id }},
                email: $('#notification_email').val(),
                period: $('#notification_period').val(),
                captcha: $('#notification_captcha').val()
            },
            dataType: 'html',
            success: function (data) {
                data = $.trim(data);

                if (data == 'ok') {
                    armdMessager.showMessage('Напоминание сохранено');
                } else if (data == 'invalid_email') {
                    armdMessager.showMessage('Неверный email', armdMessager.messageTypes.ERROR);
                } else if (data == 'invalid_captcha') {
                    armdMessager.showMessage('Неверный код с картинки', armdMessager.messageTypes.ERROR);
                } else {
                    armdMessager.showMessage('Неверные параметры', armdMessager.messageTypes.ERROR);
                }
            },
            complete: function () {
                armdMk.stopLoadingBlock();
                $('#notification_captcha_img').attr('src', '{{ path('armd_online_translation_captcha') }}' + '?rand=' + Math.random());
            }

        });
    });
});
</script><commit_msg>[^] Online translation: countdown fix for UTC<commit_after><div id="online_translation_notification_form" style="display: none;">
    <h4>Напомнить</h4>
    <div class="otnf_email">
        Email:
        <br>
        <input id="notification_email" type="email">
    </div>
    <div class="otnf_period">
        Напомнить за:
        <br>
        <select id="notification_period">
                        {% for key, value in params.notificationPeriods %}
                <option value="{{ key }}">{{ value }}</option>
                        {% endfor %}
    </select>
</div>
<div>
    <img id="notification_captcha_img" src="{{ path('armd_online_translation_captcha') }}">
    <br>
    Введите код с картинки:
    <br>
    <input id="notification_captcha">
</div>
<div class="otnf_buttons">
    <a id="notification_save" class="button button-orange " href="#">Сохранить напоменание</a>
    <a id="notification_cancel" class="button button-orange " href="#">Отмена</a>
</div>
</div>
<script type="text/javascript">
var countdownTimestamp = {{ entity.date.getTimestamp() }};

function countdown()
{
    var diffSec, days, hours, minutes, now,
        date = new Date(countdownTimestamp * 1000);

    // fix date to use UTC
    now = moment();
    now = now.subtract('minutes', now.zone()).toDate();

    if (date > now) {
        diffSec = Math.floor((date.getTime() - now.getTime()) / 1000);
        days = Math.floor(diffSec / 60 / 60 / 24);
        hours = Math.floor((diffSec - days * 60 * 60 * 24) / 60 / 60);
        minutes = Math.floor((diffSec - days * 60 * 60 * 24 - hours * 60 * 60) / 60);                

        var dStr, arr1 = [0, 5, 6, 7, 8, 9],
            arr2 = [11, 12, 13, 14, 15, 16, 17, 18, 19];                              

        if ($.inArray(parseInt((days + '').substr(-1)), arr1) != -1
            || $.inArray(parseInt((days + '').substr(-2)), arr2) != -1
        ) {
            dStr = 'дней';
        } else if (parseInt((days + '').substr(-1)) == 1) {
            dStr = 'день';
        } else {
            dStr = 'дня';
        }

        $('#countdown').text(days + ' ' + dStr + ' ' + hours + ' час ' + minutes + ' мин');

        setTimeout(countdown, 5000);
    } else {
        $('#countdown').text('0 дней 0 час 0 мин');
    }
}

$(document).ready(function() {
    countdown();

    $('#online_translation_notification').fancybox({
        openEffect  : 'none',
        closeEffect : 'none',
        scrolling: 'visible'
    });

    $('#notification_cancel').click(function () { $.fancybox.close() });

    $('#notification_save').click(function () {
        if (!$.trim($('#notification_email').val()) || !$.trim($('#notification_captcha').val())) {
            return;
        }

        $.fancybox.close();
        armdMk.startLoadingBlock();
        $.ajax({
            url: '{{ path('armd_online_translation_set_notification') }}',
            type: 'post',
            data: {
                id: {{ entity.id }},
                email: $('#notification_email').val(),
                period: $('#notification_period').val(),
                captcha: $('#notification_captcha').val()
            },
            dataType: 'html',
            success: function (data) {
                data = $.trim(data);

                if (data == 'ok') {
                    armdMessager.showMessage('Напоминание сохранено');
                } else if (data == 'invalid_email') {
                    armdMessager.showMessage('Неверный email', armdMessager.messageTypes.ERROR);
                } else if (data == 'invalid_captcha') {
                    armdMessager.showMessage('Неверный код с картинки', armdMessager.messageTypes.ERROR);
                } else {
                    armdMessager.showMessage('Неверные параметры', armdMessager.messageTypes.ERROR);
                }
            },
            complete: function () {
                armdMk.stopLoadingBlock();
                $('#notification_captcha_img').attr('src', '{{ path('armd_online_translation_captcha') }}' + '?rand=' + Math.random());
            }

        });
    });
});
</script>
{'fraction_non_alphanumeric': 0.1720470006184292, 'fraction_numerical': 0.019542362399505256, 'mean_word_length': 1.9914909359970403, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '986506', 'n_tokens_mistral': 2627, 'n_tokens_neox': 2431, 'n_words': 489}