diff --git a/package-lock.json b/package-lock.json index 2f1e5cf..738b64f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9363,6 +9363,11 @@ "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=" }, + "pretty-data": { + "version": "0.40.0", + "resolved": "https://registry.npmjs.org/pretty-data/-/pretty-data-0.40.0.tgz", + "integrity": "sha1-Vyqo6iNGdGerlLa1Jmpv2cj93XI=" + }, "pretty-hrtime": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", diff --git a/package.json b/package.json index 562be4b..71d19f1 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "jquery": "^3.1.1", "laravel-echo": "^1.3.5", "laravel-elixir": "^4.0.0", + "pretty-data": "^0.40.0", "pusher-js": "^4.2.2" }, "scripts": { diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index e3840ec..63942b9 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -1,3 +1,5 @@ +var prettyData = require('pretty-data').pd; + angular .module("app", [ 'ui.router', @@ -189,7 +191,14 @@ angular $scope.currentRequest = JSON.parse(JSON.stringify(request)); if ($scope.formatJsonEnable) { - $scope.currentRequest.content = $scope.formatContentJson(request.content) + var hloutput = hljs.highlightAuto(request.content); + + if (hloutput.language === "json") { + $scope.currentRequest.content = $scope.formatContentJson(request.content) + } + if (hloutput.language === "xml") { + $scope.currentRequest.content = prettyData.xml(request.content); + } } $scope.markAsRead(request.uuid); diff --git a/resources/views/app.php b/resources/views/app.php index f8f1790..1245574 100644 --- a/resources/views/app.php +++ b/resources/views/app.php @@ -195,9 +195,9 @@ class="btn btn-xs" ng-class="redirectUrl ? '' : 'disabled'"   + ga-on="click" ga-event-category="JSONFormat" ga-event-action="toggle"/> Format JSON/XML