diff --git a/data/css/style.css b/data/css/style.css
index 541fe7b..4ad6807 100755
--- a/data/css/style.css
+++ b/data/css/style.css
@@ -182,4 +182,12 @@ margin: 0;
.button {
padding: 0.3em;
+}
+
+.formatsrc {
+ margin-right: 20%
+}
+
+.formatdst {
+ margin-left: 20%
}
\ No newline at end of file
diff --git a/data/html/panel.html b/data/html/panel.html
index 921f406..868f50a 100755
--- a/data/html/panel.html
+++ b/data/html/panel.html
@@ -40,7 +40,9 @@
Second version
diff --git a/data/js/ui.js b/data/js/ui.js
index a020def..4bde0d1 100644
--- a/data/js/ui.js
+++ b/data/js/ui.js
@@ -86,6 +86,36 @@ function printSingleDiff(diff, div) {
$(function() {
$( "#resizable" ).resizable();
});
+function formatJsonInTextArea(node) {
+ var text1 = node.val();
+ // Remove newlines
+ var text1 = text1.replace("\n", "");
+ try{
+ value = JSON.parse(text1);
+ indendent_text = JSON.stringify(value, null, " ");
+ node.val(indendent_text);
+
+ }catch(e){
+ $('#primary').addClass("invalidJson");
+ alert('The input is not valid JSON. Please check the checkboes.');
+ }
+};
+$(function() {
+ $( "#format1" ).click(function( event ) {
+ event.preventDefault();
+ node = $('textarea#primary');
+ $('#primary').removeClass("invalidJson");
+ formatJsonInTextArea(node);
+ });
+});
+$(function() {
+ $( "#format2" ).click(function( event ) {
+ event.preventDefault();
+ node = $('textarea#secondary');
+ $('#secondary').removeClass("invalidJson");
+ formatJsonInTextArea(node);
+ });
+});
$(function() {
$( "#checkdiff" ).click(function( event ) {
event.preventDefault();
diff --git a/package.json b/package.json
index 4c10311..a609400 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"title": "JSON Diff View",
"name": "jsondiff",
- "version": "0.1.2",
+ "version": "0.1.3",
"description": "Easily view JSON object diffs. Source code can be found at https://github.com/rafspiny/jsondiff/",
"main": "index.js",
"author": "Raffaele Spinelli",