aboutsummaryrefslogtreecommitdiff
path: root/static/play/play.js
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2013-06-26 10:05:01 +1000
committerAndrew Gerrand <adg@golang.org>2013-06-26 10:05:01 +1000
commit7bde0643f08c04fa0dbab7bdeb804c1288974195 (patch)
tree8dfd5b7a235d68970b8c2f70fab0847fd10709cf /static/play/play.js
parent235bb198da098068fe79b2cde98062fc1af13d9a (diff)
go.blog: add line numbers to playground snippets
R=golang-dev, r CC=golang-dev https://golang.org/cl/10541043
Diffstat (limited to 'static/play/play.js')
-rw-r--r--static/play/play.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/static/play/play.js b/static/play/play.js
index d4540dc..a30ca74 100644
--- a/static/play/play.js
+++ b/static/play/play.js
@@ -16,7 +16,7 @@
var s = "";
for (var i = 0; i < node.childNodes.length; i++) {
var n = node.childNodes[i];
- if (n.nodeType === 1 && n.tagName === "PRE") {
+ if (n.nodeType === 1 && n.tagName === "SPAN" && n.className != "number") {
var innerText = n.innerText === undefined ? "textContent" : "innerText";
s += n[innerText] + "\n";
continue;
@@ -35,18 +35,27 @@
var outpre = document.createElement('pre');
var stopFunc;
+ $(output).resizable({
+ handles: "n,w,nw",
+ minHeight: 27,
+ minWidth: 135,
+ maxHeight: 608,
+ maxWidth: 990
+ });
+
function onKill() {
if (stopFunc) {
stopFunc();
}
}
-
- function onRun() {
+
+ function onRun(e) {
onKill();
outpre.innerHTML = "";
output.style.display = "block";
run.style.display = "none";
- stopFunc = runFunc(text(code), outpre);
+ var options = {Race: e.shiftKey};
+ stopFunc = runFunc(text(code), outpre, options);
}
function onClose() {
@@ -97,7 +106,7 @@
}
if (play.length > 0) {
if (window.connectPlayground) {
- runFunc = window.connectPlayground("ws://localhost:3999/socket");
+ runFunc = window.connectPlayground("ws://" + window.location.host + "/socket");
} else {
// If this message is logged,
// we have neglected to include socket.js or playground.js.