<commit_before>extends base
- load staticfiles
- load i18n
- load compress

block js_media
    script(type='text/javascript', src='{{ ACE_URL }}/ace.js')
    - compress js
        | #{form.media.js}
        script(type='text/javascript').
            $(function () {
                var select = $('#id_language');
                var container = select.parent();
                var current = select.find(':selected').attr('value');
                var field = $('<input/>', {
                    id: 'id_language',
                    name: 'language',
                    type: 'hidden',
                    value: current
                }).appendTo(container);
                var info = $('#language-details');

                function update_info(from, to) {
                    var data_info = from.attr('data-info');
                    if (data_info) {
                        to.html(data_info);
                        return;
                    }
                    var runtimes = [];

                    from.find('.runtime-info').each(function() {
                        var name = $(this).attr('data-runtime-id');
                        var min_ver = $(this).attr('data-min-version');
                        var max_ver = $(this).attr('data-max-version');

                        if (!min_ver || !max_ver) {
                            runtimes.push(name);
                        } else {
                            var version_display = min_ver == max_ver ? max_ver : (min_ver + ' - ' + max_ver);
                            runtimes.push(name + ' ' + version_display);
                        }
                    });
                    to.html(runtimes.join(', '));
                }

                function update_selected() {
                    $('#language-current').find('.name').text(selected.text());
                }
                select.remove();
                select = $('#language-select').show();
                select.find('li').mouseenter(function () {
                    update_info($(this), info);
                }).mouseout(function() {
                    update_info($(this), info);
                }).click(function () {
                    selected.removeClass('selected');
                    window.ace_source.getSession().setMode("ace/mode/" + selected.attr('data-ace'));
                    field.attr('value', (selected = $(this).addClass('selected')).attr('data-id'));
                    update_selected();
                });
                var selected = select.find('[data-id=' + current + ']').addClass('selected');
                update_selected(selected);
                update_info(selected, info);

                $('#language-current').click(function() {
                    var $expand = $('#language-expand');
                    var $current = $(this);
                    if ($expand.is(':visible'))
                        $expand.slideUp(400, function () {
                            $current.removeClass('expanded');
                        });
                    else {
                        $current.addClass('expanded');
                        $expand.slideDown(400);
                    }
                });

                $('#id_language').change(function () {
                    var lang = $("#id_language").find("option:selected").attr('value');
                    window.ace_source.getSession().setMode("ace/mode/" + modes[lang]);
                });

                $('#ace_source').on('ace_load', function (e, editor) {
                    var source = $('textarea#id_source');
                    if (source.val() == '') {
                        var problem = $('#id_problem').find('option:selected').attr('value');<commit_msg>There are actually two places; DMOJ/judge#197<commit_after>extends base
- load staticfiles
- load i18n
- load compress

block js_media
    script(type='text/javascript', src='{{ ACE_URL }}/ace.js')
    - compress js
        | #{form.media.js}
        script(type='text/javascript').
            $(function () {
                var select = $('#id_language');
                var container = select.parent();
                var current = select.find(':selected').attr('value');
                var field = $('<input/>', {
                    id: 'id_language',
                    name: 'language',
                    type: 'hidden',
                    value: current
                }).appendTo(container);
                var info = $('#language-details');

                function update_info(from, to) {
                    var data_info = from.attr('data-info');
                    if (data_info) {
                        to.html(data_info);
                        return;
                    }
                    var runtimes = [];

                    from.find('.runtime-info').each(function() {
                        var name = $(this).attr('data-runtime-id');
                        var min_ver = $(this).attr('data-min-version');
                        var max_ver = $(this).attr('data-max-version');

                        if (!min_ver || !max_ver) {
                            runtimes.push(name);
                        } else {
                            var version_display = min_ver == max_ver ? max_ver : (min_ver + ' - ' + max_ver);
                            runtimes.push(name + ' ' + version_display);
                        }
                    });
                    to.html(runtimes.join(', '));
                }

                function update_selected() {
                    $('#language-current').find('.name').text(selected.text());
                    update_info(selected, $('#language-current').find('.info'));
                    update_info(selected, info);
                }
                select.remove();
                select = $('#language-select').show();
                select.find('li').mouseenter(function () {
                    update_info($(this), info);
                }).mouseout(function() {
                    update_info($(this), info);
                }).click(function () {
                    selected.removeClass('selected');
                    window.ace_source.getSession().setMode("ace/mode/" + selected.attr('data-ace'));
                    field.attr('value', (selected = $(this).addClass('selected')).attr('data-id'));
                    update_selected();
                });
                var selected = select.find('[data-id=' + current + ']').addClass('selected');
                update_selected(selected);

                $('#language-current').click(function() {
                    var $expand = $('#language-expand');
                    var $current = $(this);
                    if ($expand.is(':visible'))
                        $expand.slideUp(400, function () {
                            $current.removeClass('expanded');
                        });
                    else {
                        $current.addClass('expanded');
                        $expand.slideDown(400);
                    }
                });

                $('#id_language').change(function () {
                    var lang = $("#id_language").find("option:selected").attr('value');
                    window.ace_source.getSession().setMode("ace/mode/" + modes[lang]);
                });

                $('#ace_source').on('ace_load', function (e, editor) {
                    var source = $('textarea#id_source');
                    if (source.val() == '') {
                        var problem = $('#id_problem').find('option:selected').attr('value');
{'fraction_non_alphanumeric': 0.14957208689927584, 'fraction_numerical': 0.00250164581961817, 'mean_word_length': 1.2171628721541157, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7365640', 'n_tokens_mistral': 1866, 'n_tokens_neox': 1719, 'n_words': 288}