/* global console, jsonView *//* * ViewJSON * Version 1.0 * A Google Chrome extension to display JSON in a user-friendly format * * This is a chromeified version of the JSONView Firefox extension by Ben Hollis: * http://jsonview.com * http://code.google.com/p/jsonview * * Also based on the XMLTree Chrome extension by Moonty & alan.stroop * https://chrome.google.com/extensions/detail/gbammbheopgpmaagmckhpjbfgdfkpadb * * port by Jamie Wilkinson (@jamiew) | http://jamiedubs.com | http://github.com/jamiew * MIT license / copyfree (f) F.A.T. Lab http://fffff.at * Speed Project Approved: 2h */function collapse(e){var t=e.target,n=t.parentNode.getElementsByClassName("collapsible");if(!n.length)return;n=n[0];if(n.style.display==="none"){var r=n.parentNode.getElementsByClassName("ellipsis")[0];n.parentNode.removeChild(r),n.style.display=""}else{n.style.display="none";var r=document.createElement("span");r.className="ellipsis",r.innerHTML=" … ",n.parentNode.insertBefore(r,n)}t.innerHTML=t.innerHTML==="-"?"+":"-"}function addCollapser(e){if(e.nodeName!=="LI")return;var t=document.createElement("div");t.className="collapser",t.innerHTML="-",t.addEventListener("click",collapse,!1),e.insertBefore(t,e.firstChild)}function jsonView(e,t){this.debug=!1;if(e.indexOf("#")!==-1)this.idType="id",this.id=e.replace("#","");else{if(e.indexOf(".")===-1){this.debug&&console.log("Can't find that element");return}this.idType="class",this.id=e.replace(".","")}this.data=document.getElementById(this.id).innerHTML;if(typeof t!==undefined)if(t.indexOf("#")!==-1)this.targetType="id",this.target=t.replace("#","");else{if(e.indexOf(".")===-1){this.debug&&console.log("Can't find the target element");return}this.targetType="class",this.target=t.replace(".","")}/^\
..., stripping HTML..."),this.data=this.data.replace(/<(?:.|\s)*?>/g,""));var n=/^\s*([\[\{].*[\}\]])\s*$/,r=/^[\s\u200B\uFEFF]*([\w$\[\]\.]+)[\s\u200B\uFEFF]*\([\s\u200B\uFEFF]*([\[{][\s\S]*[\]}])[\s\u200B\uFEFF]*\);?[\s\u200B\uFEFF]*$/,i=/([\[\{][\s\S]*[\]\}])\)/,s=n.test(this.data),o=r.test(this.data);this.debug&&console.log("JSONView: is_json="+s+" is_jsonp="+o);if(s||o){this.debug&&console.log("JSONView: sexytime!");function u(){}u.prototype={htmlEncode:function(e){return e!=null?e.toString().replace(/&/g,"&").replace(/"/g,""").replace(//g,">"):""},decorateWithSpan:function(e,t){return''+this.htmlEncode(e)+""},valueToHTML:function(e){var t=typeof e,n="";return e===null?n+=this.decorateWithSpan("null","null"):e&&e.constructor===Array?n+=this.arrayToHTML(e):t==="object"?n+=this.objectToHTML(e):t==="number"?n+=this.decorateWithSpan(e,"num"):t==="string"?/^(http|https):\/\/[^\s]+$/.test(e)?n+=''+this.htmlEncode(e)+"":n+=this.decorateWithSpan('"'+e+'"',"string"):t==="boolean"&&(n+=this.decorateWithSpan(e,"bool")),n},arrayToHTML:function(e){var t='[