godoc/static: replace innerHTML with textContent

Setting innerHTML is a more heavyweight operation that supports HTML.
What's being done here doesn't use HTML, so it's viable to use the more
lightweight textContent.

Change-Id: I46e9359ffe776001836cc09fea88b04364870db7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/235577
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/godoc/static/play.js b/godoc/static/play.js
index 0a10165..cde6d53 100644
--- a/godoc/static/play.js
+++ b/godoc/static/play.js
@@ -51,7 +51,7 @@
       var sk = e.shiftKey || localStorage.getItem('play-shiftKey') === 'true';
       if (running) running.Kill();
       output.style.display = 'block';
-      outpre.innerHTML = '';
+      outpre.textContent = '';
       run1.style.display = 'none';
       var options = { Race: sk };
       running = transport.Run(text(code), PlaygroundOutput(outpre), options);
@@ -72,20 +72,20 @@
     }
 
     var run1 = document.createElement('button');
-    run1.innerHTML = 'Run';
+    run1.textContent = 'Run';
     run1.className = 'run';
     run1.addEventListener('click', onRun, false);
     var run2 = document.createElement('button');
     run2.className = 'run';
-    run2.innerHTML = 'Run';
+    run2.textContent = 'Run';
     run2.addEventListener('click', onRun, false);
     var kill = document.createElement('button');
     kill.className = 'kill';
-    kill.innerHTML = 'Kill';
+    kill.textContent = 'Kill';
     kill.addEventListener('click', onKill, false);
     var close = document.createElement('button');
     close.className = 'close';
-    close.innerHTML = 'Close';
+    close.textContent = 'Close';
     close.addEventListener('click', onClose, false);
 
     var button = document.createElement('div');
