<commit_before>define(["lodash", "backbone", "js/views/base", "game", "js/views/message", "text!html/level.html", "text!html/target.html", "text!html/base.html"],
    function (_, Backbone, BaseView, Game, MessageView, LevelTemplate, TargetTemplate, BaseTemplate) {
        var LevelView;

        LevelView = BaseView.extend({

            template: _.template(LevelTemplate),
            targetTemplate: _.template(TargetTemplate),
            basisTemplate: _.template(BaseTemplate),

            tagName: "div",

            name: "level",

            events: {
                "click .check-solution": "onCheckSolutionClick",
                "click .level-num.button": "onLevelNumClick",
                "click .reset.button": "onResetClick"
            },

            initialize: function (index) {
                BaseView.prototype.initialize.apply(this, arguments);

                this.levelIndex = _.isNumber(index) ? index : parseInt(index);
            },

            prepareData: function () {
                var view = this;

                return Game.db.getLevel(this.levelIndex).then(function (level) {
                    view.model = level;
                });
            },

            getTemplateData: function () {
                var td = BaseView.prototype.getTemplateData.apply(this, arguments);

                _.assign(td, {
                    renderTargetItem: this.targetTemplate,
                    renderBasisItem: this.basisTemplate
                });

                return td;
            },

            show: function () {
                $.when(BaseView.prototype.show.apply(this, arguments))
                    .then(_.bind(this.initDragAreas, this))
                    .then(_.bind(this.initDropAreas, this));
            },

            reset: function () {
                this.$el.find(".base .occupied").removeClass("occupied").attr("data-linked-target-id", "")
                    .find(".target").appendTo(this.$el.find(".targets").get(0));
            },

            onCheckSolutionClick: function (e) {
                if (this.validatelevel(this.getLevelSolution())) {
                    Game.updateActiveLevel(this.levelIndex).then(function (nextLevelIndex) {
                        return Game.navigateToLevel(nextLevelIndex);
                    });
                } else {
                    (new MessageView()).show({
                        "templateData": {
                            "header": "O-o-pss!",
                            "body": "Lorum ipsum dolor, Lorum ipsum dolorLorum ipsum dolorLorum ipsum dolorLorum ipsum dolorLorum ipsum dolorLorum ipsum dolorLorum ipsum dolorLorum ipsum dolorLorum ipsum dolorLorum ipsum dolorLorum ipsum dolor",
                            "buttons": [{
                                "text": "Try again"
                            }]
                        },
                        "postRender": function (message) {
                            message.$el.find(".button").click(_.bind(message.hide, message));
                        }
                    });
                }
            },

            onLevelNumClick: function (e) {
                Game.router.navigate("levels", { trigger: true });
            },

            onResetClick: function (e) {
                this.reset();
            },

            initDropAreas: function () {
                this.$el.find(".drop-area")<commit_msg>Change message;<commit_after>define(["lodash", "backbone", "js/views/base", "game", "js/views/message", "text!html/level.html", "text!html/target.html", "text!html/base.html"],
    function (_, Backbone, BaseView, Game, MessageView, LevelTemplate, TargetTemplate, BaseTemplate) {
        var LevelView;

        LevelView = BaseView.extend({

            template: _.template(LevelTemplate),
            targetTemplate: _.template(TargetTemplate),
            basisTemplate: _.template(BaseTemplate),

            tagName: "div",

            name: "level",

            events: {
                "click .check-solution": "onCheckSolutionClick",
                "click .level-num.button": "onLevelNumClick",
                "click .reset.button": "onResetClick"
            },

            initialize: function (index) {
                BaseView.prototype.initialize.apply(this, arguments);

                this.levelIndex = _.isNumber(index) ? index : parseInt(index);
            },

            prepareData: function () {
                var view = this;

                return Game.db.getLevel(this.levelIndex).then(function (level) {
                    view.model = level;
                });
            },

            getTemplateData: function () {
                var td = BaseView.prototype.getTemplateData.apply(this, arguments);

                _.assign(td, {
                    renderTargetItem: this.targetTemplate,
                    renderBasisItem: this.basisTemplate
                });

                return td;
            },

            show: function () {
                $.when(BaseView.prototype.show.apply(this, arguments))
                    .then(_.bind(this.initDragAreas, this))
                    .then(_.bind(this.initDropAreas, this));
            },

            reset: function () {
                this.$el.find(".base .occupied").removeClass("occupied").attr("data-linked-target-id", "")
                    .find(".target").appendTo(this.$el.find(".targets").get(0));
            },

            onCheckSolutionClick: function (e) {
                if (this.validatelevel(this.getLevelSolution())) {
                    Game.updateActiveLevel(this.levelIndex).then(function (nextLevelIndex) {
                        return Game.navigateToLevel(nextLevelIndex);
                    });
                } else {
                    (new MessageView()).show({
                        "templateData": {
                            "header": "O-o-o-p-psss!",
                            "body": "Something is wrong. Try again, try to think deeper...",
                            "buttons": [{
                                "text": "Try again"
                            }]
                        },
                        "postRender": function (message) {
                            message.$el.find(".button").click(_.bind(message.hide, message));
                        }
                    });
                }
            },

            onLevelNumClick: function (e) {
                Game.router.navigate("levels", { trigger: true });
            },

            onResetClick: function (e) {
                this.reset();
            },

            initDropAreas: function () {
                this.$el.find(".drop-area")
{'fraction_non_alphanumeric': 0.12321215733015495, 'fraction_numerical': 0.0002979737783075089, 'mean_word_length': 1.3645649876717154, 'pattern_counts': {'":': 18, '<': 3, '<?xml version=': 0, '>': 3, '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': '1154154', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1588, 'n_words': 281}