if (typeof(PhpDebugBar) == 'undefined') { // namespace var PhpDebugBar = {}; PhpDebugBar.$ = jQuery; } (function($) { /** * @namespace */ PhpDebugBar.Widgets = {}; /** * Replaces spaces with   and line breaks with
* * @param {String} text * @return {String} */ var htmlize = PhpDebugBar.Widgets.htmlize = function(text) { return text.replace(/\n/g, '
').replace(/\s/g, " ") }; /** * Returns a string representation of value, using JSON.stringify * if it's an object. * * @param {Object} value * @param {Boolean} prettify Uses htmlize() if true * @return {String} */ var renderValue = PhpDebugBar.Widgets.renderValue = function(value, prettify) { if (typeof(value) !== 'string') { if (prettify) { return htmlize(JSON.stringify(value, undefined, 2)); } return JSON.stringify(value); } return value; }; /** * Highlights a block of code * * @param {String} code * @param {String} lang * @return {String} */ var highlight = PhpDebugBar.Widgets.highlight = function(code, lang) { if (typeof(code) === 'string') { if (typeof(hljs) === 'undefined') { return htmlize(code); } if (lang) { return hljs.highlight(lang, code).value; } return hljs.highlightAuto(code).value; } if (typeof(hljs) === 'object') { code.each(function(i, e) { hljs.highlightBlock(e); }); } return code; }; /** * Creates a
 element with a block of code
     *
     * @param  {String} code
     * @param  {String} lang
     * @return {String}
     */
    var createCodeBlock = PhpDebugBar.Widgets.createCodeBlock = function(code, lang) {
        var pre = $('
');
        $('').text(code).appendTo(pre);
        if (lang) {
            pre.addClass("language-" + lang);
        }
        highlight(pre);
        return pre;
    };

    var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-widgets-');


    // ------------------------------------------------------------------
    // Generic widgets
    // ------------------------------------------------------------------

    /**
     * Displays array element in a