Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
1a1940c8
Commit
1a1940c8
authored
Feb 22, 2012
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc: support redirect-on-share
R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/5689056
parent
d3642699
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
12 deletions
+21
-12
doc/play/playground.js
doc/play/playground.js
+15
-6
doc/root.html
doc/root.html
+6
-6
No files found.
doc/play/playground.js
View file @
1a1940c8
...
...
@@ -8,6 +8,7 @@
// runEl - run button element
// shareEl - share button element (optional)
// shareURLEl - share URL text input element (optional)
// shareRedirect - base URL to redirect to on share (optional)
// preCompile - callback to mutate request data before compiling
// postCompile - callback to read response data after compiling
// simple - use plain textarea instead of CodeMirror.
...
...
@@ -163,7 +164,7 @@ function playground(opts) {
}
$
(
opts
[
'
runEl
'
]).
click
(
run
);
if
(
opts
[
'
shareEl
'
]
==
null
||
opts
[
'
shareURLEl
'
]
==
null
)
{
if
(
opts
[
'
shareEl
'
]
==
null
||
(
opts
[
'
shareURLEl
'
]
==
null
&&
opts
[
'
shareRedirect
'
]
==
null
)
)
{
return
editor
;
}
...
...
@@ -171,7 +172,10 @@ function playground(opts) {
return
(
""
+
href
).
split
(
"
/
"
).
slice
(
0
,
3
).
join
(
"
/
"
);
}
var
shareURL
=
$
(
opts
[
'
shareURLEl
'
]).
hide
();
var
shareURL
;
if
(
opts
[
'
shareURLEl
'
])
{
shareURL
=
$
(
opts
[
'
shareURLEl
'
]).
hide
();
}
var
sharing
=
false
;
$
(
opts
[
'
shareEl
'
]).
click
(
function
()
{
if
(
sharing
)
return
;
...
...
@@ -184,12 +188,17 @@ function playground(opts) {
sharing
=
false
;
if
(
xhr
.
status
!=
200
)
{
alert
(
"
Server error; try again.
"
);
return
return
;
}
if
(
opts
[
'
shareRedirect
'
])
{
window
.
location
=
opts
[
'
shareRedirect
'
]
+
xhr
.
responseText
;
}
if
(
shareURL
)
{
var
url
=
origin
(
window
.
location
)
+
"
/p/
"
+
xhr
.
responseText
;
shareURL
.
show
().
val
(
url
).
focus
().
select
();
}
}
});
});
...
...
doc/root.html
View file @
1a1940c8
...
...
@@ -118,7 +118,7 @@ function init() {
"
outputEl
"
:
"
#output
"
,
"
runEl
"
:
"
#run
"
,
"
shareEl
"
:
"
#share
"
,
"
share
URLEl
"
:
"
#shareURL
"
"
share
Redirect
"
:
"
http://play.golang.org/
"
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment