These are chat archives for synrc/n2o

6th
Apr 2016
Roman
@AstRonin
Apr 06 2016 10:50
@cystbear есть успехи?
Canislupax
@Canislupax
Apr 06 2016 13:42
hi all!
playing with some auth systems with n2o -> first of all i try to use the avz module -> got this compilation error from the avz master branche: Line 73: error {undefined_record,panel} in "/deps/avz/src/github.erl" i can correct this by hand or is there a better solution ?
i think the panel is now in -include_lib("nitro/include/nitro.hrl").
fxmy wang
@fxmy
Apr 06 2016 13:46
just a guess: maybe a project structure issue?
Canislupax
@Canislupax
Apr 06 2016 13:47
used a fresh n2o sample from github
only added avz under rebar...
i added the -include_lib("nitro/include/nitro.hrl"). in the avz files wich using the panel and its working correct
fxmy wang
@fxmy
Apr 06 2016 13:51
ahh. I thought that you got the undefined_record error even with -include_lib("nitro/include/nitro.hrl") :joy:
fxmy wang
@fxmy
Apr 06 2016 15:41
It seems that wiring nested #jq{} will generate ill-formed js code which broswer complains
wf:render(#jq{target=history,property=scrollTop,right=#jq{target=history,property=scrollHeight}}).
"qi('history').scrollTop = 'qi('history').scrollHeight;';"
SyntaxError: missing ; before statement
Stack trace:
onio@http://127.0.0.1:8000/n2o/n2o.js:28:11
onbert/<@http://127.0.0.1:8000/n2o/n2o.js:47:46
Is nesting #jq{} not supported or it's just I'm using it wrong? :joy:
How about a special case like this? synrc/nitro#8
Oleg Zinchenko
@cystbear
Apr 06 2016 16:09
@5HT Макс, а как mad start и stop работают? есть ли примеры
rusjava8
@rusjava8
Apr 06 2016 16:09
This message was deleted
This message was deleted
This message was deleted
Andrii Zadorozhnii
@doxtop
Apr 06 2016 17:01

@fxmy you should check the code how the jq action is rendered

render_action(Record=#jq{property=undefined,target=Target,method=Methods,args=Args0,format=_F}) ->
    Args = case Record#jq.format of "'~s'" -> [nitro:render(Args0)]; _ -> Args0 end,
    RenderedArgs = string:join([ case A of 
        A when is_tuple(A) -> nitro:render(A);
        A when is_list(A) -> A;
        A when is_integer(A) -> nitro:to_list(A);
        A -> A end || A <- Args],","),
    string:join([ nitro:f("qi('~s').~s("++Record#jq.format++");",
        [nitro:to_list(Target),nitro:to_list(Method),RenderedArgs]) || Method <- Methods],[]);

render_action(#jq{target=T,method=undefined,property=P,right=R,format=_F}) ->
    nitro:f("qi('~s').~s = '~s';",
        [nitro:to_list(T),nitro:to_list(P),binary_to_list(iolist_to_binary(nitro:render(R)))]).

you have the js according to the last render_action. try to avoid 'property' and 'right' in favor of 'args' and change the #jq record format to ~s without single quotes.
you can end with something like

qi('history').scrollTop=qi('history').scrollHeight;;

you will still have the unnecessary ';;' at the end but i don't think the browser will complain about that :)

Andrii Zadorozhnii
@doxtop
Apr 06 2016 17:26
actually I've missed the point about properties, formatting will work for methods, sorry. reuse of formatting needs to be applied for property rendering
but in case when the properties are functions this will still work )
Oleg Zinchenko
@cystbear
Apr 06 2016 17:33
ща буду mad распидарасивать
Oleg Zinchenko
@cystbear
Apr 06 2016 17:43
$ cloc ./src 
      25 text files.
      25 unique files.                              
       1 file ignored.

http://cloc.sourceforge.net v 1.64  T=0.10 s (239.8 files/s, 12177.5 lines/s)
---------------------------------
Language files blank comment code
---------------------------------
Erlang   24    171   15      1033
rusjava8
@rusjava8
Apr 06 2016 19:23