<commit_before>/*!
 * Copyright 2012-2014 <NAME>
 *
 * This file is part of opmuse.
 *
 * opmuse is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * opmuse is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with opmuse.  If not, see <http://www.gnu.org/licenses/>.
 */

define(['jquery', 'inheritance', 'ws', 'ajaxify', 'logger', 'sprintf', 'bind', 'domReady!'],
    function($, inheritance, ws, ajaxify, logger) {

    "use strict";

    var instance = null;

    var Reloader = Class.extend({
        init: function () {
            if (instance !== null) {
                throw Error('Only one instance of Reloader allowed!');
            }
        },
        load: function (selectors) {
            var found = false;

            for (var index in selectors) {
                var selector = selectors[index];

                if (!$(selector).hasClass('reloader')) {
                    logger.log(sprintf('Missing reloader class on %s!', selector));
                    return;
                }

                if ($(selector).length > 0) {
                    found = true;
                    break;
                }
            }

            if (found) {
                $.ajax(document.location.href, {
                    success: function (data, textStatus, xhr) {
                        var page = $($.parseHTML(data));

                        for (var index in selectors) {
                            var selector = selectors[index];

                            (function (selector) {
                                var element = $(selector);

                                element.addClass('reloader-hide').one('transitionend', function (event) {
                                    element.get(0).innerHTML = page.find(selector).get(0).innerHTML;

                                    ajaxify.load(selector);

                                    $(this).removeClass('reloader-hide');
                                });
                            })(selector);
                        }
                    },
                    error: function (xhr) {
                    }
                });
            }
        }
    });

    return (function() {
        if (instance === null) {<commit_msg>only complain about missing reloader class when relevant :/<commit_after>/*!
 * Copyright 2012-2014 <NAME>
 *
 * This file is part of opmuse.
 *
 * opmuse is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * opmuse is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with opmuse.  If not, see <http://www.gnu.org/licenses/>.
 */

define(['jquery', 'inheritance', 'ws', 'ajaxify', 'logger', 'sprintf', 'bind', 'domReady!'],
    function($, inheritance, ws, ajaxify, logger) {

    "use strict";

    var instance = null;

    var Reloader = Class.extend({
        init: function () {
            if (instance !== null) {
                throw Error('Only one instance of Reloader allowed!');
            }
        },
        load: function (selectors) {
            var usedSelectors = [];

            for (var index in selectors) {
                var selector = selectors[index];

                if ($(selector).length > 0) {
                    if (!$(selector).hasClass('reloader')) {
                        logger.log(sprintf('Missing reloader class on %s!', selector));
                        continue;
                    }

                    usedSelectors.push(selector);
                }
            }

            if (usedSelectors.length > 0) {
                $.ajax(document.location.href, {
                    success: function (data, textStatus, xhr) {
                        var page = $($.parseHTML(data));

                        for (var index in usedSelectors) {
                            var selector = usedSelectors[index];

                            (function (selector) {
                                var element = $(selector);

                                element.addClass('reloader-hide').one('transitionend', function (event) {
                                    element.get(0).innerHTML = page.find(selector).get(0).innerHTML;

                                    ajaxify.load(selector);

                                    $(this).removeClass('reloader-hide');
                                });
                            })(selector);
                        }
                    },
                    error: function (xhr) {
                    }
                });
            }
        }
    });

    return (function() {
        if (instance === null) {
{'fraction_non_alphanumeric': 0.10414006930512493, 'fraction_numerical': 0.004559547692868867, 'mean_word_length': 1.412670479542455, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6939408', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1257, 'n_words': 428}