_content: update /play/ url to show ?v= for gotip usage
Show ?v=gotip when 'Go dev branch' is selected in the dropdown, and then also add it to playground shares. Change-Id: I38e74a9cc6285b71269f9edf2e958e1bb46def55 Reviewed-on: https://go-review.googlesource.com/c/website/+/368361 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org> Website-Publish: Russ Cox <rsc@golang.org>
This commit is contained in:
Родитель
a78844bf24
Коммит
1167ccddc1
|
@ -375,16 +375,24 @@ function PlaygroundOutput(el) {
|
||||||
.join('/');
|
.join('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
var pushedPlay = window.location.pathname == '/play';
|
var pushedPlay = window.location.pathname == '/play/';
|
||||||
function inputChanged() {
|
function inputChanged() {
|
||||||
if (pushedPlay) {
|
if (pushedPlay) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pushedPlay = true;
|
pushedPlay = true;
|
||||||
$(opts.shareURLEl).hide();
|
$(opts.shareURLEl).hide();
|
||||||
|
$(opts.toysEl).show();
|
||||||
var path = window.location.pathname;
|
var path = window.location.pathname;
|
||||||
var i = path.indexOf('/play');
|
var i = path.indexOf('/play/');
|
||||||
window.history.pushState(null, '', path.substr(0, i+5));
|
var p = path.substr(0, i+6);
|
||||||
|
if (opts.versionEl !== null) {
|
||||||
|
var v = $(opts.versionEl).val();
|
||||||
|
if (v != '') {
|
||||||
|
p += '?v=' + v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.history.pushState(null, '', p);
|
||||||
}
|
}
|
||||||
function popState(e) {
|
function popState(e) {
|
||||||
if (e === null) {
|
if (e === null) {
|
||||||
|
@ -515,8 +523,10 @@ function PlaygroundOutput(el) {
|
||||||
window.location = opts.shareRedirect + xhr.responseText;
|
window.location = opts.shareRedirect + xhr.responseText;
|
||||||
}
|
}
|
||||||
var path = '/play/p/' + xhr.responseText;
|
var path = '/play/p/' + xhr.responseText;
|
||||||
|
if (opts.versionEl !== null && $(opts.versionEl).val() != "") {
|
||||||
|
path += "?v=" + $(opts.versionEl).val();
|
||||||
|
}
|
||||||
var url = origin(window.location) + path;
|
var url = origin(window.location) + path;
|
||||||
|
|
||||||
for (var i = 0; i < shareCallbacks.length; i++) {
|
for (var i = 0; i < shareCallbacks.length; i++) {
|
||||||
shareCallbacks[i](url);
|
shareCallbacks[i](url);
|
||||||
}
|
}
|
||||||
|
@ -529,13 +539,11 @@ function PlaygroundOutput(el) {
|
||||||
.focus()
|
.focus()
|
||||||
.select();
|
.select();
|
||||||
|
|
||||||
if (opts.toysEl !== null) {
|
$(opts.toysEl).hide();
|
||||||
$(opts.toysEl).hide();
|
|
||||||
}
|
|
||||||
if (rewriteHistory) {
|
if (rewriteHistory) {
|
||||||
var historyData = { code: sharingData };
|
var historyData = { code: sharingData };
|
||||||
window.history.pushState(historyData, '', path);
|
window.history.pushState(historyData, '', path);
|
||||||
pushedEmpty = false;
|
pushedPlay = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -595,15 +603,18 @@ function PlaygroundOutput(el) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.versionEl !== null) {
|
if (opts.versionEl !== null) {
|
||||||
|
var select = $(opts.versionEl);
|
||||||
var v = (new URL(window.location)).searchParams.get('v');
|
var v = (new URL(window.location)).searchParams.get('v');
|
||||||
if (v !== null && v != "") {
|
if (v !== null && v != "") {
|
||||||
var select = $(opts.versionEl)
|
|
||||||
select.val(v);
|
select.val(v);
|
||||||
if (select.val() != v) {
|
if (select.val() != v) {
|
||||||
select.append($('<option>', {value: v, text: 'Backend: ' + v}));
|
select.append($('<option>', {value: v, text: 'Backend: ' + v}));
|
||||||
select.val(v);
|
select.val(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (opts.enableHistory) {
|
||||||
|
select.bind('change', inputChanged);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче