|
1
|
|
|
|
|
2
|
|
|
$(window).on('resize', function() { |
|
3
|
|
|
$('.global-headers-section').width($('.method-copy').width() - 30); |
|
4
|
|
|
}); |
|
5
|
|
|
|
|
6
|
|
|
$(document).ready(function(){ |
|
7
|
|
|
$('#documenter_nav').tendina({activeMenu: '.current'}); |
|
8
|
|
|
|
|
9
|
|
|
var hash = window.location.hash; |
|
10
|
|
|
var a = $('a[href="' + hash + '"]', '#scroll'); |
|
11
|
|
|
if (a.length) { |
|
12
|
|
|
$('a[href="'+ hash +'"]', '#scroll')[0].click(); |
|
13
|
|
|
} else { |
|
14
|
|
|
window.location.hash = $($("a[href^='#']")[0]).attr('href'); |
|
15
|
|
|
} |
|
16
|
|
|
$('section.method').each(function() { |
|
17
|
|
|
/** global: Waypoint */ |
|
18
|
|
|
new Waypoint({ |
|
|
|
|
|
|
19
|
|
|
element : this, |
|
20
|
|
|
handler : function() { |
|
21
|
|
|
var id = this.element.attributes['id'].nodeValue; |
|
22
|
|
|
// |
|
23
|
|
|
$('a', '#scroll').removeClass('current'); |
|
24
|
|
|
$('ul', '#scroll').removeClass('open'); |
|
25
|
|
|
var a = $('a[href="#' + id + '"]', '#scroll'); |
|
26
|
|
|
a.addClass('current'); |
|
27
|
|
|
|
|
28
|
|
|
var ul = a.closest('ul'); |
|
29
|
|
|
if (ul.length) { |
|
30
|
|
|
openUl(ul); |
|
31
|
|
|
} |
|
32
|
|
|
if (a.next().is('ul')) { |
|
33
|
|
|
a.next().addClass('open'); |
|
34
|
|
|
} |
|
35
|
|
|
window.history.replaceState(null, null, document.location.pathname + '#' + id); |
|
36
|
|
|
} |
|
37
|
|
|
}) |
|
38
|
|
|
}); |
|
39
|
|
|
$("a[href^='#']").on('click', function() { |
|
40
|
|
|
var a = this; |
|
41
|
|
|
$('html, body').animate({ |
|
42
|
|
|
scrollTop: $($(a).attr('href').replace(new RegExp(/\./, 'g'), '\\.').replace(new RegExp(/\:/, 'g'), '\\:')).offset().top |
|
43
|
|
|
}); |
|
44
|
|
|
return false; |
|
45
|
|
|
}); |
|
46
|
|
|
|
|
47
|
|
|
autocompleteHeaders(); |
|
48
|
|
|
|
|
49
|
|
|
}); |
|
50
|
|
|
|
|
51
|
|
|
function autocompleteHeaders() |
|
52
|
|
|
{ |
|
53
|
|
|
$('.req-header').easyAutocomplete({ |
|
54
|
|
|
data: [ |
|
55
|
|
|
'Accept', |
|
56
|
|
|
'Accept-Charset', |
|
57
|
|
|
'Accept-Encoding', |
|
58
|
|
|
'Accept-Language', |
|
59
|
|
|
'Accept-Datetime', |
|
60
|
|
|
'Access-Control-Request-Method', |
|
61
|
|
|
'Access-Control-Request-Headers', |
|
62
|
|
|
'Authorization', |
|
63
|
|
|
'Cache-Control', |
|
64
|
|
|
'Connection', |
|
65
|
|
|
'Cookie', |
|
66
|
|
|
'Content-Length', |
|
67
|
|
|
'Content-MD5', |
|
68
|
|
|
'Content-Type', |
|
69
|
|
|
'Content-Disposition', |
|
70
|
|
|
'Date', |
|
71
|
|
|
'Expect', |
|
72
|
|
|
'Forwarded', |
|
73
|
|
|
'From', |
|
74
|
|
|
'Host', |
|
75
|
|
|
'If-Match', |
|
76
|
|
|
'If-Modified-Since', |
|
77
|
|
|
'If-None-Match', |
|
78
|
|
|
'If-Range', |
|
79
|
|
|
'If-Unmodified-Since', |
|
80
|
|
|
'Max-Forwards', |
|
81
|
|
|
'Origin', |
|
82
|
|
|
'Pragma', |
|
83
|
|
|
'Proxy-Authorization', |
|
84
|
|
|
'Range', |
|
85
|
|
|
'Referer', |
|
86
|
|
|
'TE', |
|
87
|
|
|
'User-Agent', |
|
88
|
|
|
'Upgrade', |
|
89
|
|
|
'Via', |
|
90
|
|
|
'Warning', |
|
91
|
|
|
'X-Requested-With', |
|
92
|
|
|
'DNT', |
|
93
|
|
|
'X-Forwarded-For', |
|
94
|
|
|
'X-Forwarded-Host', |
|
95
|
|
|
'X-Forwarded-Proto', |
|
96
|
|
|
'Front-End-Https', |
|
97
|
|
|
'X-Http-Method-Override', |
|
98
|
|
|
'X-ATT-DeviceId', |
|
99
|
|
|
'X-Wap-Profile', |
|
100
|
|
|
'Proxy-Connection', |
|
101
|
|
|
'X-UIDH', |
|
102
|
|
|
'X-Csrf-Token', |
|
103
|
|
|
'X-Request-ID', |
|
104
|
|
|
'X-Correlation-ID', |
|
105
|
|
|
], |
|
106
|
|
|
list: { |
|
107
|
|
|
match: { |
|
108
|
|
|
enabled: true |
|
109
|
|
|
} |
|
110
|
|
|
}, |
|
111
|
|
|
}); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
function openUl(ul) |
|
115
|
|
|
{ |
|
116
|
|
|
ul.addClass('open'); |
|
117
|
|
|
var ul = ul.parent().closest('ul'); |
|
118
|
|
|
if (ul.length) { |
|
119
|
|
|
openUl(ul); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
function sendRequest(form) |
|
124
|
|
|
{ |
|
125
|
|
|
$('#toggle-lang-response').trigger('click'); |
|
126
|
|
|
|
|
127
|
|
|
var $form = $(form); |
|
128
|
|
|
var $section = $form.closest('section'); |
|
129
|
|
|
|
|
130
|
|
|
var $btn = $form.find('button[type="submit"]'); |
|
131
|
|
|
$btn.html($('#preloader-template').html()).attr('disabled', true); |
|
132
|
|
|
|
|
133
|
|
|
var headers = {}; |
|
134
|
|
|
$section.find('.headers-form .form-group').not('.except').each(function(key, element) { |
|
135
|
|
|
var $el = $(element); |
|
136
|
|
|
if ($el.find('.req-header-active').is(':checked')) { |
|
137
|
|
|
var header = $el.find('.req-header').val(); |
|
138
|
|
|
headers[header] = $el.find('.req-header-value').val(); |
|
139
|
|
|
} |
|
140
|
|
|
}); |
|
141
|
|
|
$('.global-headers-form .form-group').not('.except').each(function(key, element) { |
|
142
|
|
|
var $el = $(element); |
|
143
|
|
|
if ($el.find('.req-header-active').is(':checked')) { |
|
144
|
|
|
var header = $el.find('.req-header').val(); |
|
145
|
|
|
headers[header] = $el.find('.req-header-value').val(); |
|
146
|
|
|
} |
|
147
|
|
|
}); |
|
148
|
|
|
|
|
149
|
|
|
$.ajax({ |
|
150
|
|
|
url : $section.find('.action-url').val(), |
|
151
|
|
|
headers: headers, |
|
152
|
|
|
type : $form.attr('method'), |
|
153
|
|
|
data : $form.serializeArray(), |
|
154
|
|
|
success : function(response, status, xhr) { |
|
155
|
|
|
$btn.text('Send').attr('disabled', false); |
|
156
|
|
|
$section.find('.method-example-endpoint code.response-content.response-highlighted').jsonViewer(response); |
|
157
|
|
|
$section.find('.method-example-endpoint code.response-content.response-raw').text(typeof response == 'object' ? JSON.stringify(response): String(response)); |
|
158
|
|
|
$section.find('.method-example-endpoint code.response-headers').text(xhr.getAllResponseHeaders()); |
|
159
|
|
|
}, |
|
160
|
|
|
error : function(xhr) { |
|
161
|
|
|
$btn.text('Send').attr('disabled', false); |
|
162
|
|
|
var content = xhr.responseText; |
|
163
|
|
|
if (xhr.statusText && !content) { |
|
164
|
|
|
$.notify({ |
|
165
|
|
|
message: xhr.statusText |
|
166
|
|
|
},{ |
|
167
|
|
|
type: 'danger' |
|
168
|
|
|
}); |
|
169
|
|
|
} |
|
170
|
|
|
if (IsJsonString(content)) { |
|
171
|
|
|
$section.find('.method-example-endpoint code.response-content').jsonViewer(content); |
|
172
|
|
|
return; |
|
173
|
|
|
} |
|
174
|
|
|
var $frame = $('<iframe class="supa" style="width:100%; height:350px;">'); |
|
175
|
|
|
$section.find('.method-example-endpoint code.response-content.response-highlighted').html($frame); |
|
176
|
|
|
$section.find('.method-example-endpoint code.response-content.response-raw').text(typeof content == 'object' ? JSON.stringify(content): String(content)); |
|
177
|
|
|
setTimeout(function() { |
|
178
|
|
|
var doc = $frame[0].contentWindow.document; |
|
179
|
|
|
var $body = $('body', doc); |
|
180
|
|
|
$body.html(content); |
|
181
|
|
|
}, 1); |
|
182
|
|
|
|
|
183
|
|
|
$section.find('.method-example-endpoint code.response-headers').text(xhr.getAllResponseHeaders()); |
|
184
|
|
|
} |
|
185
|
|
|
}); |
|
186
|
|
|
|
|
187
|
|
|
return false; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
function IsJsonString(str) { |
|
191
|
|
|
try { |
|
192
|
|
|
JSON.parse(str); |
|
193
|
|
|
} catch (e) { |
|
194
|
|
|
return false; |
|
195
|
|
|
} |
|
196
|
|
|
return true; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
function changeApiUrl(input) |
|
200
|
|
|
{ |
|
201
|
|
|
var $input = $(input); |
|
202
|
|
|
var $form = $input.closest('form'); |
|
203
|
|
|
var $urlInput = $form.find('.action-url'); |
|
204
|
|
|
var original = $urlInput.data('original'); |
|
205
|
|
|
|
|
206
|
|
|
$form.find('input').not('.action-url').each(function(key, input) { |
|
207
|
|
|
if (!input.value) { |
|
208
|
|
|
return; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
var regexp = new RegExp('{'+ input.name +'}', "g"); |
|
212
|
|
|
original = original.replace(regexp, input.value); |
|
213
|
|
|
}); |
|
214
|
|
|
|
|
215
|
|
|
$urlInput.val(original); |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
function changeTab(ident) |
|
219
|
|
|
{ |
|
220
|
|
|
$('.method-tab').hide(); |
|
221
|
|
|
$('.method-tab.'+ ident).show(); |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
function changeSourceView(ctx) |
|
225
|
|
|
{ |
|
226
|
|
|
var $a = $(ctx); |
|
227
|
|
|
var $parent = $a.parent(); |
|
228
|
|
|
$parent.find('pre.language-none').hide(); |
|
229
|
|
|
if ($a.hasClass('show-source-block')) { |
|
230
|
|
|
$a.removeClass('show-source-block').addClass('show-highlighted-block'); |
|
231
|
|
|
$parent.find('.response-highlighted').parent().show(); |
|
232
|
|
|
$a.find('.fa-eye-slash').removeClass('fa-eye-slash').addClass('fa-eye'); |
|
233
|
|
|
} else { |
|
234
|
|
|
$a.removeClass('show-highlighted-block').addClass('show-source-block'); |
|
235
|
|
|
$parent.find('.response-raw').parent().show(); |
|
236
|
|
|
$a.find('.fa-eye').removeClass('fa-eye').addClass('fa-eye-slash'); |
|
237
|
|
|
} |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
function addNewHeaderInput(ctx) |
|
241
|
|
|
{ |
|
242
|
|
|
$(ctx).closest('.form-group').before($('#header-row-template').html()); |
|
243
|
|
|
autocompleteHeaders(); |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
function showGlobalHeaders(ctx) |
|
247
|
|
|
{ |
|
248
|
|
|
var $li = $(ctx).parent(); |
|
249
|
|
|
if ($li.hasClass('dx-nav-active')) { |
|
250
|
|
|
$li.removeClass('dx-nav-active'); |
|
251
|
|
|
$('.global-headers-section').slideUp(); |
|
252
|
|
|
} else { |
|
253
|
|
|
$li.addClass('dx-nav-active'); |
|
254
|
|
|
$(window).trigger('resize') |
|
255
|
|
|
$('.global-headers-section').slideDown(); |
|
256
|
|
|
} |
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
|