Skip to content

Commit 5f17982

Browse files
author
Jonas Schubert Erlandsson
committed
Updates opal shim, removes duplication
1 parent e07149b commit 5f17982

File tree

1 file changed

+12
-30
lines changed

1 file changed

+12
-30
lines changed

opal/js/shims.js

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,25 @@
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+
}
79

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() {
1411

1512
$('script[type="application/ruby"]').each(function( idx, script ){
1613
$script = $(script);
1714
if( $script.attr('src') ){
18-
waiting++;
19-
src[idx] = null;
2015
$.ajax({
2116
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
3218
});
3319
} else {
34-
//src[idx] = $script.text();
35-
var s,el;
20+
var s;
3621
s = $script.text();
37-
el = $('<pre></pre>');
38-
el.text( s );
39-
$('body').append( el );
40-
Opal.eval( s );
22+
opal_run( s );
4123
}
4224
});
4325

0 commit comments

Comments
 (0)