Commit de6f0a3 1 parent e6f0721 commit de6f0a3 Copy full SHA for de6f0a3
File tree 2 files changed +17
-4
lines changed
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,22 @@ def initialize
20
20
21
21
@result = Element [ '#result-frame' ]
22
22
23
- @ruby . value = RUBY
24
-
25
23
Element . find ( '#run-code' ) . on ( :click ) { run_code }
24
+ @link = Element . find ( '#link-code' )
25
+
26
+ hash = `decodeURIComponent(location.hash)`
27
+
28
+ if hash . start_with? '#code:'
29
+ @ruby . value = hash [ 6 ..-1 ]
30
+ else
31
+ @ruby . value = RUBY . strip
32
+ end
33
+
26
34
run_code
27
35
end
28
36
29
37
def run_code
38
+ @link [ :href ] = "#code:#{ `encodeURIComponent(#{ @ruby . value } )` } "
30
39
js = Opal . compile @ruby . value
31
40
32
41
update_iframe ( <<-HTML )
@@ -48,6 +57,8 @@ def run_code
48
57
</ body>
49
58
</ html>
50
59
HTML
60
+ rescue => e
61
+ alert "#{ e . class } : #{ e . message } "
51
62
end
52
63
53
64
def update_iframe ( html )
Original file line number Diff line number Diff line change 1
-
2
1
!!!
3
2
%html
4
3
%head
15
14
%a .navbar-brand Opal Playground - RSpec
16
15
.container
17
16
.collapse.navbar-collapse
18
- %ul .nav.navbar-nav
17
+ %ul .nav.navbar-nav ( style = "padding: 7px" )
19
18
%li
20
19
%button .btn.btn-primary #run-code
21
20
Run Code (Cmd+Enter)
21
+ %li
22
+ %a .btn.btn-default #link-code (style ="padding: 6px" )
23
+ Link Code
22
24
23
25
.row
24
26
.col-md-6 (style ="height: 100%" )
You can’t perform that action at this time.
0 commit comments