Skip to content

Commit 6a5ca26

Browse files
author
Sabbir Hossain Rupom
committed
console script updated
1 parent 2153732 commit 6a5ca26

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

console/console.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ var tokenHeader = 'X-API-TOKEN';
55
var sessionHeader = 'X-USER-SESSION-ID';
66

77
$(function () {
8-
8+
99
var browserUrl = document.location.href;
10-
if(apiUrl != browserUrl && apiUrl.includes('localhost')) {
10+
if (apiUrl != browserUrl && apiUrl.includes('localhost')) {
1111
apiUrl = browserUrl.replace('/console', '');
12-
if(apiUrl.substr(apiUrl.length - 1) == '/') {
12+
if (apiUrl.substr(apiUrl.length - 1) == '/') {
1313
apiUrl = apiUrl.slice(0, -1);
1414
}
1515
}
16-
16+
1717
$("input[name=baseUrl]").val(apiUrl);
1818
$("input[name=apiPath]").val(pathExt);
1919

@@ -74,7 +74,7 @@ $(function () {
7474
var tokenSignature = $('textarea[name=tokenHash]').val();
7575

7676
if (checkJson) {
77-
$.ajax({
77+
var xhr = $.ajax({
7878
url: apiPath + (queryParameter.length > 0 ? '?' + queryParameter : ''),
7979
type: apiMethod,
8080
data: jsonBody,
@@ -106,17 +106,21 @@ $(function () {
106106
console.log(request.getAllResponseHeaders());
107107
$('#responseHeader').html(request.getAllResponseHeaders().replace(/\n/g, '<br/>'));
108108

109+
},
110+
error: function (xhr) {
111+
$('#responseHeader').html('HTTP-STATUS: ' + xhr.status + '<br>' + xhr.getAllResponseHeaders().replace(/\n/g, '<br>'));
109112
}
110-
}).fail(function (obj, textStatus, request) {
111-
if (obj.hasOwnProperty('responseJSON')) {
112-
obj = obj.responseJSON;
113-
} else if (obj.hasOwnProperty('responseText')) {
114-
obj = obj.responseText;
113+
}).fail(function (jqXHR) {
114+
if (jqXHR.hasOwnProperty('responseJSON')) {
115+
var obj = jqXHR.responseJSON;
116+
} else if (jqXHR.hasOwnProperty('responseText')) {
117+
var obj = jqXHR.responseText;
115118
}
119+
116120
var str = JSON.stringify(obj, null, 2);
121+
117122
$("#jsonOutput").css("background-color", "rgb(251, 205, 183)");
118123
$('#jsonOutput').text(syntaxHighlight(str));
119-
$('#responseHeader').html(request.getAllResponseHeaders().replace(/\n/g, '<br/>'));
120124
});
121125
// $('#submit').attr('disabled', 'disabled');
122126
} else {
@@ -213,5 +217,18 @@ function syntaxHighlight(json) {
213217

214218

215219

220+
221+
222+
223+
224+
225+
226+
227+
228+
229+
230+
231+
232+
216233

217234

console/console.min.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)