').addClass('value-map-value').append($('
').addClass('map-field-label').text('val'))
$value.append build_response_element(pair[1], info.value)
$li.append $value
$ul.append $li
$ul
when "VOID"
$('').addClass('value-void').text('VOID (note: for oneway methods, success merely indicates the message was sent; it may not have been received or recognized)')
populate_structured_response = (request, response) ->
$details = $('.response-details')
$details.empty()
if response.return != undefined
$('.response-error').hide()
$('.response-success').show()
$details.append build_response_element(response.return, Scrimp.services[request.service][request.function].returns)
else
$('.response-success').hide()
for err, details of response # there's only one. this is awkward
$('.response-error').text(err)
if err == 'Thrift::ApplicationException'
$details.append($('').text(details.type))
$details.append($('
').text(details.message))
else
$detailsList = $('
')
for field, value of details
$detailsList.append($('- ').text(field))
$detailsList.append($('
- ').text(value))
$details.append($detailsList)
$('.response-error').show()
$ ->
$.ajax
success: load_services
url: '/services'
async: false # yeah yeah it's silly get over it
$.ajax
success: load_structs
url: '/structs'
async: false
$.ajax
success: load_protocols
url: '/protocols'
async: false
$('select.service-field').change(service_changed)
$('select.function-field').change(function_changed)
$('.request-json').val(JSON.stringify(default_request(), null, 2))
$('.show-raw-request').click ->
load_raw_request()
$('.structured-request').hide()
$('.raw-request').show()
$('.show-structured-request').click ->
if load_structured_request()
$('.raw-request').hide()
$('.structured-request').show()
$('.show-structured-request').show()
$('.invoke').click ->
if $('.raw-request:hidden').size()
load_raw_request()
request = $('.request-json').val()
$.post $('.request-form').attr('action'),
request,
(data) ->
populate_structured_response JSON.parse(request), data
$('.response-json').text(JSON.stringify(data, null, 2))
$('.response').show()
false
$('.show-raw-response').click ->
$('.structured-response').hide()
$('.raw-response').show()
$('.show-structured-response').click ->
$('.raw-response').hide()
$('.structured-response').show()
$('.show-structured-request').click()