<commit_before>/*
 * Wegas
 * http://wegas.albasim.ch
 *
 * Copyright (c) 2013 School of Business and Engineering Vaud, Comem
 * Licensed under the MIT License
 */
/**
 * @fileoverview
 * @author <NAME> <<EMAIL>>
 */
YUI.add('wegas-helper', function(Y) {
    "use strict";
    /**
     * @name Y.Wegas.Helper
     * @class
     * @constructor
     */

    var Helper = {
        /**
         * Generate ID an unique id based on current time.
         * @function
         * @static
         * @return {Number} time
         * @description
         */
        genId: function() {
            var now = new Date();
            return now.getHours() + now.getMinutes() + now.getSeconds();
        },
        /**
         * Escape a html string by replacing <, > and " by their html entities.
         *
         * @function
         * @static
         * @param {String} str
         * @return {String} Escaped string
         */
        htmlEntities: function(str) {
            return String(str).replace(/&/g, '&amp;')
                    .replace(/</g, '&lt;')
                    .replace(/>/g, '&gt;')
                    .replace(/"/g, '&quot;');
        },
        /**
         * Replace any text line return
         * @function
         * @static
         * @param {String} str the string to escape
         * @param {String} replaceBy The value to replace with, default is \<br \/\>
         * @return {String} Escaped string
         */
        nl2br: function(str, replaceBy) {
            replaceBy = replaceBy || '<br />';
            return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + replaceBy + '$2');
        },
        escapeJSString: function(str) {
            return str.replace(/"/g, '\\"').replace(/(\r\n|\n\r|\r|\n)/g, "\\n");
            //return Helper.nl2br(str.replace(/"/g, '\\"'), "\\n");
        },
        unesacapeJSString: function(str) {
            return str.replace(/\\"/g, '"');
        },
        escapeCSSClass: function(str) {
            return str.replace(/ /g, "-").toLowerCase();
        },
        stripHtml: function(html) {
            var div = document.createElement("div");
            div.innerHTML = html;
            return div.textContent || div.innerText || "";
        },
        /**
         * Format a date, using provided format string.
         *
         * @function
         * @static
         * @argument {Number} timestamp
         * @argument {String} fmt the format to apply, ex. '%d.%M.%Y at %H:%i:%s' <br /><commit_msg>Fix #492<commit_after>/*
 * Wegas
 * http://wegas.albasim.ch
 *
 * Copyright (c) 2013 School of Business and Engineering Vaud, Comem
 * Licensed under the MIT License
 */
/**
 * @fileoverview
 * @author <NAME> <<EMAIL>>
 */
YUI.add('wegas-helper', function(Y) {
    "use strict";
    /**
     * @name Y.Wegas.Helper
     * @class
     * @constructor
     */

    var Helper = {
        /**
         * Generate ID an unique id based on current time.
         * @function
         * @static
         * @return {Number} time
         * @description
         */
        genId: function() {
            var now = new Date();
            return now.getHours() + now.getMinutes() + now.getSeconds();
        },
        /**
         * Escape a html string by replacing <, > and " by their html entities.
         *
         * @function
         * @static
         * @param {String} str
         * @return {String} Escaped string
         */
        htmlEntities: function(str) {
            return String(str).replace(/&/g, '&amp;')
                    .replace(/</g, '&lt;')
                    .replace(/>/g, '&gt;')
                    .replace(/"/g, '&quot;');
        },
        /**
         * Replace any text line return
         * @function
         * @static
         * @param {String} str the string to escape
         * @param {String} replaceBy The value to replace with, default is \<br \/\>
         * @return {String} Escaped string
         */
        nl2br: function(str, replaceBy) {
            replaceBy = replaceBy || '<br />';
            return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + replaceBy + '$2');
        },
        escapeJSString: function(str) {
            return str.replace(/"/g, '\\"').replace(/(\r\n|\n\r|\r)/g, "\n");
            //.replace(/(\r\n|\n\r|\r|\n)/g, "\\n");

            //return Helper.nl2br(str.replace(/"/g, '\\"'), "\\n");
        },
        unesacapeJSString: function(str) {
            return str.replace(/\\"/g, '"');
        },
        escapeCSSClass: function(str) {
            return str.replace(/ /g, "-").toLowerCase();
        },
        stripHtml: function(html) {
            var div = document.createElement("div");
            div.innerHTML = html;
            return div.textContent || div.innerText || "";
        },
        /**
         * Format a date, using provided format string.
         *
         * @function
         * @static
         * @argument {Number} timestamp
         * @argument {String} fmt the format to apply, ex. '%d.%M.%Y at %H:%i:%s' <br />
{'fraction_non_alphanumeric': 0.1727074668251139, 'fraction_numerical': 0.003763121410180234, 'mean_word_length': 1.5224775224775224, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '5447913', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1501, 'n_words': 367}