These are chat archives for synrc/n2o

1st
May 2016
fxmy wang
@fxmy
May 01 2016 06:33
Are there any handy ways to query the value of certain JS variables in the webpage on the server side?
For now I was relying on exposing #api{} then manually wf:wire("raw js") and finally get them through api_event/3, which was freaking tedious.. :kissing:
Namdak Tonpa
@5HT
May 01 2016 07:29
#jq{}?
fxmy wang
@fxmy
May 01 2016 07:44
I dont think #jq{} will meet my needs as #jq{} doesnt send value back to server side. ( Or am I missing something here :smile:
Namdak Tonpa
@5HT
May 01 2016 07:44
why "query the value of certain JS variables" should send data to server?
fxmy wang
@fxmy
May 01 2016 07:48
Let me rephrase :
I'm interested in the timezone settings of the browser so I can perform some localization renderings to the user
Namdak Tonpa
@5HT
May 01 2016 07:49
just send this after N2O handshake, capture it with protocol, and only then issue the rendered elements back on websockets
in async way
there is no sync way to do this
anyway
fxmy wang
@fxmy
May 01 2016 07:51
so how to get returned value executed from JS eg. new Date().getTimezoneOffset(); back to server?
Namdak Tonpa
@5HT
May 01 2016 07:51
ws.send(enc(tuple(atom('timezone'),bin(new Date().getTimezoneOffset()))))
fxmy wang
@fxmy
May 01 2016 07:53
Looks like what I'm looking for, will try.
thank you! :kissing:
fxmy wang
@fxmy
May 01 2016 08:02
Tried ws.send(enc(tuple(atom('timezone'),bin(new Date().getTimezoneOffset())))); in web console, but got nothing in erlang shell nor event/1 :worried: How do I capture it?
fxmy wang
@fxmy
May 01 2016 08:28
ws.send(enc(tuple(atom('client'), number(new Date().getTimezoneOffset()))));
ahh, CLIENT message seems work