Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ceec8d380f
Fetching contributors…

Cannot retrieve contributors at this time

117 lines (113 sloc) 2.95 kb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jsDump</title>
<meta name="keywords" content="javascript, script, dump, pretty, object, function, window, document, nodes, strings, numbers, regexp, dates, ariel, flesler" />
<meta name="description" content="Demo of jsDump. A small JS Object, to parse Javascript data into pretty strings. Made by Ariel Flesler." />
<meta name="robots" content="index,follow" />
<style type="text/css">
body{
padding:5px;
font-family: Verdana, sans-serif;
background-color: #DDD;
}
ul,li,h3{
margin:0;
padding:0;
}
#links{
position:absolute;
right:5px;
border:1px solid #777;
top:5px;
padding:20px;
}
#links h3{
color:#933;
margin:0 0 5px 0;
}
#links ul{
padding: 8px 0 3px 20px;
}
#links li{
list-style-type:circle;
}
#links a{
color:#69C;
}
h1{
color:#5B739C;
}
h1 strong{
font-size:13px;
color:#777;
}
h2{
margin-top:20px;
}
textarea{
font-size:12px;
height:335px;
width:350px;
display:inline;
}
button{ display:block }
p{
font-size:14px;
width:700px;
}
</style>
</head>
<body id="body" class="node">
<h1>jsDump&nbsp;<strong>by Ariel Flesler</strong></h1>
<div id="links">
<h3>Links</h3>
<ul>
<li><a href="http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html">Homepage</a></li>
</ul>
</div>
<p>
Note that the code on the left is eval'd and then dumped on the right. What this script does, is the second part, dumping <strong>real</strong> Javascript data.<br />
You can try your own code, use only 1 line of code. It can handle from the simplest data, to complex collections.<br />
The way each "thing" is dumped can be easily changed, and it support HTML mode output. Enjoy!
</p>
<textarea rows="15" id="source">
[
window,
document,
{ a : 5, '1' : 'foo' },
/^[ab]+$/g,
new RegExp('x(.*?)z','ig'),
alert,
function fn( x, y, z ){
return x + y;
},
true,
undefined,
null,
new Date(),
document.body,
document.getElementById('links')
]
</textarea>
<textarea id="parsed"></textarea>
<button id="dump">dump</button>
<script type="text/javascript" src="jsDump.js"></script>
<script type="text/javascript">
document.getElementById('dump').onclick = function(){
// All this is specifically for the demo
var text = document.getElementById('source').value;
try{
eval('var data = '+text);
}catch(e){
var data = 'ERROR: '+(e.message||e);
}
// All you need to use is something like this, where 'data' is any JS data
var dumped = jsDump.parse( data );
// Show the parsed data on the 2nd textarea
document.getElementById('parsed').value = dumped;
};
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.