<commit_before>(function($) {
    $(document).ready(function($) {

        var preview_delayed = false;

        function update_preview_delay() {
            preview_delayed = false;
        }

        $("#id_content_raw").keyup(function() {
            if (!preview_delayed) {
                window.setTimeout(update_preview_delay,1000);
                preview_delayed = true;
                $('a[title="Preview"]').trigger('mousedown');
            }
        });

        mySettings.markupSet.push({
            name: 'Mediacracy',
            key: 'M',
            className:"MediaWindow",
            replaceWith: function(markItUp) {
                return MediacracyPopUp(markItUp);
            },
        }, {
            name: 'Save',
            key: 'S',
            className:"Save",
            replaceWith: function(markItUp) {
                return MediacracySave(markItUp);
            },
        });

        $("#{{ id }}").markItUp(mySettings);
        $('a[title="Preview"]').trigger('mousedown');

    });
})(jQuery);

ForceSaveContinue = function() {
    $("input[name='_continue']").click();
}

MediacracySave = function(markItUp) {
    var the_form = $("form");

    //check if this a new object OR if there are errors already here. If so, force normal save. Otherwise, use ajax.
    if ($(window.location.pathname.split('/')).get(-2) == 'add' || $('ul.errorlist').length>0) {
        ForceSaveContinue();
    }

    $.ajax({ // create an AJAX call...
        data: the_form.serialize()+"&_continue=", // get the form data, send as "save and continue"
        type: the_form.attr('method'), // GET or POST
        url: the_form.attr('action'), // the file to call
        success: function(response) { // on 400 response..
            var success_message = $(response).find('ul.messagelist');
            if (success_message.length > 0) { //success message. Perhaps this should be made more explicit?
                $('ul.messagelist').remove();
                success_message.insertBefore($('#content')).delay(1000).toggle(function() {
                    success_message.remove();
                });
            } else { // did not get success message
                ForceSaveContinue();
            }
        },
        error: function(response) { // on non 400 responses
            ForceSaveContinue();
        }
    });
}

/*
<ul class="messagelist">
  <li class="info">The Textify Page &quot;/medical/treatments/laser/ -- LASER&quot; was changed successfully. You may edit it again below.</li>
</ul>
*/

MediacracyPopUp = function(markItUp) {
    var url = '{% url mediacracy_window %}';
    var windowName = "Mediacracy";
    var windowSize = "width=820,height=500";<commit_msg>using new url tag for 1.5 compatibility<commit_after>{% load url from future %}

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

        var preview_delayed = false;

        function update_preview_delay() {
            preview_delayed = false;
        }

        $("#id_content_raw").keyup(function() {
            if (!preview_delayed) {
                window.setTimeout(update_preview_delay,1000);
                preview_delayed = true;
                $('a[title="Preview"]').trigger('mousedown');
            }
        });

        mySettings.markupSet.push({
            name: 'Mediacracy',
            key: 'M',
            className:"MediaWindow",
            replaceWith: function(markItUp) {
                return MediacracyPopUp(markItUp);
            },
        }, {
            name: 'Save',
            key: 'S',
            className:"Save",
            replaceWith: function(markItUp) {
                return MediacracySave(markItUp);
            },
        });

        $("#{{ id }}").markItUp(mySettings);
        $('a[title="Preview"]').trigger('mousedown');

    });
})(jQuery);

ForceSaveContinue = function() {
    $("input[name='_continue']").click();
}

MediacracySave = function(markItUp) {
    var the_form = $("form");

    //check if this a new object OR if there are errors already here. If so, force normal save. Otherwise, use ajax.
    if ($(window.location.pathname.split('/')).get(-2) == 'add' || $('ul.errorlist').length>0) {
        ForceSaveContinue();
    }

    $.ajax({ // create an AJAX call...
        data: the_form.serialize()+"&_continue=", // get the form data, send as "save and continue"
        type: the_form.attr('method'), // GET or POST
        url: the_form.attr('action'), // the file to call
        success: function(response) { // on 400 response..
            var success_message = $(response).find('ul.messagelist');
            if (success_message.length > 0) { //success message. Perhaps this should be made more explicit?
                $('ul.messagelist').remove();
                success_message.insertBefore($('#content')).delay(1000).toggle(function() {
                    success_message.remove();
                });
            } else { // did not get success message
                ForceSaveContinue();
            }
        },
        error: function(response) { // on non 400 responses
            ForceSaveContinue();
        }
    });
}

/*
<ul class="messagelist">
  <li class="info">The Textify Page &quot;/medical/treatments/laser/ -- LASER&quot; was changed successfully. You may edit it again below.</li>
</ul>
*/

MediacracyPopUp = function(markItUp) {
    var url = '{% url 'mediacracy_window' %}';
    var windowName = "Mediacracy";
    var windowSize = "width=820,height=500";
{'fraction_non_alphanumeric': 0.1517304189435337, 'fraction_numerical': 0.008743169398907104, 'mean_word_length': 2.086565486228218, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '523833', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1533, 'n_words': 344}