<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/**
 * jQuery json-viewer
 * @author: Alexandre Bodelot &lt;alexandre.bodelot@gmail.com&gt;
 * @link: https://github.com/abodelot/jquery.json-viewer
 */
(function($) {

  /**
   * Check if arg is either an array with at least 1 element, or a dict with at least 1 key
   * @return boolean
   */
  function isCollapsable(arg) {
    return arg instanceof Object &amp;&amp; Object.keys(arg).length &gt; 0;
  }

  /**
   * Check if a string represents a valid url
   * @return boolean
   */
  function isUrl(string) {
    var urlRegexp = /^(https?:\/\/|ftps?:\/\/)?([a-z0-9%-]+\.){1,}([a-z0-9-]+)?(:(\d{1,5}))?(\/([a-z0-9\-._~:/?#[\]@!$&amp;'()*+,;=%]+)?)?$/i;
    return urlRegexp.test(string);
  }

  /**
   * Transform a json object into html representation
   * @return string
   */
  function json2html(json, options) {
    var html = '';
    if (typeof json === 'string') {
      // Escape tags and quotes
      json = json
        .replace(/&amp;/g, '&amp;amp;')
        .replace(/&lt;/g, '&amp;lt;')
        .replace(/&gt;/g, '&amp;gt;')
        .replace(/'/g, '&amp;apos;')
        .replace(/"/g, '&amp;quot;');

      if (options.withLinks &amp;&amp; isUrl(json)) {
        html += '&lt;a href="' + json + '" class="json-string" target="_blank"&gt;' + json + '&lt;/a&gt;';
      } else {
        // Escape double quotes in the rendered non-URL string.
        json = json.replace(/&amp;quot;/g, '\\&amp;quot;');
        html += '&lt;span class="json-string"&gt;"' + json + '"&lt;/span&gt;';
      }
    } else if (typeof json === 'number') {
      html += '&lt;span class="json-literal"&gt;' + json + '&lt;/span&gt;';
    } else if (typeof json === 'boolean') {
      html += '&lt;span class="json-literal"&gt;' + json + '&lt;/span&gt;';
    } else if (json === null) {
      html += '&lt;span class="json-literal"&gt;null&lt;/span&gt;';
    } else if (json instanceof Array) {
      if (json.length &gt; 0) {
        html += '[&lt;ol class="json-array"&gt;';
        for (var i = 0; i &lt; json.length; ++i) {
          html += '&lt;li&gt;';
          // Add toggle button if item is collapsable
          if (isCollapsable(json[i])) {
            html += '&lt;a href class="json-toggle"&gt;&lt;/a&gt;';
          }
          html += json2html(json[i], options);
          // Add comma if item is not last
          if (i &lt; json.length - 1) {
            html += ',';
          }
          html += '&lt;/li&gt;';
        }
        html += '&lt;/ol&gt;]';
      } else {
        html += '[]';
      }
    } else if (typeof json === 'object') {
      var keyCount = Object.keys(json).length;
      if (keyCount &gt; 0) {
        html += '{&lt;ul class="json-dict"&gt;';
        for (var key in json) {
          if (Object.prototype.hasOwnProperty.call(json, key)) {
            html += '&lt;li&gt;';
            var keyRepr = options.withQuotes ?
              '&lt;span class="json-string"&gt;"' + key + '"&lt;/span&gt;' : key;
            // Add toggle button if item is collapsable
            if (isCollapsable(json[key])) {
              html += '&lt;a href class="json-toggle"&gt;' + keyRepr + '&lt;/a&gt;';
            } else {
              html += keyRepr;
            }
            html += ': ' + json2html(json[key], options);
            // Add comma if item is not last
            if (--keyCount &gt; 0) {
              html += ',';
            }
            html += '&lt;/li&gt;';
          }
        }
        html += '&lt;/ul&gt;}';
      } else {
        html += '{}';
      }
    }
    return html;
  }

  /**
   * jQuery plugin method
   * @param json: a javascript object
   * @param options: an optional options hash
   */
  $.fn.jsonViewer = function(json, options) {
    // Merge user options with default options
    options = Object.assign({}, {
      collapsed: false,
      rootCollapsable: true,
      withQuotes: false,
      withLinks: true
    }, options);

    // jQuery chaining
    return this.each(function() {

      // Transform to HTML
      var html = json2html(json, options);
      if (options.rootCollapsable &amp;&amp; isCollapsable(json)) {
        html = '&lt;a href class="json-toggle"&gt;&lt;/a&gt;' + html;
      }

      // Insert HTML in target DOM element
      $(this).html(html);
      $(this).addClass('json-document');

      // Bind click on toggle buttons
      $(this).off('click');
      $(this).on('click', 'a.json-toggle', function() {
        var target = $(this).toggleClass('collapsed').siblings('ul.json-dict, ol.json-array');
        target.toggle();
        if (target.is(':visible')) {
          target.siblings('.json-placeholder').remove();
        } else {
          var count = target.children('li').length;
          var placeholder = count + (count &gt; 1 ? ' items' : ' item');
          target.after('&lt;a href class="json-placeholder"&gt;' + placeholder + '&lt;/a&gt;');
        }
        return false;
      });

      // Simulate click on toggle button when placeholder is clicked
      $(this).on('click', 'a.json-placeholder', function() {
        $(this).siblings('a.json-toggle').click();
        return false;
      });

      if (options.collapsed == true) {
        // Trigger click to collapse all nodes
        $(this).find('a.json-toggle').click();
      }
    });
  };
})(jQuery);
</pre></body></html>