diff --git a/godoc/static/static.go b/godoc/static/static.go
index 58af1b7..0f94143 100644
--- a/godoc/static/static.go
+++ b/godoc/static/static.go
@@ -83,7 +83,7 @@
 
 	"packageroot.html": "<!--\x0a\x09Copyright\x202018\x20The\x20Go\x20Authors.\x20All\x20rights\x20reserved.\x0a\x09Use\x20of\x20this\x20source\x20code\x20is\x20governed\x20by\x20a\x20BSD-style\x0a\x09license\x20that\x20can\x20be\x20found\x20in\x20the\x20LICENSE\x20file.\x0a-->\x0a<!--\x0a\x09Note:\x20Static\x20(i.e.,\x20not\x20template-generated)\x20href\x20and\x20id\x0a\x09attributes\x20start\x20with\x20\"pkg-\"\x20to\x20make\x20it\x20impossible\x20for\x0a\x09them\x20to\x20conflict\x20with\x20generated\x20attributes\x20(some\x20of\x20which\x0a\x09correspond\x20to\x20Go\x20identifiers).\x0a-->\x0a{{with\x20.PAst}}\x0a\x09{{range\x20$filename,\x20$ast\x20:=\x20.}}\x0a\x09\x09<a\x20href=\"{{$filename|srcLink|html}}\">{{$filename|filename|html}}</a>:<pre>{{node_html\x20$\x20$ast\x20false}}</pre>\x0a\x09{{end}}\x0a{{end}}\x0a\x0a{{with\x20.Dirs}}\x0a\x09{{/*\x20DirList\x20entries\x20are\x20numbers\x20and\x20strings\x20-\x20no\x20need\x20for\x20FSet\x20*/}}\x0a\x09{{if\x20$.PDoc}}\x0a\x09\x09<h2\x20id=\"pkg-subdirectories\">Subdirectories</h2>\x0a\x09{{end}}\x0a\x09\x09<div\x20id=\"manual-nav\">\x0a\x09\x09\x09<dl>\x0a\x09\x09\x09\x09<dt><a\x20href=\"#stdlib\">Standard\x20library</a></dt>\x0a\x09\x09\x09\x09{{if\x20hasThirdParty\x20.List\x20}}\x0a\x09\x09\x09\x09\x09<dt><a\x20href=\"#thirdparty\">Third\x20party</a></dt>\x0a\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09<dt><a\x20href=\"#other\">Other\x20packages</a></dt>\x0a\x09\x09\x09\x09<dd><a\x20href=\"#subrepo\">Sub-repositories</a></dd>\x0a\x09\x09\x09\x09<dd><a\x20href=\"#community\">Community</a></dd>\x0a\x09\x09\x09</dl>\x0a\x09\x09</div>\x0a\x0a\x09\x09<div\x20id=\"stdlib\"\x20class=\"toggleVisible\">\x0a\x09\x09\x09<div\x20class=\"collapsed\">\x0a\x09\x09\x09\x09<h2\x20class=\"toggleButton\"\x20title=\"Click\x20to\x20show\x20Standard\x20library\x20section\">Standard\x20library\x20\xe2\x96\xb9</h2>\x0a\x09\x09\x09</div>\x0a\x09\x09\x09<div\x20class=\"expanded\">\x0a\x09\x09\x09\x09<h2\x20class=\"toggleButton\"\x20title=\"Click\x20to\x20hide\x20Standard\x20library\x20section\">Standard\x20library\x20\xe2\x96\xbe</h2>\x0a\x09\x09\x09\x09<img\x20alt=\"\"\x20class=\"gopher\"\x20src=\"/doc/gopher/pkg.png\"/>\x0a\x09\x09\x09\x09<div\x20class=\"pkg-dir\">\x0a\x09\x09\x09\x09\x09<table>\x0a\x09\x09\x09\x09\x09\x09<tr>\x0a\x09\x09\x09\x09\x09\x09\x09<th\x20class=\"pkg-name\">Name</th>\x0a\x09\x09\x09\x09\x09\x09\x09<th\x20class=\"pkg-synopsis\">Synopsis</th>\x0a\x09\x09\x09\x09\x09\x09</tr>\x0a\x0a\x09\x09\x09\x09\x09\x09{{range\x20.List}}\x0a\x09\x09\x09\x09\x09\x09\x09<tr>\x0a\x09\x09\x09\x09\x09\x09\x09{{if\x20eq\x20.RootType\x20\"GOROOT\"}}\x0a\x09\x09\x09\x09\x09\x09\x09{{if\x20$.DirFlat}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20.HasPkg}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<td\x20class=\"pkg-name\">\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<a\x20href=\"{{html\x20.Path}}/{{modeQueryString\x20$.Mode\x20|\x20html}}\">{{html\x20.Path}}</a>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</td>\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09{{else}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09<td\x20class=\"pkg-name\"\x20style=\"padding-left:\x20{{multiply\x20.Depth\x2020}}px;\">\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<a\x20href=\"{{html\x20.Path}}/{{modeQueryString\x20$.Mode\x20|\x20html}}\">{{html\x20.Name}}</a>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09</td>\x0a\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09<td\x20class=\"pkg-synopsis\">\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Synopsis}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09</td>\x0a\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09</tr>\x0a\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09</table>\x0a\x09\x09\x09\x09</div>\x20<!--\x20.pkg-dir\x20-->\x0a\x09\x09\x09</div>\x20<!--\x20.expanded\x20-->\x0a\x09\x09</div>\x20<!--\x20#stdlib\x20.toggleVisible\x20-->\x0a\x0a\x09{{if\x20hasThirdParty\x20.List\x20}}\x0a\x09\x09<div\x20id=\"thirdparty\"\x20class=\"toggleVisible\">\x0a\x09\x09\x09<div\x20class=\"collapsed\">\x0a\x09\x09\x09\x09<h2\x20class=\"toggleButton\"\x20title=\"Click\x20to\x20show\x20Third\x20party\x20section\">Third\x20party\x20\xe2\x96\xb9</h2>\x0a\x09\x09\x09</div>\x0a\x09\x09\x09<div\x20class=\"expanded\">\x0a\x09\x09\x09\x09<h2\x20class=\"toggleButton\"\x20title=\"Click\x20to\x20hide\x20Third\x20party\x20section\">Third\x20party\x20\xe2\x96\xbe</h2>\x0a\x09\x09\x09\x09<div\x20class=\"pkg-dir\">\x0a\x09\x09\x09\x09\x09<table>\x0a\x09\x09\x09\x09\x09\x09<tr>\x0a\x09\x09\x09\x09\x09\x09\x09<th\x20class=\"pkg-name\">Name</th>\x0a\x09\x09\x09\x09\x09\x09\x09<th\x20class=\"pkg-synopsis\">Synopsis</th>\x0a\x09\x09\x09\x09\x09\x09</tr>\x0a\x0a\x09\x09\x09\x09\x09\x09{{range\x20.List}}\x0a\x09\x09\x09\x09\x09\x09\x09<tr>\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20eq\x20.RootType\x20\"GOPATH\"}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20$.DirFlat}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20.HasPkg}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<td\x20class=\"pkg-name\">\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<a\x20href=\"{{html\x20.Path}}/{{modeQueryString\x20$.Mode\x20|\x20html}}\">{{html\x20.Path}}</a>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</td>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{else}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<td\x20class=\"pkg-name\"\x20style=\"padding-left:\x20{{multiply\x20.Depth\x2020}}px;\">\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<a\x20href=\"{{html\x20.Path}}/{{modeQueryString\x20$.Mode\x20|\x20html}}\">{{html\x20.Name}}</a>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</td>\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09<td\x20class=\"pkg-synopsis\">\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Synopsis}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09</td>\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09</tr>\x0a\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09</table>\x0a\x09\x09\x09\x09</div>\x20<!--\x20.pkg-dir\x20-->\x0a\x09\x09\x09</div>\x20<!--\x20.expanded\x20-->\x0a\x09\x09</div>\x20<!--\x20#stdlib\x20.toggleVisible\x20-->\x0a\x09{{end}}\x0a\x0a\x09<h2\x20id=\"other\">Other\x20packages</h2>\x0a\x09<h3\x20id=\"subrepo\">Sub-repositories</h3>\x0a\x09<p>\x0a\x09These\x20packages\x20are\x20part\x20of\x20the\x20Go\x20Project\x20but\x20outside\x20the\x20main\x20Go\x20tree.\x0a\x09They\x20are\x20developed\x20under\x20looser\x20<a\x20href=\"/doc/go1compat\">compatibility\x20requirements</a>\x20than\x20the\x20Go\x20core.\x0a\x09Install\x20them\x20with\x20\"<a\x20href=\"/cmd/go/#hdr-Download_and_install_packages_and_dependencies\">go\x20get</a>\".\x0a\x09</p>\x0a\x09<ul>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/benchmarks\">benchmarks</a>\x20\xe2\x80\x94\x20benchmarks\x20to\x20measure\x20Go\x20as\x20it\x20is\x20developed.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/blog\">blog</a>\x20\xe2\x80\x94\x20<a\x20href=\"//blog.golang.org\">blog.golang.org</a>'s\x20implementation.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/build\">build</a>\x20\xe2\x80\x94\x20<a\x20href=\"//build.golang.org\">build.golang.org</a>'s\x20implementation.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/crypto\">crypto</a>\x20\xe2\x80\x94\x20additional\x20cryptography\x20packages.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/debug\">debug</a>\x20\xe2\x80\x94\x20an\x20experimental\x20debugger\x20for\x20Go.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/image\">image</a>\x20\xe2\x80\x94\x20additional\x20imaging\x20packages.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/mobile\">mobile</a>\x20\xe2\x80\x94\x20experimental\x20support\x20for\x20Go\x20on\x20mobile\x20platforms.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/net\">net</a>\x20\xe2\x80\x94\x20additional\x20networking\x20packages.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/perf\">perf</a>\x20\xe2\x80\x94\x20packages\x20and\x20tools\x20for\x20performance\x20measurement,\x20storage,\x20and\x20analysis.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/review\">review</a>\x20\xe2\x80\x94\x20a\x20tool\x20for\x20working\x20with\x20Gerrit\x20code\x20reviews.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/sync\">sync</a>\x20\xe2\x80\x94\x20additional\x20concurrency\x20primitives.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/sys\">sys</a>\x20\xe2\x80\x94\x20packages\x20for\x20making\x20system\x20calls.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/text\">text</a>\x20\xe2\x80\x94\x20packages\x20for\x20working\x20with\x20text.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/time\">time</a>\x20\xe2\x80\x94\x20additional\x20time\x20packages.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/tools\">tools</a>\x20\xe2\x80\x94\x20godoc,\x20goimports,\x20gorename,\x20and\x20other\x20tools.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/tour\">tour</a>\x20\xe2\x80\x94\x20<a\x20href=\"//tour.golang.org\">tour.golang.org</a>'s\x20implementation.</li>\x0a\x09\x09<li><a\x20href=\"//godoc.org/golang.org/x/exp\">exp</a>\x20\xe2\x80\x94\x20experimental\x20and\x20deprecated\x20packages\x20(handle\x20with\x20care;\x20may\x20change\x20without\x20warning).</li>\x0a\x09</ul>\x0a\x0a\x09<h3\x20id=\"community\">Community</h3>\x0a\x09<p>\x0a\x09These\x20services\x20can\x20help\x20you\x20find\x20Open\x20Source\x20packages\x20provided\x20by\x20the\x20community.\x0a\x09</p>\x0a\x09<ul>\x0a\x09\x09<li><a\x20href=\"//godoc.org\">GoDoc</a>\x20-\x20a\x20package\x20index\x20and\x20search\x20engine.</li>\x0a\x09\x09<li><a\x20href=\"http://go-search.org\">Go\x20Search</a>\x20-\x20a\x20code\x20search\x20engine.</li>\x0a\x09\x09<li><a\x20href=\"/wiki/Projects\">Projects\x20at\x20the\x20Go\x20Wiki</a>\x20-\x20a\x20curated\x20list\x20of\x20Go\x20projects.</li>\x0a\x09</ul>\x0a{{end}}\x0a",
 
