<commit_before><div id='{{ id }}'>{{ value|safe }}</div>
<script>
var textarea = window.document.getElementById('{{ id }}-textarea');
var src = window.document.getElementById('{{ id }}');
var csrftoken = getCookie('csrftoken');
$(textarea).hide();

$(src).summernote({
    height: {{ height }},
    airMode: {{ airMode }},
    toolbar: {{ toolbar|safe }},
    lang: '{{ lang }}',
    onblur: function() {
        textarea.value = $(this).code();
    },
    onImageUpload: function(files, editor, position) {
        var imageInput = $('.note-image-input');
        imageInput.fileupload();
        var jqXHR = imageInput.fileupload('send', 
            {
                files: files,
                formData: {csrfmiddlewaretoken: csrftoken},
                url: '{{ url.upload_attachment }}',
            })
            .success(function (result, textStatus, jqXHR) {
                data = $.parseJSON(result);
                $.each(data.files, function (index, file) {
                    editor.insertImage(position, file.url);
                });
            })
            .error(function (jqXHR, textStatus, errorThrown) {
                // TODO: Display a detailed error message. It will come from JSON.
                alert( 'Got an error while uploading images.' );
            })
        }
});

// See https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
function getCookie(name) {
    var cookieValue = null;
    if (document.cookie && document.cookie != '') {
        var cookies = document.cookie.split(';');<commit_msg>Appended {{ id }}_ to global variables<commit_after><div id='{{ id }}'>{{ value|safe }}</div>
<script>
var {{ id }}_textarea = window.document.getElementById('{{ id }}-textarea');
var {{ id }}_src = window.document.getElementById('{{ id }}');
var csrftoken = getCookie('csrftoken');
$({{ id }}_textarea).hide();

$({{ id }}_src).summernote({
    height: {{ height }},
    airMode: {{ airMode }},
    toolbar: {{ toolbar|safe }},
    lang: '{{ lang }}',
    onblur: function() {
        {{ id }}_textarea.value = $(this).code();
    },
    onImageUpload: function(files, editor, position) {
        var imageInput = $('.note-image-input');
        imageInput.fileupload();
        var jqXHR = imageInput.fileupload('send', 
            {
                files: files,
                formData: {csrfmiddlewaretoken: <PASSWORD>},
                url: '{{ url.upload_attachment }}',
            })
            .success(function (result, textStatus, jqXHR) {
                data = $.parseJSON(result);
                $.each(data.files, function (index, file) {
                    editor.insertImage(position, file.url);
                });
            })
            .error(function (jqXHR, textStatus, errorThrown) {
                // TODO: Display a detailed error message. It will come from JSON.
                alert( 'Got an error while uploading images.' );
            })
        }
});

// See https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
function getCookie(name) {
    var cookieValue = null;
    if (document.cookie && document.cookie != '') {
        var cookies = document.cookie.split(';');
{'fraction_non_alphanumeric': 0.16545626776128827, 'fraction_numerical': 0.0, 'mean_word_length': 2.18391959798995, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 2, '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': '7320833', 'n_tokens_mistral': 939, 'n_tokens_neox': 887, 'n_words': 202}