godoc: add vet support to playground.js
Playground needs godoc to support calls to /vet endpoint in playground.js. Optional parameter "vetEl" is added to the function "playground". If it's passed then the js installs the click handler to the element. There is a corresponding CL 100776 for the playground code. Updates golang/go#7597 Change-Id: Ica2e7cb9d76f6f19a1805c182e666b8142762da9 Reviewed-on: https://go-review.googlesource.com/100775 Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
parent
2226533658
commit
4c0f0e48a6
|
@ -238,6 +238,7 @@ function PlaygroundOutput(el) {
|
||||||
// shareEl - share button element (optional)
|
// shareEl - share button element (optional)
|
||||||
// shareURLEl - share URL text input element (optional)
|
// shareURLEl - share URL text input element (optional)
|
||||||
// shareRedirect - base URL to redirect to on share (optional)
|
// shareRedirect - base URL to redirect to on share (optional)
|
||||||
|
// vetEl - vet button element (optional)
|
||||||
// toysEl - toys select element (optional)
|
// toysEl - toys select element (optional)
|
||||||
// enableHistory - enable using HTML5 history API (optional)
|
// enableHistory - enable using HTML5 history API (optional)
|
||||||
// transport - playground transport to use (default is HTTPTransport)
|
// transport - playground transport to use (default is HTTPTransport)
|
||||||
|
@ -368,6 +369,11 @@ function PlaygroundOutput(el) {
|
||||||
if (running) running.Kill();
|
if (running) running.Kill();
|
||||||
output.removeClass("error").text('Waiting for remote server...');
|
output.removeClass("error").text('Waiting for remote server...');
|
||||||
}
|
}
|
||||||
|
function noError() {
|
||||||
|
lineClear();
|
||||||
|
if (running) running.Kill();
|
||||||
|
output.removeClass("error").text('No errors.');
|
||||||
|
}
|
||||||
function run() {
|
function run() {
|
||||||
loading();
|
loading();
|
||||||
running = transport.Run(body(), highlightOutput(PlaygroundOutput(output[0])));
|
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 shareURL; // jQuery element to show the shared URL.
|
||||||
var sharing = false; // true if there is a pending request.
|
var sharing = false; // true if there is a pending request.
|
||||||
var shareCallbacks = [];
|
var shareCallbacks = [];
|
||||||
|
@ -441,6 +467,7 @@ function PlaygroundOutput(el) {
|
||||||
|
|
||||||
$(opts.runEl).click(run);
|
$(opts.runEl).click(run);
|
||||||
$(opts.fmtEl).click(fmt);
|
$(opts.fmtEl).click(fmt);
|
||||||
|
$(opts.vetEl).click(vet);
|
||||||
|
|
||||||
if (opts.shareEl !== null && (opts.shareURLEl !== null || opts.shareRedirect !== null)) {
|
if (opts.shareEl !== null && (opts.shareURLEl !== null || opts.shareRedirect !== null)) {
|
||||||
if (opts.shareURLEl) {
|
if (opts.shareURLEl) {
|
||||||
|
|
|
@ -2432,6 +2432,7 @@ function PlaygroundOutput(el) {
|
||||||
// shareEl - share button element (optional)
|
// shareEl - share button element (optional)
|
||||||
// shareURLEl - share URL text input element (optional)
|
// shareURLEl - share URL text input element (optional)
|
||||||
// shareRedirect - base URL to redirect to on share (optional)
|
// shareRedirect - base URL to redirect to on share (optional)
|
||||||
|
// vetEl - vet button element (optional)
|
||||||
// toysEl - toys select element (optional)
|
// toysEl - toys select element (optional)
|
||||||
// enableHistory - enable using HTML5 history API (optional)
|
// enableHistory - enable using HTML5 history API (optional)
|
||||||
// transport - playground transport to use (default is HTTPTransport)
|
// transport - playground transport to use (default is HTTPTransport)
|
||||||
|
@ -2562,6 +2563,11 @@ function PlaygroundOutput(el) {
|
||||||
if (running) running.Kill();
|
if (running) running.Kill();
|
||||||
output.removeClass("error").text('Waiting for remote server...');
|
output.removeClass("error").text('Waiting for remote server...');
|
||||||
}
|
}
|
||||||
|
function noError() {
|
||||||
|
lineClear();
|
||||||
|
if (running) running.Kill();
|
||||||
|
output.removeClass("error").text('No errors.');
|
||||||
|
}
|
||||||
function run() {
|
function run() {
|
||||||
loading();
|
loading();
|
||||||
running = transport.Run(body(), highlightOutput(PlaygroundOutput(output[0])));
|
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 shareURL; // jQuery element to show the shared URL.
|
||||||
var sharing = false; // true if there is a pending request.
|
var sharing = false; // true if there is a pending request.
|
||||||
var shareCallbacks = [];
|
var shareCallbacks = [];
|
||||||
|
@ -2635,6 +2661,7 @@ function PlaygroundOutput(el) {
|
||||||
|
|
||||||
$(opts.runEl).click(run);
|
$(opts.runEl).click(run);
|
||||||
$(opts.fmtEl).click(fmt);
|
$(opts.fmtEl).click(fmt);
|
||||||
|
$(opts.vetEl).click(vet);
|
||||||
|
|
||||||
if (opts.shareEl !== null && (opts.shareURLEl !== null || opts.shareRedirect !== null)) {
|
if (opts.shareEl !== null && (opts.shareURLEl !== null || opts.shareRedirect !== null)) {
|
||||||
if (opts.shareURLEl) {
|
if (opts.shareURLEl) {
|
||||||
|
|
Loading…
Reference in New Issue