<commit_before>/*
 * Wegas
 * http://www.albasim.ch/wegas/
 *
 * Copyright (c) 2013 School of Business and Engineering Vaud, Comem
 * Licensed under the MIT License
 */

/**
 * @fileOverview 
 * @author <NAME> <<EMAIL>od at g<EMAIL>>
 */

YUI.add("wegas-template", function(Y) {
    "use strict";
    var TEMPLATE,
            engine = new Y.Template(Y.Template.Micro),
            undefinedToEmpty = function(value) {
        return Y.Lang.isUndefined(value) ? "" : "" + value;
    };
    TEMPLATE = {
        TEXT: "<div class='wegas-text-template'><span><%= this.label || '{label}' %></span><br/><span><%= this.value || '{value}' %></span></div>",
        BOX: "<div class='wegas-box-template'><%= this.label || '{label}'%><br/><span><% for(var i=0; i < this.value; i+=1){%>" +
                "<div class='wegas-template-box-unit'></div><% } %></span><br/>" +
                "<span>(<%= this.value || '{value}' %><% if(this.default_value != ''){ %><%= '/' + (this.default_value || '{default_value}') %><% } %>)</span></div>",
        VALUEBOX: "<div class='wegas-valuebox-template'><%= this.label || '{label}'%><br/><span><% for(var i=+this.min_value; i < +this.max_value + 1; i+=1){%>" +
                "<div class='wegas-template-valuebox-unit<%= +i === +this.value ? ' wegas-template-valuebox-selected' : '' %>'><%= ''+i %></div><% } %></span><br/>" +
                "</span></div>",
        TITLE: "<div class='wegas-title-template'><%= this.label || '{label}'%></div>",
        FRACTION: "<div class='wegas-fraction-template'><%= (this.min_value || '{min_value}') + '/' + (this.value || '{label}') + '/' + (this.max_value || '{max_value}') %></div>"
    };   
    /**
     * @name Y.Wegas.Template
     * @extends Y.Widget
     * @borrows Y.WidgetChild, Y.Wegas.Widget, Y.Wegas.Editable
     * @class 
     * @constructor
     * @description  Display  Wegas variables instance (or/and descriptor) under
     * specifique templates : text, title, box, fraction and valuebox.
     * It is also possible to create a custom template.
     */
    Y.namespace("Wegas").Template = Y.Base.create("wegas-template", Y.Widget,
            [Y.WidgetChild, Y.Wegas.Widget, Y.Wegas.Editable], {
        /*@lends Y.Wegas.Template#*/
        TEMPLATES: {
            text: engine.compile(TEMPLATE.TEXT),
            box: engine.compile(TEMPLATE.BOX),
            valuebox: engine.compile(TEMPLATE.VALUEBOX),
            title: engine.compile(TEMPLATE.TITLE),
            fraction: engine.compile(TEMPLATE.FRACTION)
        },
        initializer: function() {
        },
        renderUI: function() {
            this.set("variable", this.get("variable"));
        },
        syncUI: function() {
            var template = this.get("custom"), hashCode = "" + Y.Wegas.Helper.hashCode(template),
                    data = this.computeData();
            if (template === "" && COMPILED[this.get("template")]) {
                this.get("contentBox").setHTML(this.TEMPLATES[this.get("template")](data));
            } else {
                if (Y.Lang.isUndefined(this.TEMPLATES[hashCode])) {
                    this.TEMPLATES[hashCode] = engine.compile(template);
                }
                this.get("contentBox").setHTML(this.TEMPLATES[hashCode](data));
            }

        },
        bindUI: function() {
            this.after(["dataChange", "variableChange", "templateChange"], this.syncUI, this);
            Y.Wegas.Facade.VariableDescriptor.after("update", this.syncUI, this);<commit_msg>Fix bug in template micro<commit_after>/*
 * Wegas
 * http://www.albasim.ch/wegas/
 *
 * Copyright (c) 2013 School of Business and Engineering Vaud, Comem
 * Licensed under the MIT License
 */

/**
 * @fileOverview
 * @author <NAME> <<EMAIL>>
 */

YUI.add("wegas-template", function(Y) {
    "use strict";
    var TEMPLATE,
            engine = new Y.Template(Y.Template.Micro),
            undefinedToEmpty = function(value) {
        return Y.Lang.isUndefined(value) ? "" : "" + value;
    };
    TEMPLATE = {
        TEXT: "<div class='wegas-text-template'><span><%= this.label || '{label}' %></span><br/><span><%= this.value || '{value}' %></span></div>",
        BOX: "<div class='wegas-box-template'><%= this.label || '{label}'%><br/><span><% for(var i=0; i < this.value; i+=1){%>" +
                "<div class='wegas-template-box-unit'></div><% } %></span><br/>" +
                "<span>(<%= this.value || '{value}' %><% if(this.default_value != ''){ %><%= '/' + (this.default_value || '{default_value}') %><% } %>)</span></div>",
        VALUEBOX: "<div class='wegas-valuebox-template'><%= this.label || '{label}'%><br/><span><% for(var i=+this.min_value; i < +this.max_value + 1; i+=1){%>" +
                "<div class='wegas-template-valuebox-unit<%= +i === +this.value ? ' wegas-template-valuebox-selected' : '' %>'><%= ''+i %></div><% } %></span><br/>" +
                "</span></div>",
        TITLE: "<div class='wegas-title-template'><%= this.label || '{label}'%></div>",
        FRACTION: "<div class='wegas-fraction-template'><%= (this.min_value || '{min_value}') + '/' + (this.value || '{label}') + '/' + (this.max_value || '{max_value}') %></div>"
    };
    /**
     * @name Y.Wegas.Template
     * @extends Y.Widget
     * @borrows Y.WidgetChild, Y.Wegas.Widget, Y.Wegas.Editable
     * @class
     * @constructor
     * @description  Display  Wegas variables instance (or/and descriptor) under
     * specifique templates : text, title, box, fraction and valuebox.
     * It is also possible to create a custom template.
     */
    Y.namespace("Wegas").Template = Y.Base.create("wegas-template", Y.Widget,
            [Y.WidgetChild, Y.Wegas.Widget, Y.Wegas.Editable], {
        /*@lends Y.Wegas.Template#*/
        TEMPLATES: {
            text: engine.compile(TEMPLATE.TEXT),
            box: engine.compile(TEMPLATE.BOX),
            valuebox: engine.compile(TEMPLATE.VALUEBOX),
            title: engine.compile(TEMPLATE.TITLE),
            fraction: engine.compile(TEMPLATE.FRACTION)
        },
        initializer: function() {
        },
        renderUI: function() {
            this.set("variable", this.get("variable"));
        },
        syncUI: function() {
            var template = this.get("custom"), hashCode = "" + Y.Wegas.Helper.hashCode(template),
                    data = this.computeData();
            if (template === "" && this.TEMPLATES[this.get("template")]) {
                this.get("contentBox").setHTML(this.TEMPLATES[this.get("template")](data));
            } else {
                if (Y.Lang.isUndefined(this.TEMPLATES[hashCode])) {
                    this.TEMPLATES[hashCode] = engine.compile(template);
                }
                this.get("contentBox").setHTML(this.TEMPLATES[hashCode](data));
            }

        },
        bindUI: function() {
            this.after(["dataChange", "variableChange", "templateChange"], this.syncUI, this);
            Y.Wegas.Facade.VariableDescriptor.after("update", this.syncUI, this);
{'fraction_non_alphanumeric': 0.20285510349750177, 'fraction_numerical': 0.0022840827980014277, 'mean_word_length': 2.5223730517848164, 'pattern_counts': {'":': 0, '<': 106, '<?xml version=': 0, '>': 102, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3955560', 'n_tokens_mistral': 2319, 'n_tokens_neox': 2238, 'n_words': 385}