File tree Expand file tree Collapse file tree 1 file changed +12
-30
lines changed Expand file tree Collapse file tree 1 file changed +12
-30
lines changed Original file line number Diff line number Diff line change 1
- $ ( document ) . ready ( function ( ) {
2
-
3
- var src , waiting ;
4
-
5
- src = [ ] ;
6
- waiting = 0 ;
1
+ function opal_run ( src ) {
2
+ var el ;
3
+ el = $ ( '<pre></pre>' ) ;
4
+ el . text ( s ) ;
5
+ $ ( 'body' ) . append ( el ) ;
6
+ Opal . eval ( s ) ;
7
+ $ ( 'body' ) . append ( '<hr/>' ) ;
8
+ }
7
9
8
- $ ( document ) . on ( 'runruby' , function ( ) {
9
- src = src . join ( "\n" ) ;
10
- src = src . replace ( / \$ \( / g, 'jQuery(' ) ;
11
-
12
- Opal . eval ( src ) ;
13
- } ) ;
10
+ $ ( document ) . ready ( function ( ) {
14
11
15
12
$ ( 'script[type="application/ruby"]' ) . each ( function ( idx , script ) {
16
13
$script = $ ( script ) ;
17
14
if ( $script . attr ( 'src' ) ) {
18
- waiting ++ ;
19
- src [ idx ] = null ;
20
15
$ . ajax ( {
21
16
url : $script . attr ( 'src' ) ,
22
- success : function ( s ) {
23
- //src[idx] = s;
24
- //waiting--;
25
- //if( waiting === 0 ){ $(document).trigger('runruby'); }
26
- var el ;
27
- el = $ ( '<pre></pre>' ) ;
28
- el . text ( s ) ;
29
- $ ( 'body' ) . append ( el ) ;
30
- Opal . eval ( s ) ;
31
- }
17
+ success : opal_run
32
18
} ) ;
33
19
} else {
34
- //src[idx] = $script.text();
35
- var s , el ;
20
+ var s ;
36
21
s = $script . text ( ) ;
37
- el = $ ( '<pre></pre>' ) ;
38
- el . text ( s ) ;
39
- $ ( 'body' ) . append ( el ) ;
40
- Opal . eval ( s ) ;
22
+ opal_run ( s ) ;
41
23
}
42
24
} ) ;
43
25
You can’t perform that action at this time.
0 commit comments