spec/dummy/tmp/cache/assets/D11/2E0/sprockets%2F1879a9ee13aa637550fd9d122fdb5407 in api_taster-0.2.1 vs spec/dummy/tmp/cache/assets/D11/2E0/sprockets%2F1879a9ee13aa637550fd9d122fdb5407 in api_taster-0.2.2

- old
+ new

@@ -1,10 +1,8 @@ -o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1340243247.760919: @value"o {I" +o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1340245412.0152829: @value"Å{I" class:EFI"ProcessedAsset;FI"logical_path;FI"api_taster/app.js;FI" pathname;FI"M/Users/User/Projects/api_taster/app/assets/javascripts/api_taster/app.js;FI"content_type;FI"application/javascript;FI" -mtime;FI"2012-06-21T11:47:27+10:00;FI" length;Fim -I" digest;F"%d5d887c25d127970d7c31900f6d38533I" source;FI"m -var ApiTaster = { +mtime;FI"2012-06-21T12:23:28+10:00;FI" length;Fià I" digest;F"%dd95b9edb74729b8f8d210253c26838bI" source;FI"à var ApiTaster = { formAction: '', disableUrlParams: function() { $("fieldset[ref=url-params] input").prop("disabled", true); }, enableUrlParams: function() { @@ -13,10 +11,20 @@ storeFormActionFor: function(form) { ApiTaster.formAction = form.attr("action") }, restoreFormActionFor: function(form) { $(form).attr("action", ApiTaster.formAction); + }, + detectContentType: function(response) { + var contentType = response.getResponseHeader("Content-Type"); + var detectedContentType = null + + if (contentType.match(/application\/json/)) { + detectedContentType = 'json'; + } + + return detectedContentType; } }; $.fn.extend({ replaceUrlParams: function(params) { @@ -48,10 +56,18 @@ $(contentElement, container).hide(); $(contentElement + "[ref=" + $(this).attr("id") + "]", container).show(); }); }, + showNavTab: function(name) { + $("ul.nav-tabs li", this).removeClass("active"); + $("ul.nav-tabs li a#response-" + name, this).parent().show().addClass("active"); + + $("pre", this).hide(); + + return $("pre[ref=response-" + name + "]", this).show(); + }, displayOnlySelectedParamsFieldset: function() { $("fieldset", this).hide(); $("fieldset[ref=" + $("ul.nav-tabs li.active a").attr("id") + "]", this).show(); } }); @@ -88,19 +104,24 @@ if ($("#show-api-response-div:visible").length == 0) { $("#show-api-response-div").slideDown(100); } + switch (ApiTaster.detectContentType(xhr)) { + case "json": + $("#show-api-response-div").showNavTab("json").text( + JSON.stringify(JSON.parse(xhr.responseText), null, 2) + ); + break; + } + $("#show-api-response-div pre[ref=response-raw]").text(xhr.responseText); - $("#show-api-response-div pre[ref=response-json]").text( - JSON.stringify(JSON.parse(xhr.responseText), null, 2) - ); prettyPrint(); }); $("#show-api-response-div").enableNavTabsFor("pre"); }); }); -;FI"dependency_digest;F"%dae1cdacab6b0b11a6a56fdb0f18d33cI"required_paths;F[I"M/Users/User/Projects/api_taster/app/assets/javascripts/api_taster/app.js;FI"dependency_paths;F[{I" path;FI"M/Users/User/Projects/api_taster/app/assets/javascripts/api_taster/app.js;FI" -mtime;FI"2012-06-21T11:47:27+10:00;FI" digest;F"%d5d887c25d127970d7c31900f6d38533I" _version;F"%9f3b95dd7ea3030dc35985c0a8020862 +;FI"dependency_digest;F"%8770e462d86068293127a8c2328e02d0I"required_paths;F[I"M/Users/User/Projects/api_taster/app/assets/javascripts/api_taster/app.js;FI"dependency_paths;F[{I" path;FI"M/Users/User/Projects/api_taster/app/assets/javascripts/api_taster/app.js;FI" +mtime;FI"2012-06-21T12:23:28+10:00;FI" digest;F"%dd95b9edb74729b8f8d210253c26838bI" _version;F"%9f3b95dd7ea3030dc35985c0a8020862 \ No newline at end of file