Skip to content

Commit

Permalink
Add XML Formatting as well (fixes #60)
Browse files Browse the repository at this point in the history
  • Loading branch information
micsco committed Mar 23, 2019
1 parent ce5c63b commit 7cb4877
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
11 changes: 10 additions & 1 deletion resources/assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var prettyData = require('pretty-data').pd;

angular
.module("app", [
'ui.router',
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions resources/views/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ class="btn btn-xs" ng-class="redirectUrl ? '' : 'disabled'"

<!-- Auto-JSON -->
<label class="small"
title="Automatically applies easy to read JSON formatting on valid requests">
title="Automatically applies easy to read JSON and XML formatting on valid requests">
<input type="checkbox" ng-model="formatJsonEnable"
ga-on="click" ga-event-category="JSONFormat" ga-event-action="toggle"/> Format JSON</label> &emsp;
ga-on="click" ga-event-category="JSONFormat" ga-event-action="toggle"/> Format JSON/XML</label> &emsp;

<!-- Auto Navigate -->
<label class="small"
Expand Down

0 comments on commit 7cb4877

Please sign in to comment.