@@ -138,10 +192,34 @@
Validation Results:
$.getJSON(url, data, handleValidationResponse);
}
+ // Call out to the validation service with pasted manifest JSON
+ function handleDirectSubmission(e) {
+ e.preventDefault();
+
+ var version = $('#input-panel select[name="version"]').val();
+ var body = $('#input-panel textarea[name="manifest"]').val();
+ $('#results-content').html('Processing ' + version + " validation...");
+ $('#results').show();
+ $.ajax({
+ url: 'validate?version=' + encodeURIComponent(version),
+ method: 'POST',
+ contentType: 'application/json',
+ data: body,
+ dataType: 'json',
+ success: handleValidationResponse,
+ error: function(xhr) {
+ var msg = (xhr.responseJSON && xhr.responseJSON.error) ? xhr.responseJSON.error : 'Invalid JSON';
+ $('#results-content').html('
Validation Error: ' + msg + '
');
+ }
+ });
+ }
+
// Handle validation service response, render response block
function handleValidationResponse(data) {
var str = '
';
- str += '
URL Tested: '+ data.url + '
';
+ if (data.url) {
+ str += '
URL Tested: '+ data.url + '
';
+ }
if (data.okay) {
str += '
Validated successfully
';
} else {
@@ -177,8 +255,18 @@
Validation Results:
$('#results').show();
}
- // Set up event handler.
+ // Tab switching: toggle active tab and matching panel.
+ $('.tab').on("click", function() {
+ var panelId = $(this).data("panel");
+ $('.tab').removeClass("active");
+ $(this).addClass("active");
+ $('.panel').removeClass("active");
+ $('#' + panelId).addClass("active");
+ });
+
+ // Set up event handlers.
$('#submit-url').on("click", handleSubmission);
+ $('#submit-input').on("click", handleDirectSubmission);