<commit_before>
$(function() {
    function xReload(xhr) {
        var value = xhr.getResponseHeader('X-AS-Reload');
        if (value) {
            value = parseInt(value, 10);
            if (value && value > 0) {
                if (typeof $.blockUI == 'function') {
                    $.blockUI();
                }
                setTimeout(function() {
                    window.location.reload()
                }, value);
            }
        }
    }

    $(document).ajaxComplete(function(event, xhr, options) {
        xReload(xhr);
    });

});<commit_msg>ajax xhr handlers for execute and trigger #4<commit_after>
$(function() {
    function xReload(xhr) {
        var value = xhr.getResponseHeader('X-AS-Reload');
        if (value) {
            value = parseInt(value, 10);
            if (value && value > 0) {
                if (typeof $.blockUI == 'function') {
                    $.blockUI();
                }
                setTimeout(function() {
                    window.location.reload()
                }, value);
            }
        }
    }

    function xExecute(xhr) {
        var header = xhr.getResponseHeader('X-AS-Execute'),
            json = header ? JSON.parse(header) : null
            ;
        json = typeof json == 'string' ? [json] : json;
        $(json).each(function(index, value) {
            if (typeof value.dom != 'undefined' && value.cmd != 'undefined') {
                AS.execute(value.dom, value.cmd, $.Event('click'));
            }
        });
    }

    function xTrigger(xhr) {
        var header = xhr.getResponseHeader('X-AS-Trigger'),
            json = header ? JSON.parse(header) : null
            ;
        json = typeof json == 'string' ? [json] : json;
        $(json).each(function(index, value) {
            if (typeof value.event != 'undefined') {
                AS.execute('body', {
                    trigger: {
                        event: value.event,
                        selector: value.selector
                    }
                }, $.Event('click'));
            }
        });
    }

    $(document).ajaxComplete(function(event, xhr, options) {
        xReload(xhr);
        xExecute(xhr);
        xTrigger(xhr);
    });

});
{'fraction_non_alphanumeric': 0.14375561545372867, 'fraction_numerical': 0.0031446540880503146, 'mean_word_length': 1.3666312433581296, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4358098', 'n_tokens_mistral': 629, 'n_tokens_neox': 602, 'n_words': 119}