-	"play.js": "//\x20Copyright\x202012\x20The\x20Go\x20Authors.\x20All\x20rights\x20reserved.\x0a//\x20Use\x20of\x20this\x20source\x20code\x20is\x20governed\x20by\x20a\x20BSD-style\x0a//\x20license\x20that\x20can\x20be\x20found\x20in\x20the\x20LICENSE\x20file.\x0a\x0afunction\x20initPlayground(transport)\x20{\x0a\x20\x20'use\x20strict';\x0a\x0a\x20\x20function\x20text(node)\x20{\x0a\x20\x20\x20\x20var\x20s\x20=\x20'';\x0a\x20\x20\x20\x20for\x20(var\x20i\x20=\x200;\x20i\x20<\x20node.childNodes.length;\x20i++)\x20{\x0a\x20\x20\x20\x20\x20\x20var\x20n\x20=\x20node.childNodes[i];\x0a\x20\x20\x20\x20\x20\x20if\x20(n.nodeType\x20===\x201)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(n.tagName\x20===\x20'BUTTON')\x20continue;\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(n.tagName\x20===\x20'SPAN'\x20&&\x20n.className\x20===\x20'number')\x20continue;\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(n.tagName\x20===\x20'DIV'\x20||\x20n.tagName\x20==\x20'BR')\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20s\x20+=\x20'\\n';\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20s\x20+=\x20text(n);\x0a\x20\x20\x20\x20\x20\x20\x20\x20continue;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20if\x20(n.nodeType\x20===\x203)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20s\x20+=\x20n.nodeValue;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20return\x20s.replace('\\xA0',\x20'\x20');\x20//\x20replace\x20non-breaking\x20spaces\x0a\x20\x20}\x0a\x0a\x20\x20//\x20When\x20presenter\x20notes\x20are\x20enabled,\x20the\x20index\x20passed\x0a\x20\x20//\x20here\x20will\x20identify\x20the\x20playground\x20to\x20be\x20synced\x0a\x20\x20function\x20init(code,\x20index)\x20{\x0a\x20\x20\x20\x20var\x20output\x20=\x20document.createElement('div');\x0a\x20\x20\x20\x20var\x20outpre\x20=\x20document.createElement('pre');\x0a\x20\x20\x20\x20var\x20running;\x0a\x0a\x20\x20\x20\x20if\x20($\x20&&\x20$(output).resizable)\x20{\x0a\x20\x20\x20\x20\x20\x20$(output).resizable({\x0a\x20\x20\x20\x20\x20\x20\x20\x20handles:\x20'n,w,nw',\x0a\x20\x20\x20\x20\x20\x20\x20\x20minHeight:\x2027,\x0a\x20\x20\x20\x20\x20\x20\x20\x20minWidth:\x20135,\x0a\x20\x20\x20\x20\x20\x20\x20\x20maxHeight:\x20608,\x0a\x20\x20\x20\x20\x20\x20\x20\x20maxWidth:\x20990,\x0a\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20onKill()\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20if\x20(window.notesEnabled)\x20updatePlayStorage('onKill',\x20index);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20onRun(e)\x20{\x0a\x20\x20\x20\x20\x20\x20var\x20sk\x20=\x20e.shiftKey\x20||\x20localStorage.getItem('play-shiftKey')\x20===\x20'true';\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20output.style.display\x20=\x20'block';\x0a\x20\x20\x20\x20\x20\x20outpre.innerHTML\x20=\x20'';\x0a\x20\x20\x20\x20\x20\x20run1.style.display\x20=\x20'none';\x0a\x20\x20\x20\x20\x20\x20var\x20options\x20=\x20{\x20Race:\x20sk\x20};\x0a\x20\x20\x20\x20\x20\x20running\x20=\x20transport.Run(text(code),\x20PlaygroundOutput(outpre),\x20options);\x0a\x20\x20\x20\x20\x20\x20if\x20(window.notesEnabled)\x20updatePlayStorage('onRun',\x20index,\x20e);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20onClose()\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20output.style.display\x20=\x20'none';\x0a\x20\x20\x20\x20\x20\x20run1.style.display\x20=\x20'inline-block';\x0a\x20\x20\x20\x20\x20\x20if\x20(window.notesEnabled)\x20updatePlayStorage('onClose',\x20index);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20if\x20(window.notesEnabled)\x20{\x0a\x20\x20\x20\x20\x20\x20playgroundHandlers.onRun.push(onRun);\x0a\x20\x20\x20\x20\x20\x20playgroundHandlers.onClose.push(onClose);\x0a\x20\x20\x20\x20\x20\x20playgroundHandlers.onKill.push(onKill);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20var\x20run1\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20run1.innerHTML\x20=\x20'Run';\x0a\x20\x20\x20\x20run1.className\x20=\x20'run';\x0a\x20\x20\x20\x20run1.addEventListener('click',\x20onRun,\x20false);\x0a\x20\x20\x20\x20var\x20run2\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20run2.className\x20=\x20'run';\x0a\x20\x20\x20\x20run2.innerHTML\x20=\x20'Run';\x0a\x20\x20\x20\x20run2.addEventListener('click',\x20onRun,\x20false);\x0a\x20\x20\x20\x20var\x20kill\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20kill.className\x20=\x20'kill';\x0a\x20\x20\x20\x20kill.innerHTML\x20=\x20'Kill';\x0a\x20\x20\x20\x20kill.addEventListener('click',\x20onKill,\x20false);\x0a\x20\x20\x20\x20var\x20close\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20close.className\x20=\x20'close';\x0a\x20\x20\x20\x20close.innerHTML\x20=\x20'Close';\x0a\x20\x20\x20\x20close.addEventListener('click',\x20onClose,\x20false);\x0a\x0a\x20\x20\x20\x20var\x20button\x20=\x20document.createElement('div');\x0a\x20\x20\x20\x20button.classList.add('buttons');\x0a\x20\x20\x20\x20button.appendChild(run1);\x0a\x20\x20\x20\x20//\x20Hack\x20to\x20simulate\x20insertAfter\x0a\x20\x20\x20\x20code.parentNode.insertBefore(button,\x20code.nextSibling);\x0a\x0a\x20\x20\x20\x20var\x20buttons\x20=\x20document.createElement('div');\x0a\x20\x20\x20\x20buttons.classList.add('buttons');\x0a\x20\x20\x20\x20buttons.appendChild(run2);\x0a\x20\x20\x20\x20buttons.appendChild(kill);\x0a\x20\x20\x20\x20buttons.appendChild(close);\x0a\x0a\x20\x20\x20\x20output.classList.add('output');\x0a\x20\x20\x20\x20output.appendChild(buttons);\x0a\x20\x20\x20\x20output.appendChild(outpre);\x0a\x20\x20\x20\x20output.style.display\x20=\x20'none';\x0a\x20\x20\x20\x20code.parentNode.insertBefore(output,\x20button.nextSibling);\x0a\x20\x20}\x0a\x0a\x20\x20var\x20play\x20=\x20document.querySelectorAll('div.playground');\x0a\x20\x20for\x20(var\x20i\x20=\x200;\x20i\x20<\x20play.length;\x20i++)\x20{\x0a\x20\x20\x20\x20init(play[i],\x20i);\x0a\x20\x20}\x0a}\x0a",
+	"play.js": "//\x20Copyright\x202012\x20The\x20Go\x20Authors.\x20All\x20rights\x20reserved.\x0a//\x20Use\x20of\x20this\x20source\x20code\x20is\x20governed\x20by\x20a\x20BSD-style\x0a//\x20license\x20that\x20can\x20be\x20found\x20in\x20the\x20LICENSE\x20file.\x0a\x0afunction\x20initPlayground(transport)\x20{\x0a\x20\x20'use\x20strict';\x0a\x0a\x20\x20function\x20text(node)\x20{\x0a\x20\x20\x20\x20var\x20s\x20=\x20'';\x0a\x20\x20\x20\x20for\x20(var\x20i\x20=\x200;\x20i\x20<\x20node.childNodes.length;\x20i++)\x20{\x0a\x20\x20\x20\x20\x20\x20var\x20n\x20=\x20node.childNodes[i];\x0a\x20\x20\x20\x20\x20\x20if\x20(n.nodeType\x20===\x201)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(n.tagName\x20===\x20'BUTTON')\x20continue;\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(n.tagName\x20===\x20'SPAN'\x20&&\x20n.className\x20===\x20'number')\x20continue;\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(n.tagName\x20===\x20'DIV'\x20||\x20n.tagName\x20==\x20'BR')\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20s\x20+=\x20'\\n';\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20s\x20+=\x20text(n);\x0a\x20\x20\x20\x20\x20\x20\x20\x20continue;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20if\x20(n.nodeType\x20===\x203)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20s\x20+=\x20n.nodeValue;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20return\x20s.replace('\\xA0',\x20'\x20');\x20//\x20replace\x20non-breaking\x20spaces\x0a\x20\x20}\x0a\x0a\x20\x20//\x20When\x20presenter\x20notes\x20are\x20enabled,\x20the\x20index\x20passed\x0a\x20\x20//\x20here\x20will\x20identify\x20the\x20playground\x20to\x20be\x20synced\x0a\x20\x20function\x20init(code,\x20index)\x20{\x0a\x20\x20\x20\x20var\x20output\x20=\x20document.createElement('div');\x0a\x20\x20\x20\x20var\x20outpre\x20=\x20document.createElement('pre');\x0a\x20\x20\x20\x20var\x20running;\x0a\x0a\x20\x20\x20\x20if\x20($\x20&&\x20$(output).resizable)\x20{\x0a\x20\x20\x20\x20\x20\x20$(output).resizable({\x0a\x20\x20\x20\x20\x20\x20\x20\x20handles:\x20'n,w,nw',\x0a\x20\x20\x20\x20\x20\x20\x20\x20minHeight:\x2027,\x0a\x20\x20\x20\x20\x20\x20\x20\x20minWidth:\x20135,\x0a\x20\x20\x20\x20\x20\x20\x20\x20maxHeight:\x20608,\x0a\x20\x20\x20\x20\x20\x20\x20\x20maxWidth:\x20990,\x0a\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20onKill()\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20if\x20(window.notesEnabled)\x20updatePlayStorage('onKill',\x20index);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20onRun(e)\x20{\x0a\x20\x20\x20\x20\x20\x20var\x20sk\x20=\x20e.shiftKey\x20||\x20localStorage.getItem('play-shiftKey')\x20===\x20'true';\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20output.style.display\x20=\x20'block';\x0a\x20\x20\x20\x20\x20\x20outpre.textContent\x20=\x20'';\x0a\x20\x20\x20\x20\x20\x20run1.style.display\x20=\x20'none';\x0a\x20\x20\x20\x20\x20\x20var\x20options\x20=\x20{\x20Race:\x20sk\x20};\x0a\x20\x20\x20\x20\x20\x20running\x20=\x20transport.Run(text(code),\x20PlaygroundOutput(outpre),\x20options);\x0a\x20\x20\x20\x20\x20\x20if\x20(window.notesEnabled)\x20updatePlayStorage('onRun',\x20index,\x20e);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20onClose()\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20output.style.display\x20=\x20'none';\x0a\x20\x20\x20\x20\x20\x20run1.style.display\x20=\x20'inline-block';\x0a\x20\x20\x20\x20\x20\x20if\x20(window.notesEnabled)\x20updatePlayStorage('onClose',\x20index);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20if\x20(window.notesEnabled)\x20{\x0a\x20\x20\x20\x20\x20\x20playgroundHandlers.onRun.push(onRun);\x0a\x20\x20\x20\x20\x20\x20playgroundHandlers.onClose.push(onClose);\x0a\x20\x20\x20\x20\x20\x20playgroundHandlers.onKill.push(onKill);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20var\x20run1\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20run1.textContent\x20=\x20'Run';\x0a\x20\x20\x20\x20run1.className\x20=\x20'run';\x0a\x20\x20\x20\x20run1.addEventListener('click',\x20onRun,\x20false);\x0a\x20\x20\x20\x20var\x20run2\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20run2.className\x20=\x20'run';\x0a\x20\x20\x20\x20run2.textContent\x20=\x20'Run';\x0a\x20\x20\x20\x20run2.addEventListener('click',\x20onRun,\x20false);\x0a\x20\x20\x20\x20var\x20kill\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20kill.className\x20=\x20'kill';\x0a\x20\x20\x20\x20kill.textContent\x20=\x20'Kill';\x0a\x20\x20\x20\x20kill.addEventListener('click',\x20onKill,\x20false);\x0a\x20\x20\x20\x20var\x20close\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20close.className\x20=\x20'close';\x0a\x20\x20\x20\x20close.textContent\x20=\x20'Close';\x0a\x20\x20\x20\x20close.addEventListener('click',\x20onClose,\x20false);\x0a\x0a\x20\x20\x20\x20var\x20button\x20=\x20document.createElement('div');\x0a\x20\x20\x20\x20button.classList.add('buttons');\x0a\x20\x20\x20\x20button.appendChild(run1);\x0a\x20\x20\x20\x20//\x20Hack\x20to\x20simulate\x20insertAfter\x0a\x20\x20\x20\x20code.parentNode.insertBefore(button,\x20code.nextSibling);\x0a\x0a\x20\x20\x20\x20var\x20buttons\x20=\x20document.createElement('div');\x0a\x20\x20\x20\x20buttons.classList.add('buttons');\x0a\x20\x20\x20\x20buttons.appendChild(run2);\x0a\x20\x20\x20\x20buttons.appendChild(kill);\x0a\x20\x20\x20\x20buttons.appendChild(close);\x0a\x0a\x20\x20\x20\x20output.classList.add('output');\x0a\x20\x20\x20\x20output.appendChild(buttons);\x0a\x20\x20\x20\x20output.appendChild(outpre);\x0a\x20\x20\x20\x20output.style.display\x20=\x20'none';\x0a\x20\x20\x20\x20code.parentNode.insertBefore(output,\x20button.nextSibling);\x0a\x20\x20}\x0a\x0a\x20\x20var\x20play\x20=\x20document.querySelectorAll('div.playground');\x0a\x20\x20for\x20(var\x20i\x20=\x200;\x20i\x20<\x20play.length;\x20i++)\x20{\x0a\x20\x20\x20\x20init(play[i],\x20i);\x0a\x20\x20}\x0a}\x0a",
 
 	"playground.js": "//\x20Copyright\x202012\x20The\x20Go\x20Authors.\x20All\x20rights\x20reserved.\x0a//\x20Use\x20of\x20this\x20source\x20code\x20is\x20governed\x20by\x20a\x20BSD-style\x0a//\x20license\x20that\x20can\x20be\x20found\x20in\x20the\x20LICENSE\x20file.\x0a\x0a/*\x0aIn\x20the\x20absence\x20of\x20any\x20formal\x20way\x20to\x20specify\x20interfaces\x20in\x20JavaScript,\x0ahere's\x20a\x20skeleton\x20implementation\x20of\x20a\x20playground\x20transport.\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20function\x20Transport()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20Set\x20up\x20any\x20transport\x20state\x20(eg,\x20make\x20a\x20websocket\x20connection).\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20return\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Run:\x20function(body,\x20output,\x20options)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20Compile\x20and\x20run\x20the\x20program\x20'body'\x20with\x20'options'.\x0a\x09\x09\x09\x09//\x20Call\x20the\x20'output'\x20callback\x20to\x20display\x20program\x20output.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20return\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Kill:\x20function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20Kill\x20the\x20running\x20program.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20};\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20};\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x0a\x09//\x20The\x20output\x20callback\x20is\x20called\x20multiple\x20times,\x20and\x20each\x20time\x20it\x20is\x0a\x09//\x20passed\x20an\x20object\x20of\x20this\x20form.\x0a\x20\x20\x20\x20\x20\x20\x20\x20var\x20write\x20=\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Kind:\x20'string',\x20//\x20'start',\x20'stdout',\x20'stderr',\x20'end'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Body:\x20'string'\x20\x20//\x20content\x20of\x20write\x20or\x20end\x20status\x20message\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x0a\x09//\x20The\x20first\x20call\x20must\x20be\x20of\x20Kind\x20'start'\x20with\x20no\x20body.\x0a\x09//\x20Subsequent\x20calls\x20may\x20be\x20of\x20Kind\x20'stdout'\x20or\x20'stderr'\x0a\x09//\x20and\x20must\x20have\x20a\x20non-null\x20Body\x20string.\x0a\x09//\x20The\x20final\x20call\x20should\x20be\x20of\x20Kind\x20'end'\x20with\x20an\x20optional\x0a\x09//\x20Body\x20string,\x20signifying\x20a\x20failure\x20(\"killed\",\x20for\x20example).\x0a\x0a\x09//\x20The\x20output\x20callback\x20must\x20be\x20of\x20this\x20form.\x0a\x09//\x20See\x20PlaygroundOutput\x20(below)\x20for\x20an\x20implementation.\x0a\x20\x20\x20\x20\x20\x20\x20\x20function\x20outputCallback(write)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a*/\x0a\x0a//\x20HTTPTransport\x20is\x20the\x20default\x20transport.\x0a//\x20enableVet\x20enables\x20running\x20vet\x20if\x20a\x20program\x20was\x20compiled\x20and\x20ran\x20successfully.\x0a//\x20If\x20vet\x20returned\x20any\x20errors,\x20display\x20them\x20before\x20the\x20output\x20of\x20a\x20program.\x0afunction\x20HTTPTransport(enableVet)\x20{\x0a\x20\x20'use\x20strict';\x0a\x0a\x20\x20function\x20playback(output,\x20data)\x20{\x0a\x20\x20\x20\x20//\x20Backwards\x20compatibility:\x20default\x20values\x20do\x20not\x20affect\x20the\x20output.\x0a\x20\x20\x20\x20var\x20events\x20=\x20data.Events\x20||\x20[];\x0a\x20\x20\x20\x20var\x20errors\x20=\x20data.Errors\x20||\x20'';\x0a\x20\x20\x20\x20var\x20status\x20=\x20data.Status\x20||\x200;\x0a\x20\x20\x20\x20var\x20isTest\x20=\x20data.IsTest\x20||\x20false;\x0a\x20\x20\x20\x20var\x20testsFailed\x20=\x20data.TestsFailed\x20||\x200;\x0a\x0a\x20\x20\x20\x20var\x20timeout;\x0a\x20\x20\x20\x20output({\x20Kind:\x20'start'\x20});\x0a\x20\x20\x20\x20function\x20next()\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(!events\x20||\x20events.length\x20===\x200)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(isTest)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(testsFailed\x20>\x200)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20output({\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Kind:\x20'system',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Body:\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'\\n'\x20+\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20testsFailed\x20+\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'\x20test'\x20+\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(testsFailed\x20>\x201\x20?\x20's'\x20:\x20'')\x20+\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'\x20failed.',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20output({\x20Kind:\x20'system',\x20Body:\x20'\\nAll\x20tests\x20passed.'\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(status\x20>\x200)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20output({\x20Kind:\x20'end',\x20Body:\x20'status\x20'\x20+\x20status\x20+\x20'.'\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(errors\x20!==\x20'')\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20errors\x20are\x20displayed\x20only\x20in\x20the\x20case\x20of\x20timeout.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20output({\x20Kind:\x20'end',\x20Body:\x20errors\x20+\x20'.'\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20output({\x20Kind:\x20'end'\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20var\x20e\x20=\x20events.shift();\x0a\x20\x20\x20\x20\x20\x20if\x20(e.Delay\x20===\x200)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20output({\x20Kind:\x20e.Kind,\x20Body:\x20e.Message\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20next();\x0a\x20\x20\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20timeout\x20=\x20setTimeout(function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20output({\x20Kind:\x20e.Kind,\x20Body:\x20e.Message\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20next();\x0a\x20\x20\x20\x20\x20\x20},\x20e.Delay\x20/\x201000000);\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20next();\x0a\x20\x20\x20\x20return\x20{\x0a\x20\x20\x20\x20\x20\x20Stop:\x20function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20clearTimeout(timeout);\x0a\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20};\x0a\x20\x20}\x0a\x0a\x20\x20function\x20error(output,\x20msg)\x20{\x0a\x20\x20\x20\x20output({\x20Kind:\x20'start'\x20});\x0a\x20\x20\x20\x20output({\x20Kind:\x20'stderr',\x20Body:\x20msg\x20});\x0a\x20\x20\x20\x20output({\x20Kind:\x20'end'\x20});\x0a\x20\x20}\x0a\x0a\x20\x20function\x20buildFailed(output,\x20msg)\x20{\x0a\x20\x20\x20\x20output({\x20Kind:\x20'start'\x20});\x0a\x20\x20\x20\x20output({\x20Kind:\x20'stderr',\x20Body:\x20msg\x20});\x0a\x20\x20\x20\x20output({\x20Kind:\x20'system',\x20Body:\x20'\\nGo\x20build\x20failed.'\x20});\x0a\x20\x20}\x0a\x0a\x20\x20var\x20seq\x20=\x200;\x0a\x20\x20return\x20{\x0a\x20\x20\x20\x20Run:\x20function(body,\x20output,\x20options)\x20{\x0a\x20\x20\x20\x20\x20\x20seq++;\x0a\x20\x20\x20\x20\x20\x20var\x20cur\x20=\x20seq;\x0a\x20\x20\x20\x20\x20\x20var\x20playing;\x0a\x20\x20\x20\x20\x20\x20$.ajax('/compile',\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20type:\x20'POST',\x0a\x20\x20\x20\x20\x20\x20\x20\x20data:\x20{\x20version:\x202,\x20body:\x20body,\x20withVet:\x20enableVet\x20},\x0a\x20\x20\x20\x20\x20\x20\x20\x20dataType:\x20'json',\x0a\x20\x20\x20\x20\x20\x20\x20\x20success:\x20function(data)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(seq\x20!=\x20cur)\x20return;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(!data)\x20return;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(playing\x20!=\x20null)\x20playing.Stop();\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(data.Errors)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(data.Errors\x20===\x20'process\x20took\x20too\x20long')\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20Playback\x20the\x20output\x20that\x20was\x20captured\x20before\x20the\x20timeout.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20playing\x20=\x20playback(output,\x20data);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20buildFailed(output,\x20data.Errors);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(!data.Events)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20data.Events\x20=\x20[];\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(data.VetErrors)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20Inject\x20errors\x20from\x20the\x20vet\x20as\x20the\x20first\x20events\x20in\x20the\x20output.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20data.Events.unshift({\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Message:\x20'Go\x20vet\x20exited.\\n\\n',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Kind:\x20'system',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Delay:\x200,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20data.Events.unshift({\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Message:\x20data.VetErrors,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Kind:\x20'stderr',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Delay:\x200,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(!enableVet\x20||\x20data.VetOK\x20||\x20data.VetErrors)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20playing\x20=\x20playback(output,\x20data);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20In\x20case\x20the\x20server\x20support\x20doesn't\x20support\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20compile+vet\x20in\x20same\x20request\x20signaled\x20by\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20'withVet'\x20parameter\x20above,\x20also\x20try\x20the\x20old\x20way.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20TODO:\x20remove\x20this\x20when\x20it\x20falls\x20out\x20of\x20use.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20It\x20is\x202019-05-13\x20now.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20$.ajax('/vet',\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20data:\x20{\x20body:\x20body\x20},\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20type:\x20'POST',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20dataType:\x20'json',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20success:\x20function(dataVet)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(dataVet.Errors)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20inject\x20errors\x20from\x20the\x20vet\x20as\x20the\x20first\x20events\x20in\x20the\x20output\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20data.Events.unshift({\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Message:\x20'Go\x20vet\x20exited.\\n\\n',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Kind:\x20'system',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Delay:\x200,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20data.Events.unshift({\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Message:\x20dataVet.Errors,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Kind:\x20'stderr',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Delay:\x200,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20playing\x20=\x20playback(output,\x20data);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20error:\x20function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20playing\x20=\x20playback(output,\x20data);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20\x20\x20\x20\x20error:\x20function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20error(output,\x20'Error\x20communicating\x20with\x20remote\x20server.');\x0a\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20return\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Kill:\x20function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(playing\x20!=\x20null)\x20playing.Stop();\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20output({\x20Kind:\x20'end',\x20Body:\x20'killed'\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20\x20\x20};\x0a\x20\x20\x20\x20},\x0a\x20\x20};\x0a}\x0a\x0afunction\x20SocketTransport()\x20{\x0a\x20\x20'use\x20strict';\x0a\x0a\x20\x20var\x20id\x20=\x200;\x0a\x20\x20var\x20outputs\x20=\x20{};\x0a\x20\x20var\x20started\x20=\x20{};\x0a\x20\x20var\x20websocket;\x0a\x20\x20if\x20(window.location.protocol\x20==\x20'http:')\x20{\x0a\x20\x20\x20\x20websocket\x20=\x20new\x20WebSocket('ws://'\x20+\x20window.location.host\x20+\x20'/socket');\x0a\x20\x20}\x20else\x20if\x20(window.location.protocol\x20==\x20'https:')\x20{\x0a\x20\x20\x20\x20websocket\x20=\x20new\x20WebSocket('wss://'\x20+\x20window.location.host\x20+\x20'/socket');\x0a\x20\x20}\x0a\x0a\x20\x20websocket.onclose\x20=\x20function()\x20{\x0a\x20\x20\x20\x20console.log('websocket\x20connection\x20closed');\x0a\x20\x20};\x0a\x0a\x20\x20websocket.onmessage\x20=\x20function(e)\x20{\x0a\x20\x20\x20\x20var\x20m\x20=\x20JSON.parse(e.data);\x0a\x20\x20\x20\x20var\x20output\x20=\x20outputs[m.Id];\x0a\x20\x20\x20\x20if\x20(output\x20===\x20null)\x20return;\x0a\x20\x20\x20\x20if\x20(!started[m.Id])\x20{\x0a\x20\x20\x20\x20\x20\x20output({\x20Kind:\x20'start'\x20});\x0a\x20\x20\x20\x20\x20\x20started[m.Id]\x20=\x20true;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20output({\x20Kind:\x20m.Kind,\x20Body:\x20m.Body\x20});\x0a\x20\x20};\x0a\x0a\x20\x20function\x20send(m)\x20{\x0a\x20\x20\x20\x20websocket.send(JSON.stringify(m));\x0a\x20\x20}\x0a\x0a\x20\x20return\x20{\x0a\x20\x20\x20\x20Run:\x20function(body,\x20output,\x20options)\x20{\x0a\x20\x20\x20\x20\x20\x20var\x20thisID\x20=\x20id\x20+\x20'';\x0a\x20\x20\x20\x20\x20\x20id++;\x0a\x20\x20\x20\x20\x20\x20outputs[thisID]\x20=\x20output;\x0a\x20\x20\x20\x20\x20\x20send({\x20Id:\x20thisID,\x20Kind:\x20'run',\x20Body:\x20body,\x20Options:\x20options\x20});\x0a\x20\x20\x20\x20\x20\x20return\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Kill:\x20function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20send({\x20Id:\x20thisID,\x20Kind:\x20'kill'\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20\x20\x20};\x0a\x20\x20\x20\x20},\x0a\x20\x20};\x0a}\x0a\x0afunction\x20PlaygroundOutput(el)\x20{\x0a\x20\x20'use\x20strict';\x0a\x0a\x20\x20return\x20function(write)\x20{\x0a\x20\x20\x20\x20if\x20(write.Kind\x20==\x20'start')\x20{\x0a\x20\x20\x20\x20\x20\x20el.innerHTML\x20=\x20'';\x0a\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20var\x20cl\x20=\x20'system';\x0a\x20\x20\x20\x20if\x20(write.Kind\x20==\x20'stdout'\x20||\x20write.Kind\x20==\x20'stderr')\x20cl\x20=\x20write.Kind;\x0a\x0a\x20\x20\x20\x20var\x20m\x20=\x20write.Body;\x0a\x20\x20\x20\x20if\x20(write.Kind\x20==\x20'end')\x20{\x0a\x20\x20\x20\x20\x20\x20m\x20=\x20'\\nProgram\x20exited'\x20+\x20(m\x20?\x20':\x20'\x20+\x20m\x20:\x20'.');\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20if\x20(m.indexOf('IMAGE:')\x20===\x200)\x20{\x0a\x20\x20\x20\x20\x20\x20//\x20TODO(adg):\x20buffer\x20all\x20writes\x20before\x20creating\x20image\x0a\x20\x20\x20\x20\x20\x20var\x20url\x20=\x20'data:image/png;base64,'\x20+\x20m.substr(6);\x0a\x20\x20\x20\x20\x20\x20var\x20img\x20=\x20document.createElement('img');\x0a\x20\x20\x20\x20\x20\x20img.src\x20=\x20url;\x0a\x20\x20\x20\x20\x20\x20el.appendChild(img);\x0a\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20//\x20^L\x20clears\x20the\x20screen.\x0a\x20\x20\x20\x20var\x20s\x20=\x20m.split('\\x0c');\x0a\x20\x20\x20\x20if\x20(s.length\x20>\x201)\x20{\x0a\x20\x20\x20\x20\x20\x20el.innerHTML\x20=\x20'';\x0a\x20\x20\x20\x20\x20\x20m\x20=\x20s.pop();\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20m\x20=\x20m.replace(/&/g,\x20'&amp;');\x0a\x20\x20\x20\x20m\x20=\x20m.replace(/</g,\x20'&lt;');\x0a\x20\x20\x20\x20m\x20=\x20m.replace(/>/g,\x20'&gt;');\x0a\x0a\x20\x20\x20\x20var\x20needScroll\x20=\x20el.scrollTop\x20+\x20el.offsetHeight\x20==\x20el.scrollHeight;\x0a\x0a\x20\x20\x20\x20var\x20span\x20=\x20document.createElement('span');\x0a\x20\x20\x20\x20span.className\x20=\x20cl;\x0a\x20\x20\x20\x20span.innerHTML\x20=\x20m;\x0a\x20\x20\x20\x20el.appendChild(span);\x0a\x0a\x20\x20\x20\x20if\x20(needScroll)\x20el.scrollTop\x20=\x20el.scrollHeight\x20-\x20el.offsetHeight;\x0a\x20\x20};\x0a}\x0a\x0a(function()\x20{\x0a\x20\x20function\x20lineHighlight(error)\x20{\x0a\x20\x20\x20\x20var\x20regex\x20=\x20/prog.go:([0-9]+)/g;\x0a\x20\x20\x20\x20var\x20r\x20=\x20regex.exec(error);\x0a\x20\x20\x20\x20while\x20(r)\x20{\x0a\x20\x20\x20\x20\x20\x20$('.lines\x20div')\x0a\x20\x20\x20\x20\x20\x20\x20\x20.eq(r[1]\x20-\x201)\x0a\x20\x20\x20\x20\x20\x20\x20\x20.addClass('lineerror');\x0a\x20\x20\x20\x20\x20\x20r\x20=\x20regex.exec(error);\x0a\x20\x20\x20\x20}\x0a\x20\x20}\x0a\x20\x20function\x20highlightOutput(wrappedOutput)\x20{\x0a\x20\x20\x20\x20return\x20function(write)\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(write.Body)\x20lineHighlight(write.Body);\x0a\x20\x20\x20\x20\x20\x20wrappedOutput(write);\x0a\x20\x20\x20\x20};\x0a\x20\x20}\x0a\x20\x20function\x20lineClear()\x20{\x0a\x20\x20\x20\x20$('.lineerror').removeClass('lineerror');\x0a\x20\x20}\x0a\x0a\x20\x20//\x20opts\x20is\x20an\x20object\x20with\x20these\x20keys\x0a\x20\x20//\x20\x20codeEl\x20-\x20code\x20editor\x20element\x0a\x20\x20//\x20\x20outputEl\x20-\x20program\x20output\x20element\x0a\x20\x20//\x20\x20runEl\x20-\x20run\x20button\x20element\x0a\x20\x20//\x20\x20fmtEl\x20-\x20fmt\x20button\x20element\x20(optional)\x0a\x20\x20//\x20\x20fmtImportEl\x20-\x20fmt\x20\"imports\"\x20checkbox\x20element\x20(optional)\x0a\x20\x20//\x20\x20shareEl\x20-\x20share\x20button\x20element\x20(optional)\x0a\x20\x20//\x20\x20shareURLEl\x20-\x20share\x20URL\x20text\x20input\x20element\x20(optional)\x0a\x20\x20//\x20\x20shareRedirect\x20-\x20base\x20URL\x20to\x20redirect\x20to\x20on\x20share\x20(optional)\x0a\x20\x20//\x20\x20toysEl\x20-\x20toys\x20select\x20element\x20(optional)\x0a\x20\x20//\x20\x20enableHistory\x20-\x20enable\x20using\x20HTML5\x20history\x20API\x20(optional)\x0a\x20\x20//\x20\x20transport\x20-\x20playground\x20transport\x20to\x20use\x20(default\x20is\x20HTTPTransport)\x0a\x20\x20//\x20\x20enableShortcuts\x20-\x20whether\x20to\x20enable\x20shortcuts\x20(Ctrl+S/Cmd+S\x20to\x20save)\x20(default\x20is\x20false)\x0a\x20\x20//\x20\x20enableVet\x20-\x20enable\x20running\x20vet\x20and\x20displaying\x20its\x20errors\x0a\x20\x20function\x20playground(opts)\x20{\x0a\x20\x20\x20\x20var\x20code\x20=\x20$(opts.codeEl);\x0a\x20\x20\x20\x20var\x20transport\x20=\x20opts['transport']\x20||\x20new\x20HTTPTransport(opts['enableVet']);\x0a\x20\x20\x20\x20var\x20running;\x0a\x0a\x20\x20\x20\x20//\x20autoindent\x20helpers.\x0a\x20\x20\x20\x20function\x20insertTabs(n)\x20{\x0a\x20\x20\x20\x20\x20\x20//\x20find\x20the\x20selection\x20start\x20and\x20end\x0a\x20\x20\x20\x20\x20\x20var\x20start\x20=\x20code[0].selectionStart;\x0a\x20\x20\x20\x20\x20\x20var\x20end\x20=\x20code[0].selectionEnd;\x0a\x20\x20\x20\x20\x20\x20//\x20split\x20the\x20textarea\x20content\x20into\x20two,\x20and\x20insert\x20n\x20tabs\x0a\x20\x20\x20\x20\x20\x20var\x20v\x20=\x20code[0].value;\x0a\x20\x20\x20\x20\x20\x20var\x20u\x20=\x20v.substr(0,\x20start);\x0a\x20\x20\x20\x20\x20\x20for\x20(var\x20i\x20=\x200;\x20i\x20<\x20n;\x20i++)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20u\x20+=\x20'\\t';\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20u\x20+=\x20v.substr(end);\x0a\x20\x20\x20\x20\x20\x20//\x20set\x20revised\x20content\x0a\x20\x20\x20\x20\x20\x20code[0].value\x20=\x20u;\x0a\x20\x20\x20\x20\x20\x20//\x20reset\x20caret\x20position\x20after\x20inserted\x20tabs\x0a\x20\x20\x20\x20\x20\x20code[0].selectionStart\x20=\x20start\x20+\x20n;\x0a\x20\x20\x20\x20\x20\x20code[0].selectionEnd\x20=\x20start\x20+\x20n;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20function\x20autoindent(el)\x20{\x0a\x20\x20\x20\x20\x20\x20var\x20curpos\x20=\x20el.selectionStart;\x0a\x20\x20\x20\x20\x20\x20var\x20tabs\x20=\x200;\x0a\x20\x20\x20\x20\x20\x20while\x20(curpos\x20>\x200)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20curpos--;\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(el.value[curpos]\x20==\x20'\\t')\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20tabs++;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20if\x20(tabs\x20>\x200\x20||\x20el.value[curpos]\x20==\x20'\\n')\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20break;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20setTimeout(function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20insertTabs(tabs);\x0a\x20\x20\x20\x20\x20\x20},\x201);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20//\x20NOTE(cbro):\x20e\x20is\x20a\x20jQuery\x20event,\x20not\x20a\x20DOM\x20event.\x0a\x20\x20\x20\x20function\x20handleSaveShortcut(e)\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(e.isDefaultPrevented())\x20return\x20false;\x0a\x20\x20\x20\x20\x20\x20if\x20(!e.metaKey\x20&&\x20!e.ctrlKey)\x20return\x20false;\x0a\x20\x20\x20\x20\x20\x20if\x20(e.key\x20!=\x20'S'\x20&&\x20e.key\x20!=\x20's')\x20return\x20false;\x0a\x0a\x20\x20\x20\x20\x20\x20e.preventDefault();\x0a\x0a\x20\x20\x20\x20\x20\x20//\x20Share\x20and\x20save\x0a\x20\x20\x20\x20\x20\x20share(function(url)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20window.location.href\x20=\x20url\x20+\x20'.go?download=true';\x0a\x20\x20\x20\x20\x20\x20});\x0a\x0a\x20\x20\x20\x20\x20\x20return\x20true;\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20keyHandler(e)\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(opts.enableShortcuts\x20&&\x20handleSaveShortcut(e))\x20return;\x0a\x0a\x20\x20\x20\x20\x20\x20if\x20(e.keyCode\x20==\x209\x20&&\x20!e.ctrlKey)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20//\x20tab\x20(but\x20not\x20ctrl-tab)\x0a\x20\x20\x20\x20\x20\x20\x20\x20insertTabs(1);\x0a\x20\x20\x20\x20\x20\x20\x20\x20e.preventDefault();\x0a\x20\x20\x20\x20\x20\x20\x20\x20return\x20false;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20if\x20(e.keyCode\x20==\x2013)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20//\x20enter\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(e.shiftKey)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20+shift\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20run();\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20e.preventDefault();\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20return\x20false;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(e.ctrlKey)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20+control\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fmt();\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20e.preventDefault();\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20autoindent(e.target);\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20return\x20true;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20code.unbind('keydown').bind('keydown',\x20keyHandler);\x0a\x20\x20\x20\x20var\x20outdiv\x20=\x20$(opts.outputEl).empty();\x0a\x20\x20\x20\x20var\x20output\x20=\x20$('<pre/>').appendTo(outdiv);\x0a\x0a\x20\x20\x20\x20function\x20body()\x20{\x0a\x20\x20\x20\x20\x20\x20return\x20$(opts.codeEl).val();\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20function\x20setBody(text)\x20{\x0a\x20\x20\x20\x20\x20\x20$(opts.codeEl).val(text);\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20function\x20origin(href)\x20{\x0a\x20\x20\x20\x20\x20\x20return\x20(''\x20+\x20href)\x0a\x20\x20\x20\x20\x20\x20\x20\x20.split('/')\x0a\x20\x20\x20\x20\x20\x20\x20\x20.slice(0,\x203)\x0a\x20\x20\x20\x20\x20\x20\x20\x20.join('/');\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20var\x20pushedEmpty\x20=\x20window.location.pathname\x20==\x20'/';\x0a\x20\x20\x20\x20function\x20inputChanged()\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(pushedEmpty)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20pushedEmpty\x20=\x20true;\x0a\x20\x20\x20\x20\x20\x20$(opts.shareURLEl).hide();\x0a\x20\x20\x20\x20\x20\x20window.history.pushState(null,\x20'',\x20'/');\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20function\x20popState(e)\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(e\x20===\x20null)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20if\x20(e\x20&&\x20e.state\x20&&\x20e.state.code)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20setBody(e.state.code);\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20var\x20rewriteHistory\x20=\x20false;\x0a\x20\x20\x20\x20if\x20(\x0a\x20\x20\x20\x20\x20\x20window.history\x20&&\x0a\x20\x20\x20\x20\x20\x20window.history.pushState\x20&&\x0a\x20\x20\x20\x20\x20\x20window.addEventListener\x20&&\x0a\x20\x20\x20\x20\x20\x20opts.enableHistory\x0a\x20\x20\x20\x20)\x20{\x0a\x20\x20\x20\x20\x20\x20rewriteHistory\x20=\x20true;\x0a\x20\x20\x20\x20\x20\x20code[0].addEventListener('input',\x20inputChanged);\x0a\x20\x20\x20\x20\x20\x20window.addEventListener('popstate',\x20popState);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20setError(error)\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20lineClear();\x0a\x20\x20\x20\x20\x20\x20lineHighlight(error);\x0a\x20\x20\x20\x20\x20\x20output\x0a\x20\x20\x20\x20\x20\x20\x20\x20.empty()\x0a\x20\x20\x20\x20\x20\x20\x20\x20.addClass('error')\x0a\x20\x20\x20\x20\x20\x20\x20\x20.text(error);\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20function\x20loading()\x20{\x0a\x20\x20\x20\x20\x20\x20lineClear();\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20output.removeClass('error').text('Waiting\x20for\x20remote\x20server...');\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20function\x20run()\x20{\x0a\x20\x20\x20\x20\x20\x20loading();\x0a\x20\x20\x20\x20\x20\x20running\x20=\x20transport.Run(\x0a\x20\x20\x20\x20\x20\x20\x20\x20body(),\x0a\x20\x20\x20\x20\x20\x20\x20\x20highlightOutput(PlaygroundOutput(output[0]))\x0a\x20\x20\x20\x20\x20\x20);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20fmt()\x20{\x0a\x20\x20\x20\x20\x20\x20loading();\x0a\x20\x20\x20\x20\x20\x20var\x20data\x20=\x20{\x20body:\x20body()\x20};\x0a\x20\x20\x20\x20\x20\x20if\x20($(opts.fmtImportEl).is(':checked'))\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20data['imports']\x20=\x20'true';\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20$.ajax('/fmt',\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20data:\x20data,\x0a\x20\x20\x20\x20\x20\x20\x20\x20type:\x20'POST',\x0a\x20\x20\x20\x20\x20\x20\x20\x20dataType:\x20'json',\x0a\x20\x20\x20\x20\x20\x20\x20\x20success:\x20function(data)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(data.Error)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20setError(data.Error);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20setBody(data.Body);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20setError('');\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20var\x20shareURL;\x20//\x20jQuery\x20element\x20to\x20show\x20the\x20shared\x20URL.\x0a\x20\x20\x20\x20var\x20sharing\x20=\x20false;\x20//\x20true\x20if\x20there\x20is\x20a\x20pending\x20request.\x0a\x20\x20\x20\x20var\x20shareCallbacks\x20=\x20[];\x0a\x20\x20\x20\x20function\x20share(opt_callback)\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(opt_callback)\x20shareCallbacks.push(opt_callback);\x0a\x0a\x20\x20\x20\x20\x20\x20if\x20(sharing)\x20return;\x0a\x20\x20\x20\x20\x20\x20sharing\x20=\x20true;\x0a\x0a\x20\x20\x20\x20\x20\x20var\x20sharingData\x20=\x20body();\x0a\x20\x20\x20\x20\x20\x20$.ajax('/share',\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20processData:\x20false,\x0a\x20\x20\x20\x20\x20\x20\x20\x20data:\x20sharingData,\x0a\x20\x20\x20\x20\x20\x20\x20\x20type:\x20'POST',\x0a\x20\x20\x20\x20\x20\x20\x20\x20contentType:\x20'text/plain;\x20charset=utf-8',\x0a\x20\x20\x20\x20\x20\x20\x20\x20complete:\x20function(xhr)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20sharing\x20=\x20false;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(xhr.status\x20!=\x20200)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20alert('Server\x20error;\x20try\x20again.');\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(opts.shareRedirect)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20window.location\x20=\x20opts.shareRedirect\x20+\x20xhr.responseText;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20var\x20path\x20=\x20'/p/'\x20+\x20xhr.responseText;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20var\x20url\x20=\x20origin(window.location)\x20+\x20path;\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20for\x20(var\x20i\x20=\x200;\x20i\x20<\x20shareCallbacks.length;\x20i++)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20shareCallbacks[i](url);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20shareCallbacks\x20=\x20[];\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(shareURL)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20shareURL\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20.show()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20.val(url)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20.focus()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20.select();\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(rewriteHistory)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20var\x20historyData\x20=\x20{\x20code:\x20sharingData\x20};\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20window.history.pushState(historyData,\x20'',\x20path);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20pushedEmpty\x20=\x20false;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20$(opts.runEl).click(run);\x0a\x20\x20\x20\x20$(opts.fmtEl).click(fmt);\x0a\x0a\x20\x20\x20\x20if\x20(\x0a\x20\x20\x20\x20\x20\x20opts.shareEl\x20!==\x20null\x20&&\x0a\x20\x20\x20\x20\x20\x20(opts.shareURLEl\x20!==\x20null\x20||\x20opts.shareRedirect\x20!==\x20null)\x0a\x20\x20\x20\x20)\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(opts.shareURLEl)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20shareURL\x20=\x20$(opts.shareURLEl).hide();\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20$(opts.shareEl).click(function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20share();\x0a\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20if\x20(opts.toysEl\x20!==\x20null)\x20{\x0a\x20\x20\x20\x20\x20\x20$(opts.toysEl).bind('change',\x20function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20var\x20toy\x20=\x20$(this).val();\x0a\x20\x20\x20\x20\x20\x20\x20\x20$.ajax('/doc/play/'\x20+\x20toy,\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20processData:\x20false,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20type:\x20'GET',\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20complete:\x20function(xhr)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(xhr.status\x20!=\x20200)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20alert('Server\x20error;\x20try\x20again.');\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20setBody(xhr.responseText);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20}\x0a\x20\x20}\x0a\x0a\x20\x20window.playground\x20=\x20playground;\x0a})();\x0a",