<ylluminate>
elia so i was thinking about adding jquery and browser to cdn. how would i go about doing that properly with the modifications you've made to building these out from src?
ylluminarious has joined #opal
elia has quit [Quit: Computer has gone to sleep.]
e_dub has quit [Read error: Connection reset by peer]
e_dub has joined #opal
grios has joined #opal
e_dub has quit [Read error: Connection reset by peer]
e_dub has joined #opal
e_dub has quit [Read error: Connection reset by peer]
<ylluminate>
i figure that might be a better place to post such a thing than here
<ylluminate>
re: require. i thought you'd implemented that in master such that we can require other .rb files within .rb scripts
<elia>
ylluminate, replying on gitter ;)
<ylluminate>
:P
alexst_ has joined #opal
alexst has quit [Ping timeout: 245 seconds]
e_dub has quit [Quit: ZZZzzz…]
e_dub has joined #opal
ylluminate has quit [Read error: Connection reset by peer]
ylluminate has joined #opal
<ylluminarious|aw>
elia: is it true that to use something like document.getElementById, you have to wrap it in `` ?
<elia>
yep
<ylluminarious|aw>
ok
<elia>
I'd probably use native to wrap document first
<elia>
$document = Native(`document`)
<elia>
and then $document.getElementById('my-id')
<elia>
or $document[:location][:href] (for accessing properties
<ylluminarious|aw>
alright
<elia>
to get back the native js object un need to use #to_n (e.g. $document.to_n)
<ylluminarious|aw>
so, like, when i write something with `` or wrap it with native, i'm writing pure javascript, right?
e_dub has quit [Quit: ZZZzzz…]
<ylluminarious|aw>
elia: i am trying to access ruby variables within some javascript like here: https://gist.github.com/43d039bc875c118f2a38 . am i doing this the right way? it feels awkward and i am of course getting an error (Unexpected token ILLEGAL) on the @ symbols on the draw method js calls
<elia>
remember that inside `` you're in js land
<elia>
and in js @ makes no sense
<elia>
if you want to grab the instance vars from opal you need to interpolate ``
<elia>
e.g. `document.getElementById("playing_field").getContext("2d").fillRect(#{@x}, #{@y}, 40, 40)`
<ylluminarious|aw>
oh, alright. that makes sense.
<ylluminarious|aw>
yeah, i guess i forgot that `` means that i'm using js, not ruby
<elia>
:)
<ylluminarious|aw>
does that make sense though? it seems that there should be a better way to access the window, document, and so forth rather than using js directly
<ylluminarious|aw>
btw, thanks for the help, elia
<elia>
np
<elia>
IIRC requiring native already prepares those global variables
<elia>
it prepares $global / $$ which in a browser is equivalent to window
<elia>
hence $document = $$[:document]
<ylluminarious|aw>
ok
<ylluminarious|aw>
could you please give me an example of `document.getElementById("playing_field").getContext("2d").fillStyle = "white"` using $$ instead?