diff --git a/godoc/static/playground.js b/godoc/static/playground.js index e8242a08..85c43556 100644 --- a/godoc/static/playground.js +++ b/godoc/static/playground.js @@ -238,6 +238,7 @@ function PlaygroundOutput(el) { // shareEl - share button element (optional) // shareURLEl - share URL text input element (optional) // shareRedirect - base URL to redirect to on share (optional) + // vetEl - vet button element (optional) // toysEl - toys select element (optional) // enableHistory - enable using HTML5 history API (optional) // transport - playground transport to use (default is HTTPTransport) @@ -368,6 +369,11 @@ function PlaygroundOutput(el) { if (running) running.Kill(); output.removeClass("error").text('Waiting for remote server...'); } + function noError() { + lineClear(); + if (running) running.Kill(); + output.removeClass("error").text('No errors.'); + } function run() { loading(); running = transport.Run(body(), highlightOutput(PlaygroundOutput(output[0]))); @@ -394,6 +400,26 @@ function PlaygroundOutput(el) { }); } + function vet() { + loading(); + var data = {"body": body()}; + $.ajax("/vet", { + data: data, + type: "POST", + dataType: "json", + success: function(data) { + if (data.Errors) { + setError(data.Errors); + } else { + noError(); + } + }, + error: function() { + setError('Error communicating with remote server.'); + } + }); + } + var shareURL; // jQuery element to show the shared URL. var sharing = false; // true if there is a pending request. var shareCallbacks = []; @@ -441,6 +467,7 @@ function PlaygroundOutput(el) { $(opts.runEl).click(run); $(opts.fmtEl).click(fmt); + $(opts.vetEl).click(vet); if (opts.shareEl !== null && (opts.shareURLEl !== null || opts.shareRedirect !== null)) { if (opts.shareURLEl) { diff --git a/godoc/static/static.go b/godoc/static/static.go index 19d6db2d..df995130 100644 --- a/godoc/static/static.go +++ b/godoc/static/static.go @@ -2432,6 +2432,7 @@ function PlaygroundOutput(el) { // shareEl - share button element (optional) // shareURLEl - share URL text input element (optional) // shareRedirect - base URL to redirect to on share (optional) + // vetEl - vet button element (optional) // toysEl - toys select element (optional) // enableHistory - enable using HTML5 history API (optional) // transport - playground transport to use (default is HTTPTransport) @@ -2562,6 +2563,11 @@ function PlaygroundOutput(el) { if (running) running.Kill(); output.removeClass("error").text('Waiting for remote server...'); } + function noError() { + lineClear(); + if (running) running.Kill(); + output.removeClass("error").text('No errors.'); + } function run() { loading(); running = transport.Run(body(), highlightOutput(PlaygroundOutput(output[0]))); @@ -2588,6 +2594,26 @@ function PlaygroundOutput(el) { }); } + function vet() { + loading(); + var data = {"body": body()}; + $.ajax("/vet", { + data: data, + type: "POST", + dataType: "json", + success: function(data) { + if (data.Errors) { + setError(data.Errors); + } else { + noError(); + } + }, + error: function() { + setError('Error communicating with remote server.'); + } + }); + } + var shareURL; // jQuery element to show the shared URL. var sharing = false; // true if there is a pending request. var shareCallbacks = []; @@ -2635,6 +2661,7 @@ function PlaygroundOutput(el) { $(opts.runEl).click(run); $(opts.fmtEl).click(fmt); + $(opts.vetEl).click(vet); if (opts.shareEl !== null && (opts.shareURLEl !== null || opts.shareRedirect !== null)) { if (opts.shareURLEl) {