nitro.htm 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <html>
  2. <head>
  3. <meta charset="utf-8" />
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta name="description" content="" />
  7. <meta name="author" content="Maxim Sokhatsky" />
  8. <title>NITRO</title>
  9. <link rel="stylesheet" href="https://n2o.dev/blank.css" />
  10. <link rel="stylesheet" href="https://n2o.dev/zima.css" />
  11. </head>
  12. <body>
  13. <nav>
  14. <a href="https://n2o.dev">DEV</a>
  15. <a href="https://nitro.n2o.space">NITRO</a>
  16. <a href="#" style="background:#ededed;">NITRO</a>
  17. <div class="dropdown">
  18. <a onclick="drop()" class="dropbtn">EN</a>
  19. <div id="dropdown" class="dropdown-content">
  20. <a href="https://n2o.dev/deps/nitro/man/ua/nitro.htm">UA</a>
  21. <a href="#">EN</a>
  22. </div>
  23. </div>
  24. </nav>
  25. <header>
  26. <a href="../index.html"><img src="https://n2o.space/img/Synrc Neo.svg" /></a>
  27. <h1>NITRO</h1>
  28. </header>
  29. <main>
  30. <section>
  31. <h3>INTRO</h3>
  32. <p>The refined SYNRC API of the Nitrogen Web Framework brought to us by Rusty Klophaus.</p>
  33. </section>
  34. <section>
  35. <h3>API</h3>
  36. <h4>q(atom()) -> term().</h4>
  37. <p>Retrieves from process dictionary by atom-key the value of client DOM element
  38. passed by over the network as <b>#ev</b> parameter</p>
  39. <figure><code> event(click) -> io:format("~p~n",[nitro:q(:name)]);</code></figure>
  40. <h4>jse([] | binary()) -> [] | binary().</h4>
  41. <p>Performs JavaScript escaping for eval compatibility.</p>
  42. <figure><code> > nitro:jse(&lt;&lt;"Ім'я"/utf8&gt;&gt;).
  43. &lt;&lt;"Ім\\'я"/utf8&gt;&gt;</code></figure>
  44. <h4>wire(list(#action{})) -> [].</h4>
  45. <p>Updates the process dictionary <b>actions</b> variable with the new list of records inhereted from <b>#action</b>.
  46. This process dictionary variable is a way data is passed from your <b>event</b> handlers into the output rendering pipeline.
  47. This is fixed by Nitrogen Web Framework API.</p>
  48. <figure><code> > nitro:wire([#alert{text="hello"}]).
  49. []
  50. > get(actions).
  51. [#wire{ancestor = action,
  52. trigger = [],
  53. target = [],
  54. module = action_wire,
  55. actions = [#alert{ancestor = action,
  56. trigger = [],
  57. target = [],
  58. module = action_alert,
  59. actions = [],
  60. source = [],
  61. text = "hello"}],
  62. source = []}]</code></figure>
  63. <h4>render(list(#action{} | #element{})) -> binary().</h4>
  64. <p>Renders HTML5 binary string by the record inhereted from <b>#element</b>.</p>
  65. <figure><code> > rr(nitro).
  66. [abbr,action,address,alert,api,area,article,aside,audio,
  67. author,b,base,bdi,bdo,bind,blockquote,body,br,button,
  68. calendar,canvas,caption,checkbox,cite,code,col,colgroup,
  69. color,command|...]
  70. &gt; #element{}.
  71. #element{ancestor = element,id = [],module = undefined,
  72. delegate = [],validation = [],validate = [],actions = [],
  73. class = [],style = [],source = [],onmouseover = [],
  74. onkeypress = [],onchange = [],onkeyup = [],onkeydown = [],
  75. onclick = [],data_fields = [],aria_states = [],body = [],
  76. role = [],tabindex = [],show_if = true,html_tag = [],
  77. title = [],postback = [],accesskey = [],
  78. contenteditable = [],contextmenu = [],...}
  79. &lt; nitro:render(#alert{text="hello"}).
  80. ["alert(\"","hello","\");"]
  81. &gt; nitro:render(#element{}).
  82. [&lt;&lt;"&lt;"&gt;&gt;,&lt;&lt;"element"&gt;&gt;,
  83. [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]],
  84. &lt;&lt;"&gt;"&gt;&gt;,&lt;&lt;&gt;&gt;,&lt;&lt;"&lt;/"&gt;&gt;,&lt;&lt;"element"&gt;&gt;,&lt;&lt;"&gt;"&gt;&gt;]
  85. &gt; iolist_to_binary(nitro:render(#element{})).
  86. &lt;&lt;"&lt;element&gt;&lt;/element&gt;"&gt;&gt;
  87. &gt; iolist_to_binary(nitro:render(setelement(1,#element{},tag))).
  88. &lt;&lt;"&lt;tag&gt;&lt;/tag&gt;"&gt;&gt;</code></figure>
  89. <h4>insert_top(atom(), list(#element{})) -> [].</h4>
  90. <h4>insert_bottom(atom(), list(#element{})) -> [].</h4>
  91. <h4>update(atom(), list(#element{})) -> [].</h4>
  92. <h4>clear(atom()) -> [].</h4>
  93. <h4>remove(atom()) -> [].</h4>
  94. <p>Wires a JavaScript to the process dictionary that manipulate
  95. DOM elements tree directly on a client side.</p>
  96. <h4>display(atom(),atom()) -> [].</h4>
  97. <p>Wires a JavaScript that manipulate <b>style</b> field of a given DOM element.</p>
  98. <h4>compact(term()) -> binary().</h4>
  99. <p>Pretty-prints the term into more compact format to display by a recursive cut
  100. the tuples with no more that 9 elements width.</p>
  101. <figure><code> &gt; iolist_to_binary(nitro:compact({1,2,3,4,5,{1,2,3,4},7,8,9,10,11})).
  102. &lt;&lt;"{1,2,3,4,5,{1,2,3,4},7,8,9}"&gt;&gt;</code></section>
  103. </section>
  104. </main>
  105. <footer> 2005—2019 © Synrc Research Center </footer>
  106. <script>function drop(){document.getElementById("dropdown").classList.toggle("show");}</script>
  107. </body>
  108. </html>