Skip to content

Commit

Permalink
godoc: restore toy selection to playground widget
Browse files Browse the repository at this point in the history
Fixes golang#4225.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6640054
  • Loading branch information
adg committed Oct 10, 2012
1 parent 6572c7e commit bd31e62
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
30 changes: 24 additions & 6 deletions doc/play/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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);
}
});
});
}
}
2 changes: 0 additions & 2 deletions doc/root.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
<div style="clear: both;"></div>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="/doc/play/playground.js"></script>
<script type="text/javascript">
google.load("feeds", "1");

Expand Down Expand Up @@ -122,7 +121,6 @@

// Set up playground.
playground({
"simple": true,
"codeEl": "#learn .code",
"outputEl": "#learn .output",
"runEl": "#learn .run",
Expand Down

0 comments on commit bd31e62

Please sign in to comment.