<commit_before>$(function () {
    configureLibs();
    setupApp();
});

function configureLibs() {
    nunjucks.configure("", {web: {useCache: true}});
    $.fn.editable.defaults.mode = 'inline';
    $.fn.editable.defaults.showbuttons = false;
    $.fn.editable.defaults.showbuttons = false;
    $.fn.editable.defaults.onblur = 'submit';
    Backbone.Marionette.Renderer.render = function (template, data) {
        if (_.isFunction(template)) {
            return template(data);
        }
        return nunjucks.render(template, data);
    };
}

var App = {};

function createEmptyDiet() {
    var diet = new Diet();
    var dayCollection = new DayCollection();
    diet.set('days', dayCollection);

    var mealListModel = new MealList();
    var firstMeal = new Meal();
    firstMeal.set('name', "Meal 1");
    mealListModel.add(firstMeal);

    dayCollection.add(new Day({name: "Monday", meals: mealListModel, active: true}));
    dayCollection.add(new Day({name: "Tuesday", meals: new MealList()}));
    dayCollection.add(new Day({name: "Wednesday", meals: new MealList()}));
    dayCollection.add(new Day({name: "Thursday", meals: new MealList()}));
    dayCollection.add(new Day({name: "Friday", meals: new MealList()}));

    diet.set('caloricIntake', new CaloricIntakeModel());

    return diet;
}

var setupApp = function () {
    var dietId = url('?id');

    App.daysPanelView = undefined;

    if (dietId != null) {
        Search.Load(dietId, function (diet) {
            App.diet = diet;
            App.daysPanelView = prepareView(diet.get('days'))
        });<commit_msg>Added initial meal for each day<commit_after>$(function () {
    configureLibs();
    setupApp();
});

function configureLibs() {
    nunjucks.configure("", {web: {useCache: true}});
    $.fn.editable.defaults.mode = 'inline';
    $.fn.editable.defaults.showbuttons = false;
    $.fn.editable.defaults.showbuttons = false;
    $.fn.editable.defaults.onblur = 'submit';
    Backbone.Marionette.Renderer.render = function (template, data) {
        if (_.isFunction(template)) {
            return template(data);
        }
        return nunjucks.render(template, data);
    };
}

var App = {};

function createNewDay(name, active) {
    var mealListModel = new MealList();
    var firstMeal = new Meal({name: 'Meal 1'});
    mealListModel.add(firstMeal);
    return new Day({name: name, meals: mealListModel, active: active})
}

function createEmptyDiet() {
    var dayCollection = new DayCollection();
    dayCollection.add(createNewDay("Monday", true));
    dayCollection.add(createNewDay("Tuesday", false));
    dayCollection.add(createNewDay("Wednesday", false));
    dayCollection.add(createNewDay("Thursday", false));
    dayCollection.add(createNewDay("Friday", false));

    return new Diet({days: dayCollection, caloricIntake: new CaloricIntakeModel()});
}

var setupApp = function () {
    var dietId = url('?id');

    App.daysPanelView = undefined;

    if (dietId != null) {
        Search.Load(dietId, function (diet) {
            App.diet = diet;
            App.daysPanelView = prepareView(diet.get('days'))
        });
{'fraction_non_alphanumeric': 0.1563299232736573, 'fraction_numerical': 0.0006393861892583121, 'mean_word_length': 3.4257425742574257, 'pattern_counts': {'":': 0, '<': 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': '1381026', 'n_tokens_mistral': 991, 'n_tokens_neox': 971, 'n_words': 206}