1
Fork 0

doc: set playground to nightly for unstable code

This commit is contained in:
Cristian Kubis 2015-07-10 09:40:44 +02:00
parent 67256dff6d
commit 682a007d24

View file

@ -16,6 +16,7 @@ document.addEventListener('DOMContentLoaded', function() {
return; return;
} }
var featureRegexp = new RegExp('^\s*#!\\[feature\\(\.*?\\)\\]');
var elements = document.querySelectorAll('pre.rust'); var elements = document.querySelectorAll('pre.rust');
Array.prototype.forEach.call(elements, function(el) { Array.prototype.forEach.call(elements, function(el) {
@ -29,8 +30,14 @@ document.addEventListener('DOMContentLoaded', function() {
a.setAttribute('class', 'test-arrow'); a.setAttribute('class', 'test-arrow');
var code = el.previousElementSibling.textContent; var code = el.previousElementSibling.textContent;
var channel = '';
if (featureRegexp.test(code)) {
channel = '&version=nightly';
}
a.setAttribute('href', window.playgroundUrl + '?code=' + a.setAttribute('href', window.playgroundUrl + '?code=' +
encodeURIComponent(code)); encodeURIComponent(code) + channel);
a.setAttribute('target', '_blank'); a.setAttribute('target', '_blank');
el.appendChild(a); el.appendChild(a);