From: Andrew Gerrand Date: Wed, 10 Oct 2012 22:53:37 +0000 (+1100) Subject: godoc: restore toy selection to playground widget X-Git-Tag: go1.1rc2~2155 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bd31e62982461b9b5b10b8c2181eff56fe4085f9;p=gostls13.git godoc: restore toy selection to playground widget Fixes #4225. R=golang-dev CC=golang-dev https://golang.org/cl/6640054 --- diff --git a/doc/play/playground.js b/doc/play/playground.js index 3f766a9bf1..0f56fc0564 100644 --- a/doc/play/playground.js +++ b/doc/play/playground.js @@ -3,13 +3,14 @@ // license that can be found in the LICENSE file. // opts is an object with these keys -// codeEl - code editor element -// outputEl - program output element +// codeEl - code editor element +// outputEl - program output element // runEl - run button element -// fmtEl - fmt button element (optional) -// shareEl - share button element (optional) -// shareURLEl - share URL text input element (optional) -// shareRedirect - base URL to redirect to on share (optional) +// fmtEl - fmt button element (optional) +// shareEl - share button element (optional) +// shareURLEl - share URL text input element (optional) +// shareRedirect - base URL to redirect to on share (optional) +// toysEl - toys select element (optional) // enableHistory - enable using HTML5 history API (optional) function playground(opts) { var code = $(opts['codeEl']); @@ -226,4 +227,21 @@ function playground(opts) { }); }); } + + if (opts['toysEl'] != null) { + $(opts['toysEl']).bind('change', function() { + var toy = $(this).val(); + $.ajax("/doc/play/"+toy, { + processData: false, + type: "GET", + complete: function(xhr) { + if (xhr.status != 200) { + alert("Server error; try again.") + return; + } + setBody(xhr.responseText); + } + }); + }); + } } diff --git a/doc/root.html b/doc/root.html index 3b4b43a5e0..cc2bfd1ba9 100644 --- a/doc/root.html +++ b/doc/root.html @@ -85,7 +85,6 @@ Linux, Mac OS X, Windows, and more.
-