Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Prettifier: */
- /* short form bookmarklet */
- javascript:(function(){window.open('about:blank'); document.open(); document.write('<html>\n<body>\n<pre>\n' + JSON.stringify(eval('('+prompt("Enter your JSON string for prettification.","")+')'),null,2) + '\n</pre>\n</body>\n</html>'); document.close();})();
- /* long form */
- document.open();
- document.write('<html>\n<body>\n<pre>\n' + JSON.stringify(eval('('+prompt("Enter your JSON string for prettification.","")+')'),null,2) + '\n</pre>\n</body>\n</html>');
- document.close();
- /* Uglifier: */
- /* this was suprisingly waay harder than prettifying. prompt() can't handle multiple lines so I had to improvise. Also I had to get a working regex that was valid in JavaScript that would strip spaces while leaving them alone inside quotes.*/
- /* short form bookmarklet */
- javascript:(function(){window.open('about:blank'); document.open(); document.write('<html>\n<body>\n<script type="text/javascript">function stripNewLine(){\nvar str1=document.getElementById("area1").value;\n document.open();\n document.write("<html>\\n<body>\\n<pre>" + str1.replace(/\\r?\\n|\\r/g,""\).replace(/(?:\\s+\)|((?:"(?:.+?)")|(?:\'(?:.+?)\'))/g,"$1") + "</pre>\\n</body>\\n</html>");\n document.close();\n}\n</script>\n<pre><textarea id="area1" name="area1" rows="25" cols="80"></textarea>\n<br/>\n<button onclick="stripNewLine()">Un-prettify</button>\n</body>\n</html>'); document.close();})();
- /* long form */
- document.open();
- document.write('<html>\n<body>\n<script type="text/javascript">function stripNewLine(){\nvar str1=document.getElementById("area1").value;\n document.open();\n document.write("<html>\\n<body>\\n<pre>" + str1.replace(/\\r?\\n|\\r/g,""\).replace(/(?:\\s+\)|((?:"(?:.+?)")|(?:\'(?:.+?)\'))/g,"$1") + "</pre>\\n</body>\\n</html>");\n document.close();\n}\n</script>\n<pre><textarea id="area1" name="area1" rows="25" cols="80"></textarea>\n<br/>\n<button onclick="stripNewLine()">Un-prettify</button>\n</body>\n</html>');
- document.close();
Advertisement
Add Comment
Please, Sign In to add comment