achandling.html 176 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417
  1. <!doctype html>
  2. <html lang="en" class="no-js">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <meta name="description" content="ESP8266/ESP32 WLAN configuration at run time with web interface">
  7. <link rel="canonical" href="https://Hieromon.github.io/AutoConnect/achandling.html">
  8. <meta name="author" content="Hieromon Ikasamo">
  9. <link rel="shortcut icon" href="assets/images/favicon.png">
  10. <meta name="generator" content="mkdocs-1.1.2, mkdocs-material-6.1.6">
  11. <title>Handling the custom Web pages - AutoConnect for ESP8266/ESP32</title>
  12. <link rel="stylesheet" href="assets/stylesheets/main.6910b76c.min.css">
  13. <link rel="stylesheet" href="assets/stylesheets/palette.196e0c26.min.css">
  14. <meta name="theme-color" content="#4051b5">
  15. <link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
  16. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback">
  17. <style>body,input{font-family:"Roboto",-apple-system,BlinkMacSystemFont,Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono",SFMono-Regular,Consolas,Menlo,monospace}</style>
  18. <link rel="stylesheet" href="css/paragraph.css">
  19. <link rel="stylesheet" href="css/extra.css">
  20. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css">
  21. <script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-116150854-1","auto"),ga("set","anonymizeIp",!0),ga("send","pageview"),document.addEventListener("DOMContentLoaded",function(){document.forms.search&&document.forms.search.query.addEventListener("blur",function(){if(this.value){var e=document.location.pathname;ga("send","pageview",e+"?q="+this.value)}})}),document.addEventListener("DOMContentSwitch",function(){ga("send","pageview",document.location.pathname)})</script>
  22. <script async src="https://www.google-analytics.com/analytics.js"></script>
  23. </head>
  24. <body dir="ltr" data-md-color-scheme="" data-md-color-primary="indigo" data-md-color-accent="indigo">
  25. <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
  26. <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
  27. <label class="md-overlay" for="__drawer"></label>
  28. <div data-md-component="skip">
  29. <a href="#page-container-component" class="md-skip">
  30. Skip to content
  31. </a>
  32. </div>
  33. <div data-md-component="announce">
  34. </div>
  35. <header class="md-header" data-md-component="header">
  36. <nav class="md-header-nav md-grid" aria-label="Header">
  37. <a href="https://Hieromon.github.io/AutoConnect/" title="AutoConnect for ESP8266/ESP32" class="md-header-nav__button md-logo" aria-label="AutoConnect for ESP8266/ESP32">
  38. <img src="images/arduino-logo.svg" alt="logo">
  39. </a>
  40. <label class="md-header-nav__button md-icon" for="__drawer">
  41. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z"/></svg>
  42. </label>
  43. <div class="md-header-nav__title" data-md-component="header-title">
  44. <div class="md-header-nav__ellipsis">
  45. <span class="md-header-nav__topic md-ellipsis">
  46. AutoConnect for ESP8266/ESP32
  47. </span>
  48. <span class="md-header-nav__topic md-ellipsis">
  49. Handling the custom Web pages
  50. </span>
  51. </div>
  52. </div>
  53. <label class="md-header-nav__button md-icon" for="__search">
  54. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg>
  55. </label>
  56. <div class="md-search" data-md-component="search" role="dialog">
  57. <label class="md-search__overlay" for="__search"></label>
  58. <div class="md-search__inner" role="search">
  59. <form class="md-search__form" name="search">
  60. <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" data-md-state="active" required>
  61. <label class="md-search__icon md-icon" for="__search">
  62. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg>
  63. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg>
  64. </label>
  65. <button type="reset" class="md-search__icon md-icon" aria-label="Clear" data-md-component="search-reset" tabindex="-1">
  66. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"/></svg>
  67. </button>
  68. </form>
  69. <div class="md-search__output">
  70. <div class="md-search__scrollwrap" data-md-scrollfix>
  71. <div class="md-search-result" data-md-component="search-result">
  72. <div class="md-search-result__meta">
  73. Initializing search
  74. </div>
  75. <ol class="md-search-result__list"></ol>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="md-header-nav__source">
  82. <a href="https://github.com/Hieromon/AutoConnect" title="Go to repository" class="md-source">
  83. <div class="md-source__icon md-icon">
  84. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M439.55 236.05L244 40.45a28.87 28.87 0 00-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 01-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 000 40.81l195.61 195.6a28.86 28.86 0 0040.8 0l194.69-194.69a28.86 28.86 0 000-40.81z"/></svg>
  85. </div>
  86. <div class="md-source__repository">
  87. Hieromon/AutoConnect
  88. </div>
  89. </a>
  90. </div>
  91. </nav>
  92. </header>
  93. <div class="md-container" data-md-component="container">
  94. <main class="md-main" data-md-component="main">
  95. <div class="md-main__inner md-grid">
  96. <div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
  97. <div class="md-sidebar__scrollwrap">
  98. <div class="md-sidebar__inner">
  99. <nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
  100. <label class="md-nav__title" for="__drawer">
  101. <a href="https://Hieromon.github.io/AutoConnect/" title="AutoConnect for ESP8266/ESP32" class="md-nav__button md-logo" aria-label="AutoConnect for ESP8266/ESP32">
  102. <img src="images/arduino-logo.svg" alt="logo">
  103. </a>
  104. AutoConnect for ESP8266/ESP32
  105. </label>
  106. <div class="md-nav__source">
  107. <a href="https://github.com/Hieromon/AutoConnect" title="Go to repository" class="md-source">
  108. <div class="md-source__icon md-icon">
  109. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M439.55 236.05L244 40.45a28.87 28.87 0 00-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 01-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 000 40.81l195.61 195.6a28.86 28.86 0 0040.8 0l194.69-194.69a28.86 28.86 0 000-40.81z"/></svg>
  110. </div>
  111. <div class="md-source__repository">
  112. Hieromon/AutoConnect
  113. </div>
  114. </a>
  115. </div>
  116. <ul class="md-nav__list" data-md-scrollfix>
  117. <li class="md-nav__item">
  118. <a href="index.html" class="md-nav__link">
  119. Overview
  120. </a>
  121. </li>
  122. <li class="md-nav__item">
  123. <a href="gettingstarted.html" class="md-nav__link">
  124. Getting started
  125. </a>
  126. </li>
  127. <li class="md-nav__item">
  128. <a href="menu.html" class="md-nav__link">
  129. AutoConnect menu
  130. </a>
  131. </li>
  132. <li class="md-nav__item">
  133. <a href="basicusage.html" class="md-nav__link">
  134. Basic usage
  135. </a>
  136. </li>
  137. <li class="md-nav__item md-nav__item--nested">
  138. <input class="md-nav__toggle md-toggle" data-md-toggle="nav-5" type="checkbox" id="nav-5" >
  139. <label class="md-nav__link" for="nav-5">
  140. Advanced usage
  141. <span class="md-nav__icon md-icon"></span>
  142. </label>
  143. <nav class="md-nav" aria-label="Advanced usage" data-md-level="1">
  144. <label class="md-nav__title" for="nav-5">
  145. <span class="md-nav__icon md-icon"></span>
  146. Advanced usage
  147. </label>
  148. <ul class="md-nav__list" data-md-scrollfix>
  149. <li class="md-nav__item">
  150. <a href="advancedusage.html" class="md-nav__link">
  151. Advanced usage
  152. </a>
  153. </li>
  154. <li class="md-nav__item">
  155. <a href="adconnection.html" class="md-nav__link">
  156. AutoConnect WiFi connection control
  157. </a>
  158. </li>
  159. <li class="md-nav__item">
  160. <a href="adcpcontrol.html" class="md-nav__link">
  161. Captive portal control
  162. </a>
  163. </li>
  164. <li class="md-nav__item">
  165. <a href="adnetwork.html" class="md-nav__link">
  166. Settings and controls for network and WiFi
  167. </a>
  168. </li>
  169. <li class="md-nav__item">
  170. <a href="adauthentication.html" class="md-nav__link">
  171. Authentication settings
  172. </a>
  173. </li>
  174. <li class="md-nav__item">
  175. <a href="adcredential.html" class="md-nav__link">
  176. Credential accesses
  177. </a>
  178. </li>
  179. <li class="md-nav__item">
  180. <a href="adexterior.html" class="md-nav__link">
  181. Customizing page appearance
  182. </a>
  183. </li>
  184. <li class="md-nav__item">
  185. <a href="adothers.html" class="md-nav__link">
  186. Other operation settings and controls
  187. </a>
  188. </li>
  189. </ul>
  190. </nav>
  191. </li>
  192. <li class="md-nav__item md-nav__item--active md-nav__item--nested">
  193. <input class="md-nav__toggle md-toggle" data-md-toggle="nav-6" type="checkbox" id="nav-6" checked>
  194. <label class="md-nav__link" for="nav-6">
  195. Custom Web pages
  196. <span class="md-nav__icon md-icon"></span>
  197. </label>
  198. <nav class="md-nav" aria-label="Custom Web pages" data-md-level="1">
  199. <label class="md-nav__title" for="nav-6">
  200. <span class="md-nav__icon md-icon"></span>
  201. Custom Web pages
  202. </label>
  203. <ul class="md-nav__list" data-md-scrollfix>
  204. <li class="md-nav__item">
  205. <a href="acintro.html" class="md-nav__link">
  206. Custom Web pages with AutoConnect
  207. </a>
  208. </li>
  209. <li class="md-nav__item">
  210. <a href="acelements.html" class="md-nav__link">
  211. AutoConnectElements
  212. </a>
  213. </li>
  214. <li class="md-nav__item">
  215. <a href="acjson.html" class="md-nav__link">
  216. Custom Web pages with JSON
  217. </a>
  218. </li>
  219. <li class="md-nav__item md-nav__item--active">
  220. <input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc">
  221. <label class="md-nav__link md-nav__link--active" for="__toc">
  222. Handling the custom Web pages
  223. <span class="md-nav__icon md-icon"></span>
  224. </label>
  225. <a href="achandling.html" class="md-nav__link md-nav__link--active">
  226. Handling the custom Web pages
  227. </a>
  228. <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  229. <label class="md-nav__title" for="__toc">
  230. <span class="md-nav__icon md-icon"></span>
  231. Table of contents
  232. </label>
  233. <ul class="md-nav__list" data-md-scrollfix>
  234. <li class="md-nav__item">
  235. <a href="#page-container-component" class="md-nav__link">
  236. Page, Container, Component
  237. </a>
  238. </li>
  239. <li class="md-nav__item">
  240. <a href="#handing-autoconnectelements-with-the-sketches" class="md-nav__link">
  241. Handing AutoConnectElements with the Sketches
  242. </a>
  243. <nav class="md-nav" aria-label="Handing AutoConnectElements with the Sketches">
  244. <ul class="md-nav__list">
  245. <li class="md-nav__item">
  246. <a href="#add-autoconnectelements-to-the-autoconnectaux-object" class="md-nav__link">
  247. Add AutoConnectElements to the AutoConnectAux object
  248. </a>
  249. </li>
  250. <li class="md-nav__item">
  251. <a href="#get-autoconnectelement-from-the-autoconnectaux" class="md-nav__link">
  252. Get AutoConnectElement from the AutoConnectAux
  253. </a>
  254. </li>
  255. <li class="md-nav__item">
  256. <a href="#enable-autoconnectelements-during-the-sketch-execution" class="md-nav__link">
  257. Enable AutoConnectElements during the Sketch execution
  258. </a>
  259. </li>
  260. </ul>
  261. </nav>
  262. </li>
  263. <li class="md-nav__item">
  264. <a href="#loading-saving-autoconnectelements-with-json" class="md-nav__link">
  265. Loading &amp; saving AutoConnectElements with JSON
  266. </a>
  267. <nav class="md-nav" aria-label="Loading &amp; saving AutoConnectElements with JSON">
  268. <ul class="md-nav__list">
  269. <li class="md-nav__item">
  270. <a href="#loading-autoconnectaux-autoconnectelements-with-json" class="md-nav__link">
  271. Loading AutoConnectAux &amp; AutoConnectElements with JSON
  272. </a>
  273. </li>
  274. <li class="md-nav__item">
  275. <a href="#saving-autoconnectelements-with-json" class="md-nav__link">
  276. Saving AutoConnectElements with JSON
  277. </a>
  278. </li>
  279. </ul>
  280. </nav>
  281. </li>
  282. <li class="md-nav__item">
  283. <a href="#custom-field-data-handling" class="md-nav__link">
  284. Custom field data handling
  285. </a>
  286. <nav class="md-nav" aria-label="Custom field data handling">
  287. <ul class="md-nav__list">
  288. <li class="md-nav__item">
  289. <a href="#where-to-pick-up-the-values" class="md-nav__link">
  290. Where to pick up the values
  291. </a>
  292. </li>
  293. <li class="md-nav__item">
  294. <a href="#when-setting-the-initial-values" class="md-nav__link">
  295. When setting the initial values
  296. </a>
  297. </li>
  298. <li class="md-nav__item">
  299. <a href="#how-you-can-reach-the-values" class="md-nav__link">
  300. How you can reach the values
  301. </a>
  302. </li>
  303. <li class="md-nav__item">
  304. <a href="#transfer-of-input-values-across-pages" class="md-nav__link">
  305. Transfer of input values ​​across pages
  306. </a>
  307. </li>
  308. <li class="md-nav__item">
  309. <a href="#retrieve-the-values-with-webserveron-handler" class="md-nav__link">
  310. Retrieve the values with WebServer::on handler
  311. </a>
  312. </li>
  313. <li class="md-nav__item">
  314. <a href="#overwrite-the-autoconnectelements" class="md-nav__link">
  315. Overwrite the AutoConnectElements
  316. </a>
  317. </li>
  318. <li class="md-nav__item">
  319. <a href="#check-data-against-on-submission" class="md-nav__link">
  320. Check data against on submission
  321. </a>
  322. </li>
  323. <li class="md-nav__item">
  324. <a href="#input-data-validation" class="md-nav__link">
  325. Input data validation
  326. </a>
  327. </li>
  328. <li class="md-nav__item">
  329. <a href="#convert-data-to-actually-type" class="md-nav__link">
  330. Convert data to actually type
  331. </a>
  332. </li>
  333. </ul>
  334. </nav>
  335. </li>
  336. <li class="md-nav__item">
  337. <a href="#place-html-elements-undefined-in-autoconnectelements" class="md-nav__link">
  338. Place HTML elements undefined in AutoConnectElements
  339. </a>
  340. <nav class="md-nav" aria-label="Place HTML elements undefined in AutoConnectElements">
  341. <ul class="md-nav__list">
  342. <li class="md-nav__item">
  343. <a href="#place-a-markup-or-a-styled-html-tag" class="md-nav__link">
  344. Place a markup or a styled HTML tag
  345. </a>
  346. </li>
  347. <li class="md-nav__item">
  348. <a href="#place-the-input-elements-within-a-form" class="md-nav__link">
  349. Place the input elements within a form
  350. </a>
  351. </li>
  352. <li class="md-nav__item">
  353. <a href="#using-javascript" class="md-nav__link">
  354. Using JavaScript
  355. </a>
  356. </li>
  357. <li class="md-nav__item">
  358. <a href="#communicate-with-the-sketch-using-xhr" class="md-nav__link">
  359. Communicate with the Sketch using XHR
  360. </a>
  361. </li>
  362. </ul>
  363. </nav>
  364. </li>
  365. <li class="md-nav__item">
  366. <a href="#transitions-of-the-custom-web-pages" class="md-nav__link">
  367. Transitions of the custom Web pages
  368. </a>
  369. <nav class="md-nav" aria-label="Transitions of the custom Web pages">
  370. <ul class="md-nav__list">
  371. <li class="md-nav__item">
  372. <a href="#scope-lifetime-of-autoconnectaux" class="md-nav__link">
  373. Scope &amp; Lifetime of AutoConnectAux
  374. </a>
  375. </li>
  376. <li class="md-nav__item">
  377. <a href="#the-uri-of-the-custom-web-pages" class="md-nav__link">
  378. The URI of the custom Web pages
  379. </a>
  380. </li>
  381. <li class="md-nav__item">
  382. <a href="#limitations" class="md-nav__link">
  383. Limitations
  384. </a>
  385. </li>
  386. </ul>
  387. </nav>
  388. </li>
  389. </ul>
  390. </nav>
  391. </li>
  392. </ul>
  393. </nav>
  394. </li>
  395. <li class="md-nav__item md-nav__item--nested">
  396. <input class="md-nav__toggle md-toggle" data-md-toggle="nav-7" type="checkbox" id="nav-7" >
  397. <label class="md-nav__link" for="nav-7">
  398. OTA Updates
  399. <span class="md-nav__icon md-icon"></span>
  400. </label>
  401. <nav class="md-nav" aria-label="OTA Updates" data-md-level="1">
  402. <label class="md-nav__title" for="nav-7">
  403. <span class="md-nav__icon md-icon"></span>
  404. OTA Updates
  405. </label>
  406. <ul class="md-nav__list" data-md-scrollfix>
  407. <li class="md-nav__item">
  408. <a href="otaupdate.html" class="md-nav__link">
  409. OTA Updates
  410. </a>
  411. </li>
  412. <li class="md-nav__item">
  413. <a href="otabrowser.html" class="md-nav__link">
  414. Using Web Browser
  415. </a>
  416. </li>
  417. <li class="md-nav__item">
  418. <a href="otaserver.html" class="md-nav__link">
  419. Using Update Server
  420. </a>
  421. </li>
  422. </ul>
  423. </nav>
  424. </li>
  425. <li class="md-nav__item md-nav__item--nested">
  426. <input class="md-nav__toggle md-toggle" data-md-toggle="nav-8" type="checkbox" id="nav-8" >
  427. <label class="md-nav__link" for="nav-8">
  428. Library APIs
  429. <span class="md-nav__icon md-icon"></span>
  430. </label>
  431. <nav class="md-nav" aria-label="Library APIs" data-md-level="1">
  432. <label class="md-nav__title" for="nav-8">
  433. <span class="md-nav__icon md-icon"></span>
  434. Library APIs
  435. </label>
  436. <ul class="md-nav__list" data-md-scrollfix>
  437. <li class="md-nav__item">
  438. <a href="api.html" class="md-nav__link">
  439. AutoConnect API
  440. </a>
  441. </li>
  442. <li class="md-nav__item">
  443. <a href="apiaux.html" class="md-nav__link">
  444. AutoConnectAux API
  445. </a>
  446. </li>
  447. <li class="md-nav__item">
  448. <a href="apiconfig.html" class="md-nav__link">
  449. AutoConnectConfig API
  450. </a>
  451. </li>
  452. <li class="md-nav__item">
  453. <a href="apielements.html" class="md-nav__link">
  454. AutoConnectElements API
  455. </a>
  456. </li>
  457. <li class="md-nav__item">
  458. <a href="apiupdate.html" class="md-nav__link">
  459. AutoConnectUpdate API
  460. </a>
  461. </li>
  462. <li class="md-nav__item">
  463. <a href="apiextra.html" class="md-nav__link">
  464. Something extra
  465. </a>
  466. </li>
  467. </ul>
  468. </nav>
  469. </li>
  470. <li class="md-nav__item md-nav__item--nested">
  471. <input class="md-nav__toggle md-toggle" data-md-toggle="nav-9" type="checkbox" id="nav-9" >
  472. <label class="md-nav__link" for="nav-9">
  473. Examples
  474. <span class="md-nav__icon md-icon"></span>
  475. </label>
  476. <nav class="md-nav" aria-label="Examples" data-md-level="1">
  477. <label class="md-nav__title" for="nav-9">
  478. <span class="md-nav__icon md-icon"></span>
  479. Examples
  480. </label>
  481. <ul class="md-nav__list" data-md-scrollfix>
  482. <li class="md-nav__item">
  483. <a href="howtoembed.html" class="md-nav__link">
  484. How to embed
  485. </a>
  486. </li>
  487. <li class="md-nav__item">
  488. <a href="datatips.html" class="md-nav__link">
  489. Tips for data conversion
  490. </a>
  491. </li>
  492. <li class="md-nav__item">
  493. <a href="menuize.html" class="md-nav__link">
  494. Attach the menus
  495. </a>
  496. </li>
  497. <li class="md-nav__item">
  498. <a href="wojson.html" class="md-nav__link">
  499. Custom Web pages w/o JSON
  500. </a>
  501. </li>
  502. </ul>
  503. </nav>
  504. </li>
  505. <li class="md-nav__item md-nav__item--nested">
  506. <input class="md-nav__toggle md-toggle" data-md-toggle="nav-10" type="checkbox" id="nav-10" >
  507. <label class="md-nav__link" for="nav-10">
  508. Appendix
  509. <span class="md-nav__icon md-icon"></span>
  510. </label>
  511. <nav class="md-nav" aria-label="Appendix" data-md-level="1">
  512. <label class="md-nav__title" for="nav-10">
  513. <span class="md-nav__icon md-icon"></span>
  514. Appendix
  515. </label>
  516. <ul class="md-nav__list" data-md-scrollfix>
  517. <li class="md-nav__item">
  518. <a href="lsbegin.html" class="md-nav__link">
  519. Inside AutoConnect::begin
  520. </a>
  521. </li>
  522. <li class="md-nav__item">
  523. <a href="credit.html" class="md-nav__link">
  524. Saved credentials access
  525. </a>
  526. </li>
  527. <li class="md-nav__item">
  528. <a href="acupload.html" class="md-nav__link">
  529. File upload handler
  530. </a>
  531. </li>
  532. <li class="md-nav__item">
  533. <a href="colorized.html" class="md-nav__link">
  534. Custom colorized
  535. </a>
  536. </li>
  537. <li class="md-nav__item">
  538. <a href="changelabel.html" class="md-nav__link">
  539. Change label text
  540. </a>
  541. </li>
  542. </ul>
  543. </nav>
  544. </li>
  545. <li class="md-nav__item">
  546. <a href="faq.html" class="md-nav__link">
  547. FAQ
  548. </a>
  549. </li>
  550. <li class="md-nav__item">
  551. <a href="changelog.html" class="md-nav__link">
  552. Change log
  553. </a>
  554. </li>
  555. <li class="md-nav__item">
  556. <a href="license.html" class="md-nav__link">
  557. License
  558. </a>
  559. </li>
  560. </ul>
  561. </nav>
  562. </div>
  563. </div>
  564. </div>
  565. <div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
  566. <div class="md-sidebar__scrollwrap">
  567. <div class="md-sidebar__inner">
  568. <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  569. <label class="md-nav__title" for="__toc">
  570. <span class="md-nav__icon md-icon"></span>
  571. Table of contents
  572. </label>
  573. <ul class="md-nav__list" data-md-scrollfix>
  574. <li class="md-nav__item">
  575. <a href="#page-container-component" class="md-nav__link">
  576. Page, Container, Component
  577. </a>
  578. </li>
  579. <li class="md-nav__item">
  580. <a href="#handing-autoconnectelements-with-the-sketches" class="md-nav__link">
  581. Handing AutoConnectElements with the Sketches
  582. </a>
  583. <nav class="md-nav" aria-label="Handing AutoConnectElements with the Sketches">
  584. <ul class="md-nav__list">
  585. <li class="md-nav__item">
  586. <a href="#add-autoconnectelements-to-the-autoconnectaux-object" class="md-nav__link">
  587. Add AutoConnectElements to the AutoConnectAux object
  588. </a>
  589. </li>
  590. <li class="md-nav__item">
  591. <a href="#get-autoconnectelement-from-the-autoconnectaux" class="md-nav__link">
  592. Get AutoConnectElement from the AutoConnectAux
  593. </a>
  594. </li>
  595. <li class="md-nav__item">
  596. <a href="#enable-autoconnectelements-during-the-sketch-execution" class="md-nav__link">
  597. Enable AutoConnectElements during the Sketch execution
  598. </a>
  599. </li>
  600. </ul>
  601. </nav>
  602. </li>
  603. <li class="md-nav__item">
  604. <a href="#loading-saving-autoconnectelements-with-json" class="md-nav__link">
  605. Loading &amp; saving AutoConnectElements with JSON
  606. </a>
  607. <nav class="md-nav" aria-label="Loading &amp; saving AutoConnectElements with JSON">
  608. <ul class="md-nav__list">
  609. <li class="md-nav__item">
  610. <a href="#loading-autoconnectaux-autoconnectelements-with-json" class="md-nav__link">
  611. Loading AutoConnectAux &amp; AutoConnectElements with JSON
  612. </a>
  613. </li>
  614. <li class="md-nav__item">
  615. <a href="#saving-autoconnectelements-with-json" class="md-nav__link">
  616. Saving AutoConnectElements with JSON
  617. </a>
  618. </li>
  619. </ul>
  620. </nav>
  621. </li>
  622. <li class="md-nav__item">
  623. <a href="#custom-field-data-handling" class="md-nav__link">
  624. Custom field data handling
  625. </a>
  626. <nav class="md-nav" aria-label="Custom field data handling">
  627. <ul class="md-nav__list">
  628. <li class="md-nav__item">
  629. <a href="#where-to-pick-up-the-values" class="md-nav__link">
  630. Where to pick up the values
  631. </a>
  632. </li>
  633. <li class="md-nav__item">
  634. <a href="#when-setting-the-initial-values" class="md-nav__link">
  635. When setting the initial values
  636. </a>
  637. </li>
  638. <li class="md-nav__item">
  639. <a href="#how-you-can-reach-the-values" class="md-nav__link">
  640. How you can reach the values
  641. </a>
  642. </li>
  643. <li class="md-nav__item">
  644. <a href="#transfer-of-input-values-across-pages" class="md-nav__link">
  645. Transfer of input values ​​across pages
  646. </a>
  647. </li>
  648. <li class="md-nav__item">
  649. <a href="#retrieve-the-values-with-webserveron-handler" class="md-nav__link">
  650. Retrieve the values with WebServer::on handler
  651. </a>
  652. </li>
  653. <li class="md-nav__item">
  654. <a href="#overwrite-the-autoconnectelements" class="md-nav__link">
  655. Overwrite the AutoConnectElements
  656. </a>
  657. </li>
  658. <li class="md-nav__item">
  659. <a href="#check-data-against-on-submission" class="md-nav__link">
  660. Check data against on submission
  661. </a>
  662. </li>
  663. <li class="md-nav__item">
  664. <a href="#input-data-validation" class="md-nav__link">
  665. Input data validation
  666. </a>
  667. </li>
  668. <li class="md-nav__item">
  669. <a href="#convert-data-to-actually-type" class="md-nav__link">
  670. Convert data to actually type
  671. </a>
  672. </li>
  673. </ul>
  674. </nav>
  675. </li>
  676. <li class="md-nav__item">
  677. <a href="#place-html-elements-undefined-in-autoconnectelements" class="md-nav__link">
  678. Place HTML elements undefined in AutoConnectElements
  679. </a>
  680. <nav class="md-nav" aria-label="Place HTML elements undefined in AutoConnectElements">
  681. <ul class="md-nav__list">
  682. <li class="md-nav__item">
  683. <a href="#place-a-markup-or-a-styled-html-tag" class="md-nav__link">
  684. Place a markup or a styled HTML tag
  685. </a>
  686. </li>
  687. <li class="md-nav__item">
  688. <a href="#place-the-input-elements-within-a-form" class="md-nav__link">
  689. Place the input elements within a form
  690. </a>
  691. </li>
  692. <li class="md-nav__item">
  693. <a href="#using-javascript" class="md-nav__link">
  694. Using JavaScript
  695. </a>
  696. </li>
  697. <li class="md-nav__item">
  698. <a href="#communicate-with-the-sketch-using-xhr" class="md-nav__link">
  699. Communicate with the Sketch using XHR
  700. </a>
  701. </li>
  702. </ul>
  703. </nav>
  704. </li>
  705. <li class="md-nav__item">
  706. <a href="#transitions-of-the-custom-web-pages" class="md-nav__link">
  707. Transitions of the custom Web pages
  708. </a>
  709. <nav class="md-nav" aria-label="Transitions of the custom Web pages">
  710. <ul class="md-nav__list">
  711. <li class="md-nav__item">
  712. <a href="#scope-lifetime-of-autoconnectaux" class="md-nav__link">
  713. Scope &amp; Lifetime of AutoConnectAux
  714. </a>
  715. </li>
  716. <li class="md-nav__item">
  717. <a href="#the-uri-of-the-custom-web-pages" class="md-nav__link">
  718. The URI of the custom Web pages
  719. </a>
  720. </li>
  721. <li class="md-nav__item">
  722. <a href="#limitations" class="md-nav__link">
  723. Limitations
  724. </a>
  725. </li>
  726. </ul>
  727. </nav>
  728. </li>
  729. </ul>
  730. </nav>
  731. </div>
  732. </div>
  733. </div>
  734. <div class="md-content">
  735. <article class="md-content__inner md-typeset">
  736. <h1>Handling the custom Web pages</h1>
  737. <h2 id="page-container-component">Page, Container, Component<a class="headerlink" href="#page-container-component" title="Permanent link">&para;</a></h2>
  738. <p>AutoConnectAux is the container for a custom Web page, AutoConnectElement is the component of a page. AutoConnectElements must be contained in AutoConnectAux object. (ie. they are the elements displayed on the custom Web page.) Then AutoConnect makes an AutoConnectAux to a page.</p>
  739. <p>AutoConnectElements declared in sketch must be programmed to add to AutoConnectAux one after another. Elements are automatically included in AutoConnectAux by AutoConnect if you load it from the JSON document. In either method, it is common to use the function of AutoConnectAux to access an element with a sketch.</p>
  740. <h2 id="handing-autoconnectelements-with-the-sketches">Handing AutoConnectElements with the Sketches<a class="headerlink" href="#handing-autoconnectelements-with-the-sketches" title="Permanent link">&para;</a></h2>
  741. <p>The AutoConnectAux class has several functions to manipulate AutoConnectElements. The functions can add, delete, retrieve elements, and get and set values.</p>
  742. <h3 id="add-autoconnectelements-to-the-autoconnectaux-object"><i class="fa fa-edit"></i> Add AutoConnectElements to the AutoConnectAux object<a class="headerlink" href="#add-autoconnectelements-to-the-autoconnectaux-object" title="Permanent link">&para;</a></h3>
  743. <p>To add AutoConnectElment(s) to an AutoConnectAux object, use the add function.</p>
  744. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">void</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">add(AutoConnectElement</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">addon)</span>
  745. </code></pre></div>
  746. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">void</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">add(AutoConnectElementVT</span> <span style="color: #f8f8f2">addons)</span>
  747. </code></pre></div>
  748. <p>The add function adds the specified AutoConnectElement to AutoConnectAux. The AutoConnectElementVT type is the <a href="https://en.cppreference.com/w/cpp/container/vector"><em>std::vector</em></a> of the <a href="https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper"><em>reference wrapper</em></a> to AutoConnectElements, and you can add these elements in bulk by using the <a href="https://en.cppreference.com/w/cpp/language/list_initialization"><em>list initialization</em></a> with the Sketch.</p>
  749. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">typedef</span> <span style="color: #f8f8f2">std</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">vector</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">std</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">reference_wrapper</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">&gt;&gt;</span> <span style="color: #f8f8f2">AutoConnectElementVT;</span>
  750. </code></pre></div>
  751. <p>AutoConnectElements contained in AutoConnectAux object are uniquely identified by name. When adding an AutoConnectElement, if an element with the same name already exists in the AutoConnectAux, checking the type, and if it is the same, the value will be replaced. If another type of AutoConnectElement exists with the same name, that add operation will be invalid.<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup> In the following example, AutoConnectButton <code>button</code> addition will invalid because <code>hello</code> with the same name already exists as AutoConnectText.</p>
  752. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #f8f8f2">aux;</span>
  753. <span style="color: #f8f8f2">AutoConnectText</span> <span style="color: #a6e22e">text</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;hello&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;hello, world&quot;</span><span style="color: #f8f8f2">);</span>
  754. <span style="background-color: #49483e"><span style="color: #f8f8f2">AutoConnectButton</span> <span style="color: #a6e22e">button</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;hello&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;hello, world&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;alert(&#39;Hello world!&#39;)&quot;)</span><span style="color: #f8f8f2">;</span> <span style="color: #75715e">// This is invalid.</span>
  755. </span><span style="color: #f8f8f2">aux.add({</span> <span style="color: #f8f8f2">text,</span> <span style="color: #f8f8f2">button</span> <span style="color: #f8f8f2">});</span>
  756. </code></pre></div>
  757. <p>Similarly this, the uniqueness of the name is also necessary within the JSON document</p>
  758. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">{</span>
  759. <span style="color: #f92672">&quot;name&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;aux&quot;</span><span style="color: #f8f8f2">,</span>
  760. <span style="color: #f92672">&quot;uri&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;/aux&quot;</span><span style="color: #f8f8f2">,</span>
  761. <span style="color: #f92672">&quot;menu&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #66d9ef">true</span><span style="color: #f8f8f2">,</span>
  762. <span style="color: #f92672">&quot;element&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #f8f8f2">[</span>
  763. <span style="color: #f8f8f2">{</span>
  764. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;hello&quot;</span><span style="color: #f8f8f2">,</span>
  765. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACText&quot;</span><span style="color: #f8f8f2">,</span>
  766. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;hello, world&quot;</span>
  767. <span style="color: #f8f8f2">},</span>
  768. <span style="color: #f8f8f2">{</span>
  769. <span style="background-color: #49483e"> <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;hello&quot;</span><span style="color: #f8f8f2">,</span>
  770. </span> <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACButton&quot;</span><span style="color: #f8f8f2">,</span>
  771. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;hello, world&quot;</span><span style="color: #f8f8f2">,</span>
  772. <span style="color: #f92672">&quot;action&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;alert(&#39;Hello world!&#39;)&quot;</span>
  773. <span style="color: #f8f8f2">}</span>
  774. <span style="color: #f8f8f2">]</span>
  775. <span style="color: #f8f8f2">}</span>
  776. </code></pre></div>
  777. <div class="admonition note">
  778. <p class="admonition-title">Load all elements from JSON document</p>
  779. <p>If you load all AutoConnectElements from JSON document into AutoConnect, you do not need to sketch the population process of the AutoConnectElements. It is managed by the AutoConnect library automatically.</p>
  780. </div>
  781. <h3 id="get-autoconnectelement-from-the-autoconnectaux"><i class="fa fa-edit"></i> Get AutoConnectElement from the AutoConnectAux<a class="headerlink" href="#get-autoconnectelement-from-the-autoconnectaux" title="Permanent link">&para;</a></h3>
  782. <p>To retrieve an element from AutoConnectAux, use the getElement or getElements function. Normally, the getElement is needed when accessing the value of AutoConnectElement in the Sketch.</p>
  783. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">*</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  784. </code></pre></div>
  785. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">T</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">T</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  786. </code></pre></div>
  787. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">AutoConnectElementVT</span><span style="color: #f92672">*</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElements(</span><span style="color: #66d9ef">void</span><span style="color: #f8f8f2">)</span>
  788. </code></pre></div>
  789. <p>The <a href="apiaux.html#getelement"><strong>getElement</strong></a> function returns an AutoConnectElement with the specified name as a key. When you use this function, you need to know the type of AutoConnectElement in advance and specify its type &lt;T> to an argument of the getElement. A type of &lt;T> can be specified as follows.</p>
  790. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">AutoConnectButton</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectButton</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  791. <span style="color: #f8f8f2">AutoConnectCheckbox</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectCheckbox</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  792. <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  793. <span style="color: #f8f8f2">AutoConnectFile</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectFile</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  794. <span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  795. <span style="color: #f8f8f2">AutoConnectRadio</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectRadio</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  796. <span style="color: #f8f8f2">AutoConnectSelect</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectSelect</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  797. <span style="color: #f8f8f2">AutoConnectSubmit</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectSubmit</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  798. <span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">name)</span>
  799. </code></pre></div>
  800. <p>To retrieve an AutoConnectElement by specifying its type, use the following method.</p>
  801. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #f8f8f2">aux;</span>
  802. <span style="color: #f8f8f2">aux.load(</span><span style="color: #e6db74">&quot;SOME_JSON_DOCUMENT&quot;</span><span style="color: #f8f8f2">);</span>
  803. <span style="color: #75715e">// Retrieve the pointer of the AutoConnectText</span>
  804. <span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">*</span> <span style="color: #f8f8f2">text</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">reinterpret_cast</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">*&gt;</span><span style="color: #f8f8f2">(aux.getElement(</span><span style="color: #e6db74">&quot;TEXT_ELEMENT_NAME&quot;</span><span style="color: #f8f8f2">));</span>
  805. <span style="color: #75715e">// Retrieve the reference of the AutoConnectText</span>
  806. <span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">text</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">aux.getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;TEXT_ELEMENT_NAME&quot;</span><span style="color: #f8f8f2">);</span>
  807. </code></pre></div>
  808. <p>The AutoConnectElement type behaves as a variant of other element types. Therefore use cast or template to convert to actual type as above. In the Sketch, you access the real type of AutoConnectElement after casting it and storing into the variable.</p>
  809. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span> <span style="color: #f8f8f2">auxJson</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">String(</span><span style="color: #e6db74">&quot;{</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">title</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">:</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">Page 1 title</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">,</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">uri</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">:</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">/page1</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">,</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">menu</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">:true,</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">element</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">:[{</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">name</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">:</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">caption</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">,</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">type</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">:</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">ACText</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">,</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">value</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">:</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">hello, world</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">}]}&quot;</span><span style="color: #f8f8f2">);</span>
  810. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #f8f8f2">portal;</span>
  811. <span style="color: #f8f8f2">portal.load(auxJson);</span>
  812. <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">*</span> <span style="color: #f8f8f2">aux</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">portal.aux(</span><span style="color: #e6db74">&quot;/page1&quot;</span><span style="color: #f8f8f2">);</span> <span style="color: #75715e">// Identify the AutoConnectAux instance with uri</span>
  813. <span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">text</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">aux</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;caption&quot;</span><span style="color: #f8f8f2">);</span> <span style="color: #75715e">// Cast to real type and access members</span>
  814. <span style="color: #f8f8f2">Serial.println(text.value);</span>
  815. </code></pre></div>
  816. <p>You can also use the <a href="apiaux.html#operator">operator <strong><code>[]</code></strong> of AutoConnectAux</a> as another way to get the desired element. An operator <strong><code>[]</code></strong> is a shortcut for <a href="apiaux.html#getelement">getElement</a> function with the reference casting and makes simplify the Sketch code and treats like an array with the elements placed on a custom Web page. Its argument is the name of the element to be acquired similarly to getElement function. In the Sketch, by combining the <a href="apielements.html#ast62"><strong>AutoConnectElement::as&lt;T></strong></a> function with the operator <code>[]</code>, you can access the AutoConnectElements reference according to its actual type. For example, the following sketch code returns the same as a reference of AutoConnectText element as the <code>caption</code>.</p>
  817. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">AutoConnect</span> <span style="color: #f8f8f2">portal;</span>
  818. <span style="color: #f8f8f2">portal.load(auxJson);</span>
  819. <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">aux</span> <span style="color: #f92672">=</span> <span style="color: #f92672">*</span><span style="color: #f8f8f2">portal.aux(</span><span style="color: #e6db74">&quot;/page1&quot;</span><span style="color: #f8f8f2">);</span>
  820. <span style="background-color: #49483e"><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">text1</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">aux.getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;caption&quot;</span><span style="color: #f8f8f2">);</span>
  821. </span><span style="background-color: #49483e"><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">text2</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">aux[</span><span style="color: #e6db74">&quot;caption&quot;</span><span style="color: #f8f8f2">].as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">();</span>
  822. </span></code></pre></div>
  823. <div class="admonition note">
  824. <p class="admonition-title">Need cast to convert to the actual type</p>
  825. <p>An operator <code>[]</code> returns a reference of an AutoConnectElement. It is necessary to convert the type according to the actual element type with <a href="apielements.html#ast62">AutoConnectElement::as&lt;T></a> function.
  826. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">AutoConnectButton</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectButton</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">()</span>
  827. <span style="color: #f8f8f2">AutoConnectCheckbox</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectCheckbox</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">()</span>
  828. <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">()</span>
  829. <span style="color: #f8f8f2">AutoConnectFile</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectFile</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">()</span>
  830. <span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">()</span>
  831. <span style="color: #f8f8f2">AutoConnectRadio</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectRadio</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">()</span>
  832. <span style="color: #f8f8f2">AutoConnectSelect</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectSelect</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">()</span>
  833. <span style="color: #f8f8f2">AutoConnectSubmit</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectSubmit</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">()</span>
  834. <span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectElement</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">()</span>
  835. </code></pre></div></p>
  836. </div>
  837. <p>To get all the AutoConnectElements in an AutoConnectAux object use the <a href="apiaux.html#getelements"><strong>getElements</strong></a> function. This function returns the vector of the reference wrapper as <strong>AutoConnectElementVT</strong> to all AutoConnectElements registered in the AutoConnectAux.</p>
  838. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">AutoConnectElementVT</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">getElements(</span><span style="color: #66d9ef">void</span><span style="color: #f8f8f2">)</span>
  839. </code></pre></div>
  840. <h3 id="enable-autoconnectelements-during-the-sketch-execution"><i class="fa fa-edit"></i> Enable AutoConnectElements during the Sketch execution<a class="headerlink" href="#enable-autoconnectelements-during-the-sketch-execution" title="Permanent link">&para;</a></h3>
  841. <p>AutoConnectElemets have an enable attribute to activate its own HTML generation. Sketches can change the HTMLization of their elements dynamically by setting or resetting the enable value. An element whose the enable attribute is true will generate itself HTML and place on the custom Web page. And conversely, it will not generate the HTML when the value is false.</p>
  842. <p>For example, to enable the submit button only when the ESP module is connected to the access point in STA mode, you can sketch the following:</p>
  843. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;ESP8266WiFi.h&gt;</span>
  844. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;ESP8266WebServer.h&gt;</span>
  845. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;AutoConnect.h&gt;</span>
  846. <span style="color: #66d9ef">static</span> <span style="color: #66d9ef">const</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">AUX[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">R(</span><span style="color: #e6db74">&quot;</span>
  847. <span style="color: #f8f8f2">{</span>
  848. <span style="color: #e6db74">&quot;name&quot;</span> <span style="color: #f92672">:</span> <span style="color: #e6db74">&quot;aux&quot;</span><span style="color: #f8f8f2">,</span>
  849. <span style="color: #e6db74">&quot;uri&quot;</span> <span style="color: #f92672">:</span> <span style="color: #e6db74">&quot;/aux&quot;</span><span style="color: #f8f8f2">,</span>
  850. <span style="color: #e6db74">&quot;menu&quot;</span> <span style="color: #f92672">:</span> <span style="color: #f8f8f2">true,</span>
  851. <span style="color: #e6db74">&quot;element&quot;</span> <span style="color: #f92672">:</span> <span style="color: #f8f8f2">[</span>
  852. <span style="color: #f8f8f2">{</span>
  853. <span style="color: #e6db74">&quot;name&quot;</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&quot;input&quot;</span><span style="color: #f8f8f2">,</span>
  854. <span style="color: #e6db74">&quot;type&quot;</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&quot;ACInput&quot;</span><span style="color: #f8f8f2">,</span>
  855. <span style="color: #e6db74">&quot;label&quot;</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&quot;Input&quot;</span>
  856. <span style="color: #f8f8f2">},</span>
  857. <span style="color: #f8f8f2">{</span>
  858. <span style="color: #e6db74">&quot;name&quot;</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&quot;send&quot;</span><span style="color: #f8f8f2">,</span>
  859. <span style="color: #e6db74">&quot;type&quot;</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&quot;ACSubmit&quot;</span><span style="color: #f8f8f2">,</span>
  860. <span style="color: #e6db74">&quot;uri&quot;</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&quot;/send&quot;</span>
  861. <span style="color: #f8f8f2">}</span>
  862. <span style="color: #f8f8f2">]</span>
  863. <span style="color: #f8f8f2">}</span>
  864. <span style="color: #e6db74">&quot;);</span>
  865. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #f8f8f2">portal;</span>
  866. <span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #f8f8f2">page;</span>
  867. <span style="color: #f8f8f2">String</span> <span style="color: #a6e22e">onPage</span><span style="color: #f8f8f2">(AutoConectAux</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">aux,</span> <span style="color: #f8f8f2">PageArgument</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">args)</span> <span style="color: #f8f8f2">{</span>
  868. <span style="color: #f8f8f2">AutoConnectSubmit</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">send</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">aux[</span><span style="color: #e6db74">&quot;send&quot;</span><span style="color: #f8f8f2">].as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectSubmit</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">();</span>
  869. <span style="background-color: #49483e"> <span style="color: #66d9ef">if</span> <span style="color: #f8f8f2">(WiFi.isConnected())</span>
  870. </span><span style="background-color: #49483e"> <span style="color: #f8f8f2">send.enable</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">(WiFi.getMode()</span> <span style="color: #f92672">==</span> <span style="color: #f8f8f2">WIFI_STA);</span>
  871. </span><span style="background-color: #49483e"> <span style="color: #66d9ef">else</span>
  872. </span><span style="background-color: #49483e"> <span style="color: #f8f8f2">send.enable</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">false;</span>
  873. </span> <span style="color: #66d9ef">return</span> <span style="color: #f8f8f2">String();</span>
  874. <span style="color: #f8f8f2">}</span>
  875. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">setup</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  876. <span style="color: #f8f8f2">page.load(AUX);</span>
  877. <span style="color: #f8f8f2">page.on(onPage);</span>
  878. <span style="color: #f8f8f2">portal.join(page);</span>
  879. <span style="color: #f8f8f2">portal.begin();</span>
  880. <span style="color: #f8f8f2">}</span>
  881. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">loop</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  882. <span style="color: #f8f8f2">portal.handleClient();</span>
  883. <span style="color: #f8f8f2">}</span>
  884. </code></pre></div>
  885. <div class="admonition hint">
  886. <p class="admonition-title">Desirable to set or reset the enable attribute in the page handler</p>
  887. <p>The enable attribute can be set at any time during the Sketch execution. The page handler with the <a href="apiaux.html#on">AC_EXIT_AHEAD</a> option is sure to handle it.</p>
  888. </div>
  889. <h2 id="loading-saving-autoconnectelements-with-json">Loading &amp; saving AutoConnectElements with JSON<a class="headerlink" href="#loading-saving-autoconnectelements-with-json" title="Permanent link">&para;</a></h2>
  890. <p>AutoConnect supports reading the custom Web page definitions written in JSON and also supports loading and saving of AutoConnectAux or AutoConnectElements. In both cases, the target object is a <a href="acjson.html">JSON document for AutoConnect</a>. However, it can not save all AutoConnectElements contained in the page as a custom Web page. (ie. AutoConnectAux)</p>
  891. <p><img src="images/ac_load_save.svg"></p>
  892. <h3 id="loading-autoconnectaux-autoconnectelements-with-json"><i class="fa fa-upload"></i> Loading AutoConnectAux &amp; AutoConnectElements with JSON<a class="headerlink" href="#loading-autoconnectaux-autoconnectelements-with-json" title="Permanent link">&para;</a></h3>
  893. <p>To load a JSON document as AutoConnectAux use the <a href="api.html#load"><strong>AutoConnect::load</strong></a> function and load the JSON document of each AutoConnectElement using the <a href="apiaux.html#loadelement"><strong>AutoConnectAux::loadElement</strong></a> function. Although the functions of both are similar, the structure of the target JSON document is different.</p>
  894. <p>The <a href="apiaux.html#load">AutoConnect::load</a> function loads the entire AutoConnectAux and creates both the AutoConnectAux instance and each AutoConnectElement instance. A single JSON document can contain multiple custom Web pages. If you write JSON of AutoConnectAux as an array, the load function generates all the pages contained in that array. Therefore, it is necessary to supply the JSON document of AutoConnectAux as an input of the load function and must contain the elements described section <a href="acjson.html#json-document-structure-for-autoconnectaux"><em>JSON document structure for AutoConnectAux</em></a>.</p>
  895. <p>The <a href="apiaux.html#loadelement">AutoConnectAux::loadElement</a> function loads the elements individually into an AutoConnectAux object. The structure of its supplying JSON document is not AutoConnectAux. It must be a <a href="acjson.html#json-object-for-autoconnectelements">JSON structure for AutoConnectElement</a>, but you can specify an array.</p>
  896. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #75715e">// AutoConnectAux as a custom Web page.</span>
  897. <span style="color: #66d9ef">const</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">page[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;raw(</span>
  898. <span style="color: #e6db74">{</span>
  899. <span style="color: #e6db74"> &quot;title&quot;: &quot;Settings&quot;,</span>
  900. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/settings&quot;,</span>
  901. <span style="color: #e6db74"> &quot;menu&quot;: true,</span>
  902. <span style="color: #e6db74"> &quot;element&quot;: [</span>
  903. <span style="color: #e6db74"> {</span>
  904. <span style="color: #e6db74"> &quot;name&quot;: &quot;server&quot;,</span>
  905. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACInput&quot;,</span>
  906. <span style="color: #e6db74"> &quot;label&quot;: &quot;Server&quot;</span>
  907. <span style="color: #e6db74"> },</span>
  908. <span style="color: #e6db74"> {</span>
  909. <span style="color: #e6db74"> &quot;name&quot;: &quot;set&quot;,</span>
  910. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACSubmit&quot;,</span>
  911. <span style="color: #e6db74"> &quot;value&quot;: &quot;SET&quot;,</span>
  912. <span style="color: #e6db74"> &quot;uri&quot; : &quot;/set&quot;</span>
  913. <span style="color: #e6db74"> }</span>
  914. <span style="color: #e6db74"> ]</span>
  915. <span style="color: #e6db74">}</span>
  916. <span style="color: #e6db74">)raw&quot;</span><span style="color: #f8f8f2">;</span>
  917. <span style="color: #75715e">// Additional AutoConnectElements.</span>
  918. <span style="color: #66d9ef">const</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">addons[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;raw(</span>
  919. <span style="color: #e6db74">[</span>
  920. <span style="color: #e6db74"> {</span>
  921. <span style="color: #e6db74"> &quot;name&quot;: &quot;notes&quot;,</span>
  922. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACText&quot;,</span>
  923. <span style="color: #e6db74"> &quot;value&quot;: &quot;An update period as the below optionally.&quot;</span>
  924. <span style="color: #e6db74"> },</span>
  925. <span style="color: #e6db74"> {</span>
  926. <span style="color: #e6db74"> &quot;name&quot;: &quot;period&quot;,</span>
  927. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACRadio&quot;,</span>
  928. <span style="color: #e6db74"> &quot;value&quot;: [</span>
  929. <span style="color: #e6db74"> &quot;30 sec.&quot;,</span>
  930. <span style="color: #e6db74"> &quot;60 sec.&quot;,</span>
  931. <span style="color: #e6db74"> &quot;180 sec.&quot;</span>
  932. <span style="color: #e6db74"> ],</span>
  933. <span style="color: #e6db74"> &quot;arrange&quot;: &quot;vertical&quot;,</span>
  934. <span style="color: #e6db74"> &quot;checked&quot;: 1</span>
  935. <span style="color: #e6db74"> }</span>
  936. <span style="color: #e6db74">]</span>
  937. <span style="color: #e6db74">)raw&quot;</span><span style="color: #f8f8f2">;</span>
  938. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #f8f8f2">portal;</span>
  939. <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">*</span> <span style="color: #f8f8f2">auxPage;</span>
  940. <span style="color: #75715e">// Load a custom Web page.</span>
  941. <span style="background-color: #49483e"><span style="color: #f8f8f2">portal.load(page);</span>
  942. </span>
  943. <span style="color: #75715e">// Get a &#39;/settings&#39; page</span>
  944. <span style="color: #f8f8f2">auxPage</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">portal.aux(</span><span style="color: #e6db74">&quot;/settings&quot;</span><span style="color: #f8f8f2">);</span>
  945. <span style="color: #75715e">// Also, load only AutoConnectRadio named the period.</span>
  946. <span style="background-color: #49483e"><span style="color: #f8f8f2">auxPage</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">loadElement(addons,</span> <span style="color: #e6db74">&quot;period&quot;</span><span style="color: #f8f8f2">);</span>
  947. </span>
  948. <span style="color: #75715e">// Retrieve a server name from an AutoConnectText value.</span>
  949. <span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">serverName</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">auxPage</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;server&quot;</span><span style="color: #f8f8f2">);</span>
  950. <span style="color: #f8f8f2">Serial.println(serverName.value);</span>
  951. </code></pre></div>
  952. <h3 id="saving-autoconnectelements-with-json"><i class="fa fa-download"></i> Saving AutoConnectElements with JSON<a class="headerlink" href="#saving-autoconnectelements-with-json" title="Permanent link">&para;</a></h3>
  953. <p>To save the AutoConnectAux or the AutoConnectElement as a JSON document, use the <a href="apiaux.html#saveelement">AutoConnectAux::saveElement</a> function. It serializes the contents of the object based on the type of the AutoConnectElement. You can persist a serialized AutoConnectElements as a JSON document to a stream.</p>
  954. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #75715e">// Open a parameter file on the SPIFFS.</span>
  955. <span style="color: #f8f8f2">SPIFFS.begin();</span>
  956. <span style="color: #66d9ef">FILE</span> <span style="color: #f8f8f2">param</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">SPIFFS.open(</span><span style="color: #e6db74">&quot;/param&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;w&quot;</span><span style="color: #f8f8f2">);</span>
  957. <span style="color: #75715e">// Save elements as the parameters.</span>
  958. <span style="color: #f8f8f2">auxPage</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">saveElement(param,</span> <span style="color: #f8f8f2">{</span> <span style="color: #e6db74">&quot;server&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;period&quot;</span> <span style="color: #f8f8f2">});</span>
  959. <span style="color: #75715e">// Close a parameter file.</span>
  960. <span style="color: #f8f8f2">param.close();</span>
  961. <span style="color: #f8f8f2">SPIFFS.end();</span>
  962. </code></pre></div>
  963. <p>The example above saves <code>server</code> and <code>period</code> elements from the AutoConnectAux object as mentioned above to the <code>/param</code> file on SPIFFS. Its JSON document of AutoConnectElements saved by its code looks like this:</p>
  964. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">[</span>
  965. <span style="color: #f8f8f2">{</span>
  966. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;server&quot;</span><span style="color: #f8f8f2">,</span>
  967. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACInput&quot;</span><span style="color: #f8f8f2">,</span>
  968. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;An inputted server name&quot;</span><span style="color: #f8f8f2">,</span>
  969. <span style="color: #f92672">&quot;label&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;Server&quot;</span><span style="color: #f8f8f2">,</span>
  970. <span style="color: #f92672">&quot;placeholder&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;&quot;</span>
  971. <span style="color: #f8f8f2">},</span>
  972. <span style="color: #f8f8f2">{</span>
  973. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;period&quot;</span><span style="color: #f8f8f2">,</span>
  974. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACRadio&quot;</span><span style="color: #f8f8f2">,</span>
  975. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #f8f8f2">[</span>
  976. <span style="color: #e6db74">&quot;30 sec.&quot;</span><span style="color: #f8f8f2">,</span>
  977. <span style="color: #e6db74">&quot;60 sec.&quot;</span><span style="color: #f8f8f2">,</span>
  978. <span style="color: #e6db74">&quot;180 sec.&quot;</span>
  979. <span style="color: #f8f8f2">],</span>
  980. <span style="color: #f92672">&quot;arrange&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;vertical&quot;</span><span style="color: #f8f8f2">,</span>
  981. <span style="color: #f92672">&quot;checked&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #ae81ff">2</span>
  982. <span style="color: #f8f8f2">}</span>
  983. <span style="color: #f8f8f2">]</span>
  984. </code></pre></div>
  985. <p>Above JSON document can be loaded as it is into a custom Web page using the loadElement function. The loadElement function also loads the value of the element, so the saved value can be restored on the custom Web page.</p>
  986. <h2 id="custom-field-data-handling">Custom field data handling<a class="headerlink" href="#custom-field-data-handling" title="Permanent link">&para;</a></h2>
  987. <p>A sketch can access variables of AutoConnectElements in the custom Web page. The value entered into the AutoConnectElements on the page is stored in the member variable of each element by AutoConnect whenever GET/POST transmission occurs. </p>
  988. <p>The following diagram shows the flow of the input values of a custom Web page into a sketch and is the basis for actions to manipulate the values of custom Web pages using sketches.</p>
  989. <p><img src="images/ac_param_flow.svg"></p>
  990. <h3 id="where-to-pick-up-the-values"><i class="fa fa-desktop"></i> Where to pick up the values<a class="headerlink" href="#where-to-pick-up-the-values" title="Permanent link">&para;</a></h3>
  991. <p>A sketch composed of handlers can receive the value of AutoConnectElements entered in a custom Web page after sending, but that handler is different from the page where the value was entered. It is necessary to be aware that can accept the entered values by the next page handler after the transition.</p>
  992. <p>Usually, two ways to retrieve entered values we have. One is to use the <a href="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#getting-information-about-request-arguments">ESP8266WebServer::arg</a> (or WebServer::arg for ESP32) function in the <a href="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#client-request-handlers"><code>on handler</code></a> attached by ESP8266WebServer (WebServer w/ESP32 also).</p>
  993. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;ESP8266WiFi.h&gt;</span>
  994. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;ESP8266WebServer.h&gt;</span>
  995. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;AutoConnect.h&gt;</span>
  996. <span style="color: #66d9ef">static</span> <span style="color: #66d9ef">const</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">addonJson[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;raw(</span>
  997. <span style="color: #e6db74">{</span>
  998. <span style="color: #e6db74"> &quot;title&quot;: &quot;Hello&quot;,</span>
  999. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/hello&quot;,</span>
  1000. <span style="color: #e6db74"> &quot;menu&quot;: true,</span>
  1001. <span style="color: #e6db74"> &quot;element&quot;: [</span>
  1002. <span style="color: #e6db74"> {</span>
  1003. <span style="color: #e6db74"> &quot;name&quot;: &quot;feels&quot;,</span>
  1004. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACInput&quot;,</span>
  1005. <span style="color: #e6db74"> &quot;label&quot;: &quot;What&#39;s up?&quot;</span>
  1006. <span style="color: #e6db74"> },</span>
  1007. <span style="color: #e6db74"> {</span>
  1008. <span style="color: #e6db74"> &quot;name&quot;: &quot;send&quot;,</span>
  1009. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACSubmit&quot;,</span>
  1010. <span style="color: #e6db74"> &quot;value&quot;: &quot;Just it!&quot;,</span>
  1011. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/feels&quot;</span>
  1012. <span style="color: #e6db74"> }</span>
  1013. <span style="color: #e6db74"> ]</span>
  1014. <span style="color: #e6db74">}</span>
  1015. <span style="color: #e6db74">)raw&quot;</span><span style="color: #f8f8f2">;</span>
  1016. <span style="color: #f8f8f2">ESP8266WebServer</span> <span style="color: #f8f8f2">webServer;</span>
  1017. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #a6e22e">portal</span><span style="color: #f8f8f2">(webServer);</span>
  1018. <span style="color: #75715e">// Here, /feels handler</span>
  1019. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">feelsOn</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1020. <span style="color: #75715e">// Retrieve the value of a input-box named &quot;feels&quot;</span>
  1021. <span style="background-color: #49483e"> <span style="color: #f8f8f2">String</span> <span style="color: #f8f8f2">feel</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">webServer.arg(</span><span style="color: #e6db74">&quot;feels&quot;</span><span style="color: #f8f8f2">);</span>
  1022. </span>
  1023. <span style="color: #75715e">// Echo back the value</span>
  1024. <span style="color: #f8f8f2">String</span> <span style="color: #f8f8f2">echo</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">&quot;&lt;html&gt;&lt;p style=</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">color:blue;font-family:verdana;font-size:300%;</span><span style="color: #ae81ff">\&quot;</span><span style="color: #e6db74">&gt;&quot;</span> <span style="color: #f92672">+</span> <span style="color: #f8f8f2">feel</span> <span style="color: #f92672">+</span> <span style="color: #f8f8f2">String(</span><span style="color: #e6db74">&quot; and a bold world!&lt;/p&gt;&lt;/html&gt;&quot;</span><span style="color: #f8f8f2">);</span>
  1025. <span style="color: #f8f8f2">webServer.send(</span><span style="color: #ae81ff">200</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;text/html&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">echo);</span>
  1026. <span style="color: #f8f8f2">}</span>
  1027. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">setup</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1028. <span style="color: #f8f8f2">delay(</span><span style="color: #ae81ff">1000</span><span style="color: #f8f8f2">);</span>
  1029. <span style="color: #f8f8f2">webServer.on(</span><span style="color: #e6db74">&quot;/feels&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">feelsOn);</span> <span style="color: #75715e">// Register /feels handler</span>
  1030. <span style="color: #f8f8f2">portal.load(addonJson);</span> <span style="color: #75715e">// Load a custom Web page</span>
  1031. <span style="color: #f8f8f2">portal.begin();</span>
  1032. <span style="color: #f8f8f2">}</span>
  1033. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">loop</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1034. <span style="color: #f8f8f2">portal.handleClient();</span>
  1035. <span style="color: #f8f8f2">}</span>
  1036. </code></pre></div>
  1037. <p>An above example is the most simple sketch of handling values entered into a custom Web page. This sketch obtains the string entered in the AutoConnectInput named <code>feels</code> with the <code>/feels</code> handler after page transition, and the AutoConnectInput is an <code>&lt;input type="text" name="feels"&gt;</code> element wrapped in the form as the actual HTML code. </p>
  1038. <div class="admonition info">
  1039. <p class="admonition-title">Should be accessed <code>/_ac</code> first</p>
  1040. <p>When you actually try the above sketch, there is no a root handler. So the URL that should be accessed first is <code>/_ac</code> concatenated with the local IP address of the esp8266 module.</p>
  1041. </div>
  1042. <p>Another method is effective when custom Web pages have complicated page transitions. It is a way to straight access the AutoConnectElements member value. You can get the AutoConnectElement with the specified name using the <a href="#get-autoconnectelement-from-the-autoconnectaux">getElement</a> function. The following sketch executes the above example with AutoConnect only, without using the function of ESP8266WebServer.</p>
  1043. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;ESP8266WiFi.h&gt;</span>
  1044. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;ESP8266WebServer.h&gt;</span>
  1045. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;AutoConnect.h&gt;</span>
  1046. <span style="color: #66d9ef">const</span> <span style="color: #66d9ef">static</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">addonJson[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;raw(</span>
  1047. <span style="color: #e6db74">[</span>
  1048. <span style="color: #e6db74"> {</span>
  1049. <span style="color: #e6db74"> &quot;title&quot;: &quot;Hello&quot;,</span>
  1050. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/hello&quot;,</span>
  1051. <span style="color: #e6db74"> &quot;menu&quot;: true,</span>
  1052. <span style="color: #e6db74"> &quot;element&quot;: [</span>
  1053. <span style="color: #e6db74"> {</span>
  1054. <span style="color: #e6db74"> &quot;name&quot;: &quot;feels&quot;,</span>
  1055. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACInput&quot;,</span>
  1056. <span style="color: #e6db74"> &quot;label&quot;: &quot;What&#39;s up?&quot;</span>
  1057. <span style="color: #e6db74"> },</span>
  1058. <span style="color: #e6db74"> {</span>
  1059. <span style="color: #e6db74"> &quot;name&quot;: &quot;send&quot;,</span>
  1060. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACSubmit&quot;,</span>
  1061. <span style="color: #e6db74"> &quot;value&quot;: &quot;Just it!&quot;,</span>
  1062. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/feels&quot;</span>
  1063. <span style="color: #e6db74"> }</span>
  1064. <span style="color: #e6db74"> ]</span>
  1065. <span style="color: #e6db74"> },</span>
  1066. <span style="color: #e6db74"> {</span>
  1067. <span style="color: #e6db74"> &quot;title&quot;: &quot;Hello&quot;,</span>
  1068. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/feels&quot;,</span>
  1069. <span style="color: #e6db74"> &quot;menu&quot;: false,</span>
  1070. <span style="color: #e6db74"> &quot;element&quot;: [</span>
  1071. <span style="color: #e6db74"> {</span>
  1072. <span style="color: #e6db74"> &quot;name&quot;: &quot;echo&quot;,</span>
  1073. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACText&quot;,</span>
  1074. <span style="color: #e6db74"> &quot;style&quot;: &quot;color:blue;font-family:verdana;font-size:300%;&quot;</span>
  1075. <span style="color: #e6db74"> }</span>
  1076. <span style="color: #e6db74"> ]</span>
  1077. <span style="color: #e6db74"> }</span>
  1078. <span style="color: #e6db74">]</span>
  1079. <span style="color: #e6db74">)raw&quot;</span><span style="color: #f8f8f2">;</span>
  1080. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #f8f8f2">portal;</span>
  1081. <span style="color: #75715e">// Here, /feels handler</span>
  1082. <span style="color: #f8f8f2">String</span> <span style="color: #a6e22e">feelsOn</span><span style="color: #f8f8f2">(AutoConnectAux</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">aux,</span> <span style="color: #f8f8f2">PageArgument</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">args)</span> <span style="color: #f8f8f2">{</span>
  1083. <span style="color: #75715e">// Get the AutoConnectInput named &quot;feels&quot;.</span>
  1084. <span style="color: #75715e">// The where() function returns an uri string of the AutoConnectAux that triggered this handler.</span>
  1085. <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">*</span> <span style="color: #f8f8f2">hello</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">portal.aux(portal.where());</span>
  1086. <span style="background-color: #49483e"> <span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">feels</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">hello</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;feels&quot;</span><span style="color: #f8f8f2">);</span>
  1087. </span>
  1088. <span style="color: #75715e">// Get the AutoConnectText named &quot;echo&quot;.</span>
  1089. <span style="background-color: #49483e"> <span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">echo</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">aux.getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;echo&quot;</span><span style="color: #f8f8f2">);</span>
  1090. </span>
  1091. <span style="color: #75715e">// Echo back from input-box to /feels page.</span>
  1092. <span style="color: #f8f8f2">echo.value</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">feels.value</span> <span style="color: #f92672">+</span> <span style="color: #f8f8f2">String(</span><span style="color: #e6db74">&quot; and a bold world!&quot;</span><span style="color: #f8f8f2">);</span>
  1093. <span style="color: #66d9ef">return</span> <span style="color: #f8f8f2">String(</span><span style="color: #e6db74">&quot;&quot;</span><span style="color: #f8f8f2">);</span>
  1094. <span style="color: #f8f8f2">}</span>
  1095. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">setup</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1096. <span style="color: #f8f8f2">delay(</span><span style="color: #ae81ff">1000</span><span style="color: #f8f8f2">);</span>
  1097. <span style="color: #f8f8f2">portal.load(addonJson);</span> <span style="color: #75715e">// Load custom Web pages</span>
  1098. <span style="color: #f8f8f2">portal.on(</span><span style="color: #e6db74">&quot;/feels&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">feelsOn,</span> <span style="color: #f8f8f2">AC_EXIT_AHEAD);</span> <span style="color: #75715e">// Register /feels handler</span>
  1099. <span style="color: #f8f8f2">portal.begin();</span>
  1100. <span style="color: #f8f8f2">}</span>
  1101. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">loop</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1102. <span style="color: #f8f8f2">portal.handleClient();</span>
  1103. <span style="color: #f8f8f2">}</span>
  1104. </code></pre></div>
  1105. <p>The above example handles in the handler for the values of a custom Web page. An <a href="api.html#on">AutoConnect::on</a> function registers a handler for the AutoConnectAux page of the specified uri. The argument of the custom Web page handler is an AutoConnectAux of the page itself and the <a href="https://github.com/Hieromon/PageBuilder#arguments-of-invoked-user-function">PageArgument</a> object.</p>
  1106. <p>To retrieve the values entered in a custom Web page you need to access the AutoConnectElement of the page that caused the request to this page and to do this, you use the <a href="api.html#where">AutoConnect::where</a> function. The <code>AutoConnect::where</code> function returns an uri string of the AutoConnectAux object of the custom Web page that caused the HTTP request.</p>
  1107. <div class="admonition note">
  1108. <p class="admonition-title">The where() function is available for only AutoConnectAux.</p>
  1109. <p>The <code>AutoConnect::where</code> function is available only for the AutoConnectAux object. It is invalid for HTTP requests from individual pages registered with the <strong>on</strong> handler of ESP8266WebServer/WebServer for ESP32. In other words, the <code>AutoConnect::where</code> function only returns the last AutoConnecAux page called.</p>
  1110. </div>
  1111. <h3 id="when-setting-the-initial-values"><i class="fa fa-desktop"></i> When setting the initial values<a class="headerlink" href="#when-setting-the-initial-values" title="Permanent link">&para;</a></h3>
  1112. <p>An AutoConnectAux page is dynamically created by AutoConnect when its uri is requested. The initial value of AutoConnectElements can be set before its page request. It is also possible during <code>loop()</code>. To set the initial value when the page is accessed it needs by the handler of its page.</p>
  1113. <p>The <a href="api.html#on"><strong>AutoConnect::on</strong></a> and <a href="apiaux.html#on"><strong>AutoConnectAux::on</strong></a> functions register a handler for a custom Web page and also specify when to call that handler. The behavior of the two <code>on</code> functions is the same, only the class and arguments are different.</p>
  1114. <p><div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">bool</span> <span style="color: #f8f8f2">AutoConnect</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">on(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">String</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">uri,</span> <span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">AuxHandlerFunctionT</span> <span style="color: #f8f8f2">handler,</span> <span style="color: #f8f8f2">AutoConnectExitOrder_t</span> <span style="color: #f8f8f2">order)</span>
  1115. </code></pre></div>
  1116. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">void</span> <span style="color: #f8f8f2">AutoConnectAux</span><span style="color: #f92672">::</span><span style="color: #f8f8f2">on(</span><span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">AuxHandlerFunctionT</span> <span style="color: #f8f8f2">handler,</span> <span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">AutoConnectExitOrder_t</span> <span style="color: #f8f8f2">order)</span>
  1117. </code></pre></div></p>
  1118. <p>Parameter <code>uri</code> specifies an URI of the custom Web page, but an AutoConnectAux object with its URI must be registered with AutoConnect via the <a href="api.html#join">AutoConnect::join</a> function beforehand.</p>
  1119. <div class="admonition note">
  1120. <p class="admonition-title">AutoConnect::on/AutoConnectAux::on is not ESP8266WebServer::on</p>
  1121. <p>The <code>on</code> function for AutoConnect is different from the <code>on</code> function of Arduino core ESP8266WebServer (WebServer for ESP32). You can share the same handler via wrapper, but access to AutoConnectElements is <strong>valid only for handlers registered with <code>on</code> function for AutoConnect</strong>.</p>
  1122. </div>
  1123. <p><code>AuxHandlerFunctionT</code> type is a handler declaration using with <a href="https://en.cppreference.com/w/cpp/utility/functional/function">std::function</a>.</p>
  1124. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">String</span> <span style="color: #f8f8f2">handler(AutoConnectAux</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">aux,</span> <span style="color: #f8f8f2">PageArgument</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">args)</span>
  1125. </code></pre></div>
  1126. <p>The handler of the custom Web page has two arguments by a reference of AutoConnectAux and a reference of PageArgument, it returns String. AutoConnect appends the string returned from the handler to the generated HTML. This allows you to add an HTML part before displaying the page.</p>
  1127. <dl>
  1128. <dt><code>AutoConnectExitOrder_t</code> specifies when the handler is called with the following enumeration value.</dt>
  1129. <dd>
  1130. <ul>
  1131. <li><strong>AC_EXIT_AHEAD</strong> : Called before AutoConnect generates the HTML of the page. You set the value of AutoConnectElements in the handler then its value will be displayed on the page.</li>
  1132. </ul>
  1133. </dd>
  1134. <dd>
  1135. <ul>
  1136. <li><strong>AC_EXIT_LATER</strong> : Called after AutoConnect generates the HTML of the page. You can append to HTML generated by AutoConnect.</li>
  1137. </ul>
  1138. </dd>
  1139. <dd>
  1140. <ul>
  1141. <li><strong>AC_EXIT_BOTH</strong> : Called even before generating HTML and after generated.</li>
  1142. </ul>
  1143. </dd>
  1144. </dl>
  1145. <p>The following example is a part of sketch contained the handlers. </p>
  1146. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #75715e">// AutoConnect object declarations</span>
  1147. <span style="color: #f8f8f2">ACInput(input1);</span>
  1148. <span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #a6e22e">aux</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;/aux&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">{</span> <span style="color: #f8f8f2">input1</span> <span style="color: #f8f8f2">});</span>
  1149. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #f8f8f2">portal;</span>
  1150. <span style="color: #75715e">// Pre-declare handlers</span>
  1151. <span style="color: #f8f8f2">String</span> <span style="color: #a6e22e">initialize</span><span style="color: #f8f8f2">(AutoConnectAux</span><span style="color: #f92672">&amp;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">PageArgument</span><span style="color: #f92672">&amp;</span><span style="color: #f8f8f2">);</span>
  1152. <span style="color: #f8f8f2">String</span> <span style="color: #a6e22e">append</span><span style="color: #f8f8f2">(AutoConnectAux</span><span style="color: #f92672">&amp;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">PageArgument</span><span style="color: #f92672">&amp;</span><span style="color: #f8f8f2">);</span>
  1153. <span style="color: #75715e">// Register handlers and launch the portal.</span>
  1154. <span style="color: #f8f8f2">aux.on(initialize,</span> <span style="color: #f8f8f2">AC_AHEAD);</span>
  1155. <span style="color: #f8f8f2">aux.on(append,</span> <span style="color: #f8f8f2">AC_LATER);</span>
  1156. <span style="color: #f8f8f2">portal.join(aux);</span>
  1157. <span style="color: #f8f8f2">portal.begin();</span>
  1158. <span style="color: #75715e">// Some code here...</span>
  1159. <span style="color: #75715e">// The handler called before HTML generating</span>
  1160. <span style="color: #f8f8f2">String</span> <span style="color: #a6e22e">initialize</span><span style="color: #f8f8f2">(AutoConnectAux</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">aux,</span> <span style="color: #f8f8f2">PageArgument</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">args)</span> <span style="color: #f8f8f2">{</span>
  1161. <span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">input1</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">aux.getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;input1&quot;</span><span style="color: #f8f8f2">);</span>
  1162. <span style="color: #75715e">// Set initial value for the input box in a custom Web page.</span>
  1163. <span style="color: #f8f8f2">input1.value</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">&quot;Initial value&quot;</span><span style="color: #f8f8f2">;</span>
  1164. <span style="color: #75715e">// Nothing appendix for a generated HTML.</span>
  1165. <span style="color: #66d9ef">return</span> <span style="color: #f8f8f2">String();</span>
  1166. <span style="color: #f8f8f2">}</span>
  1167. <span style="color: #75715e">// The handler called after HTML generated</span>
  1168. <span style="color: #f8f8f2">String</span> <span style="color: #a6e22e">append</span><span style="color: #f8f8f2">(AutoConnectAux</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">aux,</span> <span style="color: #f8f8f2">PageArgument</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">args)</span> <span style="color: #f8f8f2">{</span>
  1169. <span style="color: #75715e">// Append an HTML</span>
  1170. <span style="color: #66d9ef">return</span> <span style="color: #f8f8f2">String(</span><span style="color: #e6db74">&quot;&lt;p&gt;This text has been added.&lt;/p&gt;&quot;</span><span style="color: #f8f8f2">);</span>
  1171. <span style="color: #f8f8f2">}</span>
  1172. </code></pre></div>
  1173. <h3 id="how-you-can-reach-the-values"><i class="fa fa-wrench"></i> How you can reach the values<a class="headerlink" href="#how-you-can-reach-the-values" title="Permanent link">&para;</a></h3>
  1174. <p>AutoConnectSubmit uses the POST method to send HTTP requests. A value of AutoConnectInput sent to the ESP8266 or ESP32 with POST is stored in the request body of the HTTP request:
  1175. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">POST</span> <span style="color: #f8f8f2">/feels</span> <span style="color: #f8f8f2">HTTP/1.1</span>
  1176. <span style="color: #f8f8f2">Host</span><span style="color: #960050; background-color: #1e0010">:</span> <span style="color: #f8f8f2">ESP8266_IP_ADDRESS</span>
  1177. <span style="color: #f8f8f2">name1=value1&amp;name2=value2&amp;name3=value3</span>
  1178. </code></pre></div>
  1179. ESP8266WebServer class will parse the query string and rebuilds its arguments when the above request arrives. A custom page handler registered with the <a href="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#client-request-handlers">ESP8266WebServer::on</a> function can access the value of AutoConnectElements with <a href="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#getting-information-about-request-arguments">ESP8266WebServe::arg</a> function. It reaches the values of AutoConnectElements without the intermediation of AutoConnect. Therefore, its handler will not be AutoConnectAux and can send a response to the client directly. The following example is part of a server sketch which has two web pages. The <code>/hello</code> page is a custom Web page of AutoConnectAux which has an input box named "input1". Another <code>/echo</code> page is a page handler for ESP8266WebServer, which uses the <a href="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#sending-responses-to-the-client">ESP8266WebServer::send</a> function to echo back the value of an input1 as an http response.</p>
  1180. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">ESP8266WebServer</span> <span style="color: #f8f8f2">server;</span>
  1181. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #a6e22e">portal</span><span style="color: #f8f8f2">(server);</span>
  1182. <span style="background-color: #49483e"><span style="color: #f8f8f2">ACInput(input1,</span> <span style="color: #e6db74">&quot;&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;INPUT&quot;</span><span style="color: #f8f8f2">);</span>
  1183. </span><span style="color: #f8f8f2">ACSubmit(send,</span> <span style="color: #e6db74">&quot;HELLO&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;/echo&quot;</span><span style="color: #f8f8f2">);</span>
  1184. <span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #a6e22e">aux</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;/hello&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">{</span> <span style="color: #f8f8f2">input1,</span> <span style="color: #f8f8f2">send</span> <span style="color: #f8f8f2">});</span>
  1185. <span style="color: #f8f8f2">server.on(</span><span style="color: #e6db74">&quot;/echo&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">[]()</span> <span style="color: #f8f8f2">{</span>
  1186. <span style="background-color: #49483e"> <span style="color: #f8f8f2">String</span> <span style="color: #f8f8f2">echo</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">server.arg(</span><span style="color: #e6db74">&quot;input1&quot;</span><span style="color: #f8f8f2">);</span>
  1187. </span> <span style="color: #f8f8f2">Serial.println(echo);</span>
  1188. <span style="color: #f8f8f2">server.send(</span><span style="color: #ae81ff">200</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;text/plain&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">echo);</span>
  1189. <span style="color: #f8f8f2">});</span>
  1190. <span style="color: #f8f8f2">portal.join(aux);</span>
  1191. <span style="color: #f8f8f2">portal.begin();</span>
  1192. </code></pre></div>
  1193. <p>Also, you can choose another way to access arguments without going through the ESP8266WebServer class. The <a href="https://github.com/Hieromon/PageBuilder#arguments-of-invoked-user-function">PageArgument</a> object of the custom Web page handler argument is a copy of the arg object of the ESP8266WebServer class. Either of these methods is a simple and easy way to access parameters in custom Web page handlers. However, if you need to access from outside of the handler to the value of AutoConnectElements, you need to accomplish it using with the <a href="#get-autoconnectelement-from-the-autoconnectaux">AutoConnectAux::getElement</a> function. The following sketch code replaces the above example with JSON and PageArgument, and its behaves is equivalent basically to the above sketch.</p>
  1194. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">const</span> <span style="color: #66d9ef">static</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">auxPage[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;raw(</span>
  1195. <span style="color: #e6db74">[</span>
  1196. <span style="color: #e6db74"> { &quot;title&quot;:&quot;Hello&quot;, &quot;uri&quot;:&quot;/hello&quot;, &quot;menu&quot;:true, &quot;element&quot;:[</span>
  1197. <span style="color: #e6db74"> { &quot;name&quot;:&quot;input1&quot;, &quot;type&quot;: &quot;ACInput&quot;, &quot;label&quot;: &quot;INPUT&quot; },</span>
  1198. <span style="color: #e6db74"> { &quot;name&quot;:&quot;send&quot;, &quot;type&quot;:&quot;ACSubmit&quot;, &quot;value&quot;:&quot;HELLO&quot;, &quot;uri&quot;:&quot;/echo&quot; }]</span>
  1199. <span style="color: #e6db74"> },</span>
  1200. <span style="color: #e6db74"> { &quot;title&quot;:&quot;Echo&quot;, &quot;uri&quot;:&quot;/echo&quot;, &quot;menu&quot;:false, &quot;element&quot;:[</span>
  1201. <span style="color: #e6db74"> { &quot;name&quot;:&quot;echo&quot;, &quot;type&quot;:&quot;ACText&quot; }]</span>
  1202. <span style="color: #e6db74"> }</span>
  1203. <span style="color: #e6db74">]</span>
  1204. <span style="color: #e6db74">)raw&quot;</span><span style="color: #f8f8f2">;</span>
  1205. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #f8f8f2">portal;</span>
  1206. <span style="color: #f8f8f2">portal.load(auxPage);</span>
  1207. <span style="color: #f8f8f2">portal.on(</span><span style="color: #e6db74">&quot;/echo&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">[](AutoConnectAux</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">aux,</span> <span style="color: #f8f8f2">PageArgument</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">args)</span> <span style="color: #f8f8f2">{</span>
  1208. <span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">ac_echo</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">aux.getElement</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectText</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;echo&quot;</span><span style="color: #f8f8f2">);</span>
  1209. <span style="color: #f8f8f2">ac_echo.value</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">args.arg(</span><span style="color: #e6db74">&quot;input1&quot;</span><span style="color: #f8f8f2">);</span>
  1210. <span style="color: #66d9ef">return</span> <span style="color: #a6e22e">String</span><span style="color: #f8f8f2">();</span>
  1211. <span style="color: #f8f8f2">});</span>
  1212. <span style="color: #f8f8f2">portal.begin();</span>
  1213. </code></pre></div>
  1214. <h3 id="transfer-of-input-values-across-pages"><i class="fa fa-wrench"></i> Transfer of input values ​​across pages<a class="headerlink" href="#transfer-of-input-values-across-pages" title="Permanent link">&para;</a></h3>
  1215. <p>Since v1.0.0, AutoConnect supports a new attribute with each element that allows automatic transfer of input values across pages without sketching. AutoConnect will copy the input value of the elements declared as <a href="apielements.html#global_2">global</a> to the same-named global elements on a different custom Web pages at the page transition timing.</p>
  1216. <p><img src="images/global.svg"> </p>
  1217. <p>The <strong>global</strong> attribute will be useful for echoing input values back to another custom Web pages. This copy operation can be performed between different types. (eg., copy value from AutoConnectInput to AutoConnectText) The following example reflects the input value of PAGE1 to the AutoConnectText field of PAGE2 without sketch code.</p>
  1218. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">static</span> <span style="color: #66d9ef">const</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">PAGE1[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;(</span>
  1219. <span style="color: #e6db74">{</span>
  1220. <span style="color: #e6db74"> &quot;title&quot;: &quot;PAGE1&quot;,</span>
  1221. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/page1&quot;,</span>
  1222. <span style="color: #e6db74"> &quot;menu&quot;: true,</span>
  1223. <span style="color: #e6db74"> &quot;element&quot;: [</span>
  1224. <span style="color: #e6db74"> {</span>
  1225. <span style="background-color: #49483e"><span style="color: #e6db74"> &quot;name&quot;: &quot;input1&quot;,</span>
  1226. </span><span style="color: #e6db74"> &quot;type&quot;: &quot;ACInput&quot;,</span>
  1227. <span style="background-color: #49483e"><span style="color: #e6db74"> &quot;global&quot;: true</span>
  1228. </span><span style="color: #e6db74"> },</span>
  1229. <span style="color: #e6db74"> {</span>
  1230. <span style="color: #e6db74"> &quot;name&quot;: &quot;send&quot;,</span>
  1231. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACSubmit&quot;,</span>
  1232. <span style="color: #e6db74"> &quot;value&quot;: &quot;OK&quot;,</span>
  1233. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/page2&quot;</span>
  1234. <span style="color: #e6db74"> }</span>
  1235. <span style="color: #e6db74"> ]</span>
  1236. <span style="color: #e6db74">}</span>
  1237. <span style="color: #e6db74">)&quot;</span><span style="color: #f8f8f2">;</span>
  1238. <span style="color: #66d9ef">static</span> <span style="color: #66d9ef">const</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">PAGE2[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;(</span>
  1239. <span style="color: #e6db74">{</span>
  1240. <span style="color: #e6db74"> &quot;title&quot;: &quot;PAGE2&quot;,</span>
  1241. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/page2&quot;,</span>
  1242. <span style="color: #e6db74"> &quot;menu&quot;: false,</span>
  1243. <span style="color: #e6db74"> &quot;element&quot;: [</span>
  1244. <span style="color: #e6db74"> {</span>
  1245. <span style="background-color: #49483e"><span style="color: #e6db74"> &quot;name&quot;: &quot;input1&quot;,</span>
  1246. </span><span style="color: #e6db74"> &quot;type&quot;: &quot;ACText&quot;,</span>
  1247. <span style="background-color: #49483e"><span style="color: #e6db74"> &quot;global&quot;: true</span>
  1248. </span><span style="color: #e6db74"> }</span>
  1249. <span style="color: #e6db74"> ]</span>
  1250. <span style="color: #e6db74">}</span>
  1251. <span style="color: #e6db74">)&quot;</span><span style="color: #f8f8f2">;</span>
  1252. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #f8f8f2">portal;</span>
  1253. <span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #f8f8f2">page1;</span>
  1254. <span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #f8f8f2">page2;</span>
  1255. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">setup</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1256. <span style="color: #f8f8f2">page1.load(PAGE1);</span>
  1257. <span style="color: #f8f8f2">page2.load(PAGE2);</span>
  1258. <span style="color: #f8f8f2">portal.join(</span> <span style="color: #f8f8f2">{</span> <span style="color: #f8f8f2">page1,</span> <span style="color: #f8f8f2">page2</span> <span style="color: #f8f8f2">});</span>
  1259. <span style="color: #f8f8f2">portal.begin();</span>
  1260. <span style="color: #f8f8f2">}</span>
  1261. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">loop</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1262. <span style="color: #f8f8f2">portal.handleClient();</span>
  1263. <span style="color: #f8f8f2">}</span>
  1264. </code></pre></div>
  1265. <p><i class="fa fa-arrow-down"></i><br><i class="fa fa-eye"></i> The value entered in <strong>input1 declared in PAGE1</strong> is reflected in <strong>input1 of PAGE2</strong> as an AutoConnectText value even if there is no sketch code to transfer it to PAGE2. It's shown as like:<br>
  1266. <span style="width:300px;height:159px"><img align="top" width="300" height="159" src="images/global1.png"></span>
  1267. <span style="margin-left:7px;"><img width="20" src="images/arrow_right.png"></span>
  1268. <span style="margin-left:7px;width:300px;height:159px"><img width="300" height="159" src="images/global2.png"></span></p>
  1269. <div class="admonition note">
  1270. <p class="admonition-title">Copy only for same-named and the global</p>
  1271. <p>The input value will be copied only if the global attribute of the destination element is true. If an element with the same name is declared non-global, the value is not copied.</p>
  1272. </div>
  1273. <h3 id="retrieve-the-values-with-webserveron-handler"><i class="fa fa-wrench"></i> Retrieve the values with WebServer::on handler<a class="headerlink" href="#retrieve-the-values-with-webserveron-handler" title="Permanent link">&para;</a></h3>
  1274. <p>ESP8266WebServer class and the WebServer class assume that the implementation of the ReqestHandler class contained in the WebServer library will handle the URL requests. Usually, it is sketch code registered by ESP8266WebServer::on function.</p>
  1275. <p>When a page transition from a custom Web page created by AutoConnectAux to a handler registered with ESP2866WebServer::on function, a little trick is needed to retrieve the values of AutoConnectElements. (i.e. the URI of the ESP8266WebServer::on handler is specified in the <a href="acelements.html#uri">uri</a> attribute of <a href="acelements.html#autoconnectsubmit">AutoConnectSubmit</a>) AutoConnect cannot intervene in the procedure in which the ESP8266WebServer class calls the on-page handler coded with the Sketch. Therefore, it is necessary to retrieve preliminary the values of AutoConnectElements using the <a href="apiaux.html#fetchelement">AutoConnectAux::fetchElement</a> function for value processing with the on-page handler.</p>
  1276. <p>The following sketch is an example of extracting values inputted on a custom web page with an on-page handler and then processing it.</p>
  1277. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">ESP8266WebServer</span> <span style="color: #f8f8f2">server;</span>
  1278. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #a6e22e">portal</span><span style="color: #f8f8f2">(server);</span>
  1279. <span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #f8f8f2">Input;</span>
  1280. <span style="color: #66d9ef">const</span> <span style="color: #66d9ef">static</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">InputPage[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;r(</span>
  1281. <span style="color: #e6db74">{</span>
  1282. <span style="color: #e6db74"> &quot;title&quot;: &quot;Input&quot;, &quot;uri&quot;: &quot;/input&quot;, &quot;menu&quot;: true, &quot;element&quot;: [</span>
  1283. <span style="color: #e6db74"> { &quot;name&quot;: &quot;input&quot;, &quot;type&quot;: &quot;ACInput&quot;, &quot;label&quot;: &quot;INPUT&quot; },</span>
  1284. <span style="color: #e6db74"> {</span>
  1285. <span style="color: #e6db74"> &quot;name&quot;: &quot;save&quot;,</span>
  1286. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACSubmit&quot;,</span>
  1287. <span style="color: #e6db74"> &quot;value&quot;: &quot;SAVE&quot;,</span>
  1288. <span style="background-color: #49483e"><span style="color: #e6db74"> &quot;uri&quot;: &quot;/&quot;</span>
  1289. </span><span style="color: #e6db74"> }</span>
  1290. <span style="color: #e6db74"> ]</span>
  1291. <span style="color: #e6db74">}</span>
  1292. <span style="color: #e6db74">)r&quot;</span><span style="color: #f8f8f2">;</span>
  1293. <span style="color: #75715e">// An on-page handler for &#39;/&#39; access</span>
  1294. <span style="background-color: #49483e"><span style="color: #66d9ef">void</span> <span style="color: #a6e22e">onRoot</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1295. </span> <span style="color: #f8f8f2">String</span> <span style="color: #f8f8f2">content</span> <span style="color: #f92672">=</span>
  1296. <span style="color: #e6db74">&quot;&lt;html&gt;&quot;</span>
  1297. <span style="color: #e6db74">&quot;&lt;head&gt;&lt;meta name=&#39;viewport&#39; content=&#39;width=device-width, initial-scale=1&#39;&gt;&lt;/head&gt;&quot;</span>
  1298. <span style="color: #e6db74">&quot;&lt;body&gt;&lt;div&gt;INPUT: {{value}}&lt;/div&gt;&lt;/body&gt;&quot;</span>
  1299. <span style="color: #e6db74">&quot;&lt;/html&gt;&quot;</span><span style="color: #f8f8f2">;</span>
  1300. <span style="background-color: #49483e"> <span style="color: #f8f8f2">Input.fetchElement();</span> <span style="color: #75715e">// Preliminary acquisition</span>
  1301. </span>
  1302. <span style="color: #75715e">// For this steps to work, need to call fetchElement function beforehand.</span>
  1303. <span style="color: #f8f8f2">String</span> <span style="color: #f8f8f2">value</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">Input[</span><span style="color: #e6db74">&quot;input&quot;</span><span style="color: #f8f8f2">].value;</span>
  1304. <span style="color: #f8f8f2">content.replace(</span><span style="color: #e6db74">&quot;{{value}}&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">value);</span>
  1305. <span style="color: #f8f8f2">server.send(</span><span style="color: #ae81ff">200</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;text/html&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">content);</span>
  1306. <span style="color: #f8f8f2">}</span>
  1307. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">setup</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1308. <span style="color: #f8f8f2">Input.load(InputPage);</span>
  1309. <span style="color: #f8f8f2">portal.join(Input);</span>
  1310. <span style="background-color: #49483e"> <span style="color: #f8f8f2">server.on(</span><span style="color: #e6db74">&quot;/&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">onRoot);</span> <span style="color: #75715e">// Register the on-page handler</span>
  1311. </span> <span style="color: #f8f8f2">portal.begin();</span>
  1312. <span style="color: #f8f8f2">}</span>
  1313. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">loop</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1314. <span style="color: #f8f8f2">portal.handleClient();</span>
  1315. <span style="color: #f8f8f2">}</span>
  1316. </code></pre></div>
  1317. <h3 id="overwrite-the-autoconnectelements"><i class="fa fa-edit"></i> Overwrite the AutoConnectElements<a class="headerlink" href="#overwrite-the-autoconnectelements" title="Permanent link">&para;</a></h3>
  1318. <p>Sketches can update the attributes of AutoConnectElements with two approaches. A one is to assign directly to the attributes of a member variable of its element. The other is to overwrite them with loading the element by <a href="apiaux.html#loadelement">AutoConnectAux::loadElement</a>. </p>
  1319. <p>The elements for attributes described in the JSON document for AutoConnectElements overwrites the member variables of the target AutoConnectElements. However, AutoConnectAux::loadElement keeps the member variables unchanged if there is no element in the JSON document. This overwriting behavior is the same for the <a href="api.html#load">AutoConnect::load</a> function.</p>
  1320. <p>For example, the combination of the Sketch and JSON document as follows updates only the style while keeping Caption (ie. "Hello, world") as AutoConnectText value.</p>
  1321. <p><i class="fab fa-js-square"></i> External JSON document for the below sketch to modify the text style.
  1322. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">{</span>
  1323. <span style="color: #f92672">&quot;name&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;Caption&quot;</span><span style="color: #f8f8f2">,</span>
  1324. <span style="color: #f92672">&quot;type&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACText&quot;</span><span style="color: #f8f8f2">,</span>
  1325. <span style="background-color: #49483e"> <span style="color: #f92672">&quot;style&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;text-align:center;font-size:24px;font-family:&#39;Impact&#39;,&#39;Futura&#39;,sans-serif;color:tomato;&quot;</span>
  1326. </span><span style="color: #f8f8f2">}</span>
  1327. </code></pre></div></p>
  1328. <p><i class="fa fa-arrow-down"></i><br>
  1329. <i class="fa fa-code"></i> the Sketch (a part of code), load above JSON.
  1330. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="background-color: #49483e"><span style="color: #f8f8f2">ACText(Caption,</span> <span style="color: #e6db74">&quot;Hello, world&quot;</span><span style="color: #f8f8f2">);</span>
  1331. </span><span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #a6e22e">helloPage</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&quot;/hello&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;Hello&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">true,</span> <span style="color: #f8f8f2">{</span> <span style="color: #f8f8f2">Caption</span> <span style="color: #f8f8f2">});</span>
  1332. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #f8f8f2">portal;</span>
  1333. <span style="color: #f8f8f2">String</span> <span style="color: #a6e22e">onHello</span><span style="color: #f8f8f2">(AutoConnectAux</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">aux,</span> <span style="color: #f8f8f2">PageArgument</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">args)</span> <span style="color: #f8f8f2">{</span>
  1334. <span style="color: #f8f8f2">aux.loadElement(JSON);</span>
  1335. <span style="color: #66d9ef">return</span> <span style="color: #f8f8f2">String();</span>
  1336. <span style="color: #f8f8f2">}</span>
  1337. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">setup</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1338. <span style="color: #f8f8f2">helloPage.on(onHello);</span>
  1339. <span style="color: #f8f8f2">portal.join(helloPage);</span>
  1340. <span style="color: #f8f8f2">portal.begin();</span>
  1341. <span style="color: #f8f8f2">}</span>
  1342. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">loop</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1343. <span style="color: #f8f8f2">portal.handleClient();</span>
  1344. <span style="color: #f8f8f2">}</span>
  1345. </code></pre></div>
  1346. <i class="fa fa-arrow-down"></i><br>
  1347. <i class="fa fa-eye"></i> It's shown as like:<span style="margin-left:14px;width:272px;height:118px;border:1px solid lightgray;"><img align="top" width="270" height="116" src="images/acow.png"></span></p>
  1348. <h3 id="check-data-against-on-submission"><i class="far fa-check-square"></i> Check data against on submission<a class="headerlink" href="#check-data-against-on-submission" title="Permanent link">&para;</a></h3>
  1349. <p>By giving a <a href="apielements.html#pattern">pattern</a> to <a href="apielements.html#autoconnectinput">AutoConnectInput</a>, you can find errors in data styles while typing in custom Web pages. The pattern is specified with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">regular expression</a>.<sup id="fnref:2"><a class="footnote-ref" href="#fn:2">2</a></sup> If the value during input of AutoConnectInput does not match the regular expression specified in the pattern, its background color changes to pink. The following example shows the behavior when checking the IP address in the AutoConnectInput field.</p>
  1350. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">{</span>
  1351. <span style="color: #f92672">&quot;title&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;Page-1&quot;</span><span style="color: #f8f8f2">,</span>
  1352. <span style="color: #f92672">&quot;uri&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;/page1&quot;</span><span style="color: #f8f8f2">,</span>
  1353. <span style="color: #f92672">&quot;menu&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #66d9ef">true</span><span style="color: #f8f8f2">,</span>
  1354. <span style="color: #f92672">&quot;element&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #f8f8f2">[</span>
  1355. <span style="color: #f8f8f2">{</span>
  1356. <span style="color: #f92672">&quot;name&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;Server&quot;</span><span style="color: #f8f8f2">,</span>
  1357. <span style="color: #f92672">&quot;type&quot;</span> <span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACInput&quot;</span><span style="color: #f8f8f2">,</span>
  1358. <span style="color: #f92672">&quot;label&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;Server address&quot;</span><span style="color: #f8f8f2">,</span>
  1359. <span style="background-color: #49483e"> <span style="color: #f92672">&quot;pattern&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$&quot;</span>
  1360. </span> <span style="color: #f8f8f2">}</span>
  1361. <span style="color: #f8f8f2">]</span>
  1362. <span style="color: #f8f8f2">}</span>
  1363. </code></pre></div>
  1364. <p><i class="fa fa-arrow-down"></i><br><i class="fa fa-eye"></i> It's shown as like:<br>
  1365. <span style="display:block;width:306px;height:136px;border:1px solid lightgrey;"><img data-gifffer="images/aux_pattern.gif" data-gifffer-height="134" data-gifffer-width="304" /></span></p>
  1366. <p>If you are not familiar with regular expressions, you may feel that description very strange. Matter of fact, it's a strange description for those who are unfamiliar with the formal languages. If your regular expression can not interpret the intended syntax and semantics, you can use an online tester. The <a href="https://regex101.com/">regex101</a> is an exceptional online tool for testing and debugging regular expressions.</p>
  1367. <h3 id="input-data-validation"><img src="images/regexp.png" align="top"> Input data validation<a class="headerlink" href="#input-data-validation" title="Permanent link">&para;</a></h3>
  1368. <p>The <a href="apielements.html#pattern">pattern</a> attribute of <a href="apielements.html#autoconnectinput">AutoConnectInput</a> only determines the data consistency on the web browser based on the given regular expression. In order to guarantee the validity of input data, it is necessary to verify it before actually using it.</p>
  1369. <p>You can validate input data from <a href="apielements.html#autoconnectinput">AutoConnectInput</a> using the <a href="apielements.html#isvalid">isValid</a> function before actually processing it. The <a href="apielements.html#isvalid">isValid</a> function determines whether the <a href="apielements.html#value_3">value</a> currently stored in <a href="apielements.html#autoconnectinput">AutoConnectInput</a> matches the <a href="apielements.html#pattern">pattern</a>.</p>
  1370. <p>You can also use the <a href="apiaux.html#isvalid">AutoConnectAux::isValid</a> function to verify the data input to all <a href="apielements.html#autoconnectinput">AutoConnectInput</a> elements on the custom Web page at once. The two sketches below show the difference between using <a href="apielements.html#isvalid">AutoConnectInput::isValid</a> and using <a href="apiaux.html#isvalid">AutoConnectAux::isValid</a>. In both cases, it verifies the input data of the same AutoConnectInput, but in the case of using AutoConnectAux::isValid, the amount of sketch coding is small.</p>
  1371. <p><strong>A common declaration</strong></p>
  1372. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">const</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">PAGE[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;(</span>
  1373. <span style="color: #e6db74">{</span>
  1374. <span style="color: #e6db74"> &quot;title&quot;: &quot;Custom page&quot;,</span>
  1375. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/page&quot;,</span>
  1376. <span style="color: #e6db74"> &quot;menu&quot;: true,</span>
  1377. <span style="color: #e6db74"> &quot;element&quot;: [</span>
  1378. <span style="color: #e6db74"> {</span>
  1379. <span style="color: #e6db74"> &quot;name&quot;: &quot;input1&quot;,</span>
  1380. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACInput&quot;,</span>
  1381. <span style="color: #e6db74"> &quot;pattern&quot;: &quot;^[0-9]{4}$&quot;</span>
  1382. <span style="color: #e6db74"> },</span>
  1383. <span style="color: #e6db74"> {</span>
  1384. <span style="color: #e6db74"> &quot;name&quot;: &quot;input2&quot;,</span>
  1385. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACInput&quot;,</span>
  1386. <span style="color: #e6db74"> &quot;pattern&quot;: &quot;^[a-zA-Z]{4}$&quot;</span>
  1387. <span style="color: #e6db74"> }</span>
  1388. <span style="color: #e6db74"> ]</span>
  1389. <span style="color: #e6db74">}</span>
  1390. <span style="color: #e6db74">)&quot;</span><span style="color: #f8f8f2">;</span>
  1391. <span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #f8f8f2">page;</span>
  1392. <span style="color: #f8f8f2">page.load(PAGE);</span>
  1393. </code></pre></div>
  1394. <p><strong>Using AutoConnectInput::isValid</strong></p>
  1395. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">input1</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">page[</span><span style="color: #e6db74">&quot;input1&quot;</span><span style="color: #f8f8f2">].as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">();</span>
  1396. <span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&amp;</span> <span style="color: #f8f8f2">input2</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">page[</span><span style="color: #e6db74">&quot;input2&quot;</span><span style="color: #f8f8f2">].as</span><span style="color: #f92672">&lt;</span><span style="color: #f8f8f2">AutoConnectInput</span><span style="color: #f92672">&gt;</span><span style="color: #f8f8f2">();</span>
  1397. <span style="color: #66d9ef">if</span> <span style="color: #f8f8f2">(</span><span style="color: #f92672">!</span><span style="color: #f8f8f2">input1.isValid()</span> <span style="color: #f92672">||</span> <span style="color: #f92672">!</span><span style="color: #f8f8f2">input2.isValid())</span>
  1398. <span style="color: #f8f8f2">Serial.println(</span><span style="color: #e6db74">&quot;Validation error&quot;</span><span style="color: #f8f8f2">);</span>
  1399. </code></pre></div>
  1400. <p><strong>Using AutoConnectAux::isValid</strong></p>
  1401. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">if</span> <span style="color: #f8f8f2">(</span><span style="color: #f92672">!</span><span style="color: #f8f8f2">page.isValid())</span>
  1402. <span style="color: #f8f8f2">Serial.println(</span><span style="color: #e6db74">&quot;Validation error&quot;</span><span style="color: #f8f8f2">);</span>
  1403. </code></pre></div>
  1404. <h3 id="convert-data-to-actually-type"><i class="fas fa-exchange-alt"></i> Convert data to actually type<a class="headerlink" href="#convert-data-to-actually-type" title="Permanent link">&para;</a></h3>
  1405. <p>The values in the AutoConnectElements field of the custom Web page are all typed as String. A sketch needs to be converted to an actual data type if the data type required for sketch processing is not a String type. For the typical data type conversion method, refer to section <a href="datatips.html#convert-autoconnectelements-value-to-actual-data-type"><em>Tips for data conversion</em></a>.</p>
  1406. <h2 id="place-html-elements-undefined-in-autoconnectelements">Place HTML elements undefined in AutoConnectElements<a class="headerlink" href="#place-html-elements-undefined-in-autoconnectelements" title="Permanent link">&para;</a></h2>
  1407. <p>Of the many HTML elements for markup, AutoConnet can only support a limited number. If you are designing a custom web page and the elements you want are not in AutoConnectElements, consider using an AutoConnectElement. <a href="acelements.html#autoconnectelement-a-basic-class-of-elements">AutoConnectElement</a> can be applied in many cases when trying to place HTML tag elements that are undefined in AutoConnectElemets on custom web pages.</p>
  1408. <div class="admonition warning">
  1409. <p class="admonition-title">Not all of them work</p>
  1410. <p>The strongest constraint is the heap size required to generate HTML for the entire custom Web page. AutoConnect creates a custom web page as a chunk of String. It's not a stream. Therefore, it may not be possible to generate long HTML pages. See also <a href="faq.html#some-autoconnect-page-is-cut-off">FAQ</a>.</p>
  1411. </div>
  1412. <h3 id="place-a-markup-or-a-styled-html-tag"><i class="far fa-file-code"></i> Place a markup or a styled HTML tag<a class="headerlink" href="#place-a-markup-or-a-styled-html-tag" title="Permanent link">&para;</a></h3>
  1413. <p>If the HTML element you want to place is just the tag that makes up the appearance of the web page, assign the tag element directly to the <a href="apielements.html#value_2">value</a> member of AutoConnectElement. If the tag you are trying to place is for static markup effects, just write the <code>value</code> as follows:</p>
  1414. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">{</span>
  1415. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;headline&quot;</span><span style="color: #f8f8f2">,</span>
  1416. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACElement&quot;</span><span style="color: #f8f8f2">,</span>
  1417. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;&lt;hr style=&#39;height:1px;border-width:0;color:gray;background-color:#52a6ed&#39;&gt;&quot;</span>
  1418. <span style="color: #f8f8f2">}</span>
  1419. </code></pre></div>
  1420. <p>If the element has a hierarchy like a <code>&lt;table&gt; ~ &lt;/table&gt;</code>, describe the entire element in the <code>value</code>:</p>
  1421. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">{</span>
  1422. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;table&quot;</span><span style="color: #f8f8f2">,</span>
  1423. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACElement&quot;</span><span style="color: #f8f8f2">,</span>
  1424. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;&lt;table&gt;&lt;tr&gt;&lt;th&gt;Board&lt;/th&gt;&lt;th&gt;Platform&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NodeMCU&lt;/td&gt;&lt;td&gt;Espressif8266&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ESP32-DevKitC&lt;/td&gt;&lt;td&gt;Espressif32&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</span>
  1425. <span style="color: #f8f8f2">}</span>
  1426. </code></pre></div>
  1427. <p>Also, using <a href="acelements.html#autoconnectstyle">AutoConnectStyle</a> combined, you can give the style effect of only that element.</p>
  1428. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">{</span>
  1429. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;tablestyle&quot;</span><span style="color: #f8f8f2">,</span>
  1430. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACStyle&quot;</span><span style="color: #f8f8f2">,</span>
  1431. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;table.style{font-family:arial,sans-serif;border-collapse:collapse;width:100%;color:black;}table.style td,table.style th{border:1px solid #dddddd;text-align:center;padding:8px;}table.style tr:nth-child(even){background-color:#dddddd;}&quot;</span>
  1432. <span style="color: #f8f8f2">}</span><span style="color: #960050; background-color: #1e0010">,</span>
  1433. <span style="color: #f8f8f2">{</span>
  1434. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;table&quot;</span><span style="color: #f8f8f2">,</span>
  1435. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACElement&quot;</span><span style="color: #f8f8f2">,</span>
  1436. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;&lt;table class=&#39;style&#39;&gt;&lt;tr&gt;&lt;th&gt;Board&lt;/th&gt;&lt;th&gt;Platform&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NodeMCU&lt;/td&gt;&lt;td&gt;Espressif8266&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ESP32-DevKitC&lt;/td&gt;&lt;td&gt;Espressif32&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</span>
  1437. <span style="color: #f8f8f2">}</span>
  1438. </code></pre></div>
  1439. <p><i class="fa fa-arrow-down"></i><br>
  1440. <i class="fa fa-eye"></i> As you see it:
  1441. <br />
  1442. <table class="achandling">
  1443. <tr>
  1444. <th>Board</th>
  1445. <th>Platform</th>
  1446. </tr>
  1447. <tr>
  1448. <td>NodeMCU</td>
  1449. <td>Espressif8266</td>
  1450. </tr>
  1451. <tr>
  1452. <td>ESP32-DevKitC</td>
  1453. <td>Espressif32</td>
  1454. </tr>
  1455. </table>
  1456. </p>
  1457. <h3 id="place-the-input-elements-within-a-form"><i class="far fa-file-code"></i> Place the input elements within a form<a class="headerlink" href="#place-the-input-elements-within-a-form" title="Permanent link">&para;</a></h3>
  1458. <p>There is still no dedicated AutoConnectElement for entering other than equivalent to <code>checkbox</code>, <code>file</code>, <code>number</code>, <code>password</code>, <code>radio</code> and <code>text</code> for <code>&lt;input type="..."&gt;</code> HTML element. But you can substitute them with the AutoConnectElement.</p>
  1459. <p>For example, if you use the <code>&lt;input&gt;</code> element of <code>type="date"</code> to place a field where you can enter a date, the AutoConnectElement would look like this:</p>
  1460. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">{</span>
  1461. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;date&quot;</span><span style="color: #f8f8f2">,</span>
  1462. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACElement&quot;</span><span style="color: #f8f8f2">,</span>
  1463. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;&lt;label for=&#39;picker&#39;&gt;Date:&lt;/label&gt;&lt;input type=&#39;date&#39; id=&#39;picker&#39; name=&#39;date&#39;&gt;&quot;</span>
  1464. <span style="color: #f8f8f2">}</span>
  1465. </code></pre></div>
  1466. <p>And it becomes a textbox that validates the input or a special date picker interface.<br />
  1467. Then, instead of accessing that AutoConnectElement directly, obtains entered date value from the POST body included in the HTTP request from the hosted ESP8266WebServer class. Its process carries out with the <a href="achandling.html#how-you-can-reach-the-values">AutoConnectAux page handler</a> following:</p>
  1468. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">String</span> <span style="color: #a6e22e">aux_page_handler</span><span style="color: #f8f8f2">(AutoConnectAux</span> <span style="color: #f92672">&amp;</span><span style="color: #f8f8f2">aux,</span> <span style="color: #f8f8f2">PageArgument</span> <span style="color: #f92672">&amp;</span><span style="color: #f8f8f2">arg)</span> <span style="color: #f8f8f2">{</span>
  1469. <span style="color: #f8f8f2">Serial.println(arg.arg(</span><span style="color: #e6db74">&quot;date&quot;</span><span style="color: #f8f8f2">));</span> <span style="color: #75715e">// Obtain a date value entered</span>
  1470. <span style="color: #66d9ef">return</span> <span style="color: #e6db74">&quot;&quot;</span><span style="color: #f8f8f2">;</span>
  1471. <span style="color: #f8f8f2">}</span>
  1472. </code></pre></div>
  1473. <p>AutoConnect passes a <a href="https://github.com/Hieromon/PageBuilder#arguments-of-invoked-user-function">PageArgument</a> to the AutoConnectAux page handler. The handler can use the <a href="https://github.com/Hieromon/PageBuilder#string-pageargumentargstring-name">PageArgument::arg</a> function to get the parameters contained in the HTTP request for the page.
  1474. Also, the equivalent can also be implemented using <a href="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#getting-information-about-request-arguments">ESP8266WebServer::arg</a> function with the <a href="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#client-request-handlers">ESP8266WebServer client request handler</a>.</p>
  1475. <h3 id="using-javascript"><i class="fab fa-js-square"></i> Using JavaScript<a class="headerlink" href="#using-javascript" title="Permanent link">&para;</a></h3>
  1476. <p>What is described in this section belongs to the tips of what effectiveness a web page can have using AutoConnectElement, rather than the correct usage for AutoConnect.<br />
  1477. You can use AutoConnectElement to embed JavaScript into the custom Web page as with HTML elements for markup. The reason for embedding JavaScript on a page depends on your requirements, but One of the most common requirements is the need to access elements of a web page. You can implement the requirements by having the AutoConnectElement have JavaScript that contains DOM access.</p>
  1478. <p>The following screenshot shows an example of accessing AutoConnectText via the DOM using an AutoConnectElement with JavaScript. This web page is a very simple example and returns the result of multiplying the multiplier entered in an AutoConnectInput field.</p>
  1479. <p><img src="images/jsmultiply.png"></p>
  1480. <p>This custom Web page is generated from the following JSON document:</p>
  1481. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">{</span>
  1482. <span style="color: #f92672">&quot;uri&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;/jselement&quot;</span><span style="color: #f8f8f2">,</span>
  1483. <span style="color: #f92672">&quot;title&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;Multiply&quot;</span><span style="color: #f8f8f2">,</span>
  1484. <span style="color: #f92672">&quot;menu&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #66d9ef">true</span><span style="color: #f8f8f2">,</span>
  1485. <span style="color: #f92672">&quot;element&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #f8f8f2">[</span>
  1486. <span style="color: #f8f8f2">{</span>
  1487. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;multiplier&quot;</span><span style="color: #f8f8f2">,</span>
  1488. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACInput&quot;</span><span style="color: #f8f8f2">,</span>
  1489. <span style="color: #f92672">&quot;label&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;3 &amp;times; &quot;</span><span style="color: #f8f8f2">,</span>
  1490. <span style="color: #f92672">&quot;apply&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;number&quot;</span><span style="color: #f8f8f2">,</span>
  1491. <span style="color: #f92672">&quot;posterior&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;none&quot;</span>
  1492. <span style="color: #f8f8f2">},</span>
  1493. <span style="color: #f8f8f2">{</span>
  1494. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;op&quot;</span><span style="color: #f8f8f2">,</span>
  1495. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACButton&quot;</span><span style="color: #f8f8f2">,</span>
  1496. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot; = &quot;</span><span style="color: #f8f8f2">,</span>
  1497. <span style="color: #f92672">&quot;action&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;multi()&quot;</span><span style="color: #f8f8f2">,</span>
  1498. <span style="color: #f92672">&quot;posterior&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;none&quot;</span>
  1499. <span style="color: #f8f8f2">},</span>
  1500. <span style="color: #f8f8f2">{</span>
  1501. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;answer&quot;</span><span style="color: #f8f8f2">,</span>
  1502. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACText&quot;</span>
  1503. <span style="color: #f8f8f2">},</span>
  1504. <span style="color: #f8f8f2">{</span>
  1505. <span style="color: #f92672">&quot;name&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;js&quot;</span><span style="color: #f8f8f2">,</span>
  1506. <span style="color: #f92672">&quot;type&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;ACElement&quot;</span><span style="color: #f8f8f2">,</span>
  1507. <span style="color: #f92672">&quot;value&quot;</span><span style="color: #f8f8f2">:</span> <span style="color: #e6db74">&quot;&lt;script type=&#39;text/javascript&#39;&gt;function multi() {document.getElementById(&#39;answer&#39;).innerHTML=3*document.getElementById(&#39;multiplier&#39;).value;}&lt;/script&gt;&quot;</span>
  1508. <span style="color: #f8f8f2">}</span>
  1509. <span style="color: #f8f8f2">]</span>
  1510. <span style="color: #f8f8f2">}</span>
  1511. </code></pre></div>
  1512. <p>An input field for a <code>multiplier</code> is defined by AutoConnectInput. The field for displaying the results exists with the name <code>answer</code>. The multiplication function is what AutoConnectElement has as JavaScript and it has the following content:</p>
  1513. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">function</span> <span style="color: #a6e22e">multi</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1514. <span style="color: #f8f8f2">document.</span><span style="color: #a6e22e">getElementById</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;answer&#39;</span><span style="color: #f8f8f2">).</span><span style="color: #a6e22e">innerHTML</span> <span style="color: #f92672">=</span> <span style="color: #ae81ff">3</span> <span style="color: #f92672">*</span> <span style="color: #f8f8f2">document.</span><span style="color: #a6e22e">getElementById</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;multiplier&#39;</span><span style="color: #f8f8f2">).</span><span style="color: #a6e22e">value</span><span style="color: #f8f8f2">;</span>
  1515. <span style="color: #f8f8f2">}</span>
  1516. </code></pre></div>
  1517. <p>And the action for calling the <code>multi()</code> function is the <code>=</code> labeled button as the AutoConnectButton element. AutoConnect generates the <a href="acjson.html#name"><strong>name</strong></a> attribute of each AutoConnectElement as the <strong>Id</strong> of the HTML tag. The Id should be useful for DOM access.</p>
  1518. <div class="admonition warning">
  1519. <p class="admonition-title">JavaScript that is too long can cause insufficient memory</p>
  1520. <p>If it reaches thousands of bytes, AutoConnect will not be able to complete the HTML generation for the page.</p>
  1521. </div>
  1522. <h3 id="communicate-with-the-sketch-using-xhr"><i class="fas fa-globe"></i> Communicate with the Sketch using XHR<a class="headerlink" href="#communicate-with-the-sketch-using-xhr" title="Permanent link">&para;</a></h3>
  1523. <p>AutoConnectElement allows having scripts that create sessions based on <a href="https://developer.mozilla.org/en-US/docs/Glossary/XHR_(XMLHttpRequest)"><strong>XHR</strong></a>. XMLHttpRequest (XHR) is a JavaScript API to create AJAX requests. Its methods provide the ability to send network requests between the browser and a server. The Sketch simply implements the server-side process as a response handler to a normal HTTP request and can equip with a dynamic custom Web page. This technique is tricky but does not cause page transitions and is useful for implementing dynamic pages. As a matter of fact, <a href="otabrowser.html#updates-with-the-web-browserupdated-wv115">AutoConnectOTA</a> class is implemented by using this technique and is a custom Web page by AutoConnectAux.</p>
  1524. <p>Here's a simple example of JavaScript-based on XHR and a server-side request handler. It's like a clock that displays the time in real-time on an AutoConnect custom web page. The sketch in the following example is roughly divided into two structures.<br />
  1525. The AutoConnectElement defined with the name <code>js</code> gets the server time with XHR and updates the response via the DOM with the AutoConnectText named <code>time</code> and substance is the following JavaScript:</p>
  1526. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">var</span> <span style="color: #a6e22e">xhr</span><span style="color: #f8f8f2">;</span>
  1527. <span style="color: #66d9ef">function</span> <span style="color: #a6e22e">clock</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1528. <span style="color: #a6e22e">xhr</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">open</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;GET&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&#39;/clock&#39;</span><span style="color: #f8f8f2">);</span>
  1529. <span style="color: #a6e22e">xhr</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">responseType</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">&#39;text&#39;</span><span style="color: #f8f8f2">;</span>
  1530. <span style="color: #a6e22e">xhr</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">send</span><span style="color: #f8f8f2">();</span>
  1531. <span style="color: #f8f8f2">}</span>
  1532. <span style="color: #f8f8f2">window.</span><span style="color: #a6e22e">onclose</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">function</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1533. <span style="color: #a6e22e">xhr</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">abort</span><span style="color: #f8f8f2">();</span>
  1534. <span style="color: #f8f8f2">};</span>
  1535. <span style="color: #f8f8f2">window.</span><span style="color: #a6e22e">onload</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">function</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1536. <span style="color: #a6e22e">xhr</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">XMLHttpRequest</span><span style="color: #f8f8f2">();</span>
  1537. <span style="color: #a6e22e">xhr</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">onreadystatechange</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">function</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1538. <span style="color: #66d9ef">if</span> <span style="color: #f8f8f2">(</span><span style="color: #66d9ef">this</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">readyState</span> <span style="color: #f92672">==</span> <span style="color: #ae81ff">4</span> <span style="color: #f92672">&amp;&amp;</span> <span style="color: #a6e22e">xhr</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">status</span> <span style="color: #f92672">==</span> <span style="color: #ae81ff">200</span><span style="color: #f8f8f2">)</span> <span style="color: #f8f8f2">{</span>
  1539. <span style="color: #f8f8f2">document.</span><span style="color: #a6e22e">getElementById</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;time&#39;</span><span style="color: #f8f8f2">).</span><span style="color: #a6e22e">innerHTML</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">this</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">responseText</span><span style="color: #f8f8f2">;</span>
  1540. <span style="color: #f8f8f2">}</span>
  1541. <span style="color: #f8f8f2">};</span>
  1542. <span style="color: #a6e22e">setInterval</span><span style="color: #f8f8f2">(</span><span style="color: #a6e22e">clock</span><span style="color: #f8f8f2">,</span> <span style="color: #ae81ff">1000</span><span style="color: #f8f8f2">);</span>
  1543. <span style="color: #f8f8f2">};</span>
  1544. </code></pre></div>
  1545. <p>This script issues a GET request to <code>/clock</code> every second and updates the element of Id=<code>time</code> with the text content of its response. As this script shows, it will issue a send request using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest">XMLHttpRequest</a> object.</p>
  1546. <p>The other component is located on the AutoConnect-hosted ESP8266WebServer server. This component gets the current time from the NTP server and sends the value as text to the client.</p>
  1547. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #66d9ef">void</span> <span style="color: #a6e22e">auxClock</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1548. <span style="color: #66d9ef">time_t</span> <span style="color: #f8f8f2">t;</span>
  1549. <span style="color: #66d9ef">struct</span> <span style="color: #a6e22e">tm</span> <span style="color: #f92672">*</span><span style="color: #f8f8f2">tm;</span>
  1550. <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">dateTime[</span><span style="color: #ae81ff">24</span><span style="color: #f8f8f2">];</span>
  1551. <span style="color: #f8f8f2">t</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">time(NULL);</span>
  1552. <span style="color: #f8f8f2">tm</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">localtime(</span><span style="color: #f92672">&amp;</span><span style="color: #f8f8f2">t);</span>
  1553. <span style="color: #f8f8f2">sprintf(dateTime,</span> <span style="color: #e6db74">&quot;%04d/%02d/%02d %02d:%02d:%02d.&quot;</span><span style="color: #f8f8f2">,</span>
  1554. <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_year</span> <span style="color: #f92672">+</span> <span style="color: #ae81ff">1900</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_mon</span> <span style="color: #f92672">+</span> <span style="color: #ae81ff">1</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_mday,</span>
  1555. <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_hour,</span> <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_min,</span> <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_sec);</span>
  1556. <span style="color: #f8f8f2">server.send(</span><span style="color: #ae81ff">200</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;text/plain&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">dateTime);</span>
  1557. <span style="color: #f8f8f2">}</span>
  1558. </code></pre></div>
  1559. <p>Then just register the <code>auxClock</code> function as a <code>/clock</code> URL handler with the hosted ESP8266Server instance.</p>
  1560. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #f8f8f2">server.on(</span><span style="color: #e6db74">&quot;/clock&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">auxClock);</span>
  1561. </code></pre></div>
  1562. <p>As you can see from the above two components, AutoConnect does not intervene in those communications and no page transitions occur. A complete sketch that integrates the above components and includes a custom Web page declaration for time display looks like this:</p>
  1563. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;Arduino.h&gt;</span>
  1564. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;ESP8266WiFi.h&gt;</span>
  1565. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;ESP8266WebServer.h&gt;</span>
  1566. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;AutoConnect.h&gt;</span>
  1567. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;time.h&gt;</span>
  1568. <span style="color: #66d9ef">static</span> <span style="color: #66d9ef">const</span> <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">JSPAGE[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;&#39;(</span>
  1569. <span style="color: #e6db74">{</span>
  1570. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/jselement&quot;,</span>
  1571. <span style="color: #e6db74"> &quot;title&quot;: &quot;Clock&quot;,</span>
  1572. <span style="color: #e6db74"> &quot;menu&quot;: true,</span>
  1573. <span style="color: #e6db74"> &quot;element&quot;: [</span>
  1574. <span style="color: #e6db74"> {</span>
  1575. <span style="color: #e6db74"> &quot;name&quot;: &quot;time&quot;,</span>
  1576. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACText&quot;</span>
  1577. <span style="color: #e6db74"> },</span>
  1578. <span style="color: #e6db74"> {</span>
  1579. <span style="color: #e6db74"> &quot;name&quot;: &quot;js&quot;,</span>
  1580. <span style="color: #e6db74"> &quot;type&quot;: &quot;ACElement&quot;,</span>
  1581. <span style="color: #e6db74"> &quot;value&quot;: &quot;&lt;script type=&#39;text/javascript&#39;&gt;var xhr;function clock(){xhr.open(&#39;GET&#39;, &#39;/clock&#39;);xhr.responseType=&#39;text&#39;;xhr.send();}window.onclose=function(){xhr.abort();};window.onload=function(){xhr=new XMLHttpRequest();xhr.onreadystatechange=function(){if(this.readyState==4&amp;&amp;xhr.status==200){document.getElementById(&#39;time&#39;).innerHTML=this.responseText;}};setInterval(clock,1000);};&lt;/script&gt;&quot;</span>
  1582. <span style="color: #e6db74"> }</span>
  1583. <span style="color: #e6db74"> ]</span>
  1584. <span style="color: #e6db74">} </span>
  1585. <span style="color: #e6db74">)&#39;&quot;</span><span style="color: #f8f8f2">;</span>
  1586. <span style="color: #f8f8f2">ESP8266WebServer</span> <span style="color: #f8f8f2">server;</span>
  1587. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #a6e22e">portal</span><span style="color: #f8f8f2">(server);</span>
  1588. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">auxClock</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1589. <span style="color: #66d9ef">time_t</span> <span style="color: #f8f8f2">t;</span>
  1590. <span style="color: #66d9ef">struct</span> <span style="color: #a6e22e">tm</span> <span style="color: #f92672">*</span><span style="color: #f8f8f2">tm;</span>
  1591. <span style="color: #66d9ef">char</span> <span style="color: #f8f8f2">dateTime[</span><span style="color: #ae81ff">24</span><span style="color: #f8f8f2">];</span>
  1592. <span style="color: #f8f8f2">t</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">time(NULL);</span>
  1593. <span style="color: #f8f8f2">tm</span> <span style="color: #f92672">=</span> <span style="color: #f8f8f2">localtime(</span><span style="color: #f92672">&amp;</span><span style="color: #f8f8f2">t);</span>
  1594. <span style="color: #f8f8f2">sprintf(dateTime,</span> <span style="color: #e6db74">&quot;%04d/%02d/%02d %02d:%02d:%02d.&quot;</span><span style="color: #f8f8f2">,</span>
  1595. <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_year</span> <span style="color: #f92672">+</span> <span style="color: #ae81ff">1900</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_mon</span> <span style="color: #f92672">+</span> <span style="color: #ae81ff">1</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_mday,</span>
  1596. <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_hour,</span> <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_min,</span> <span style="color: #f8f8f2">tm</span><span style="color: #f92672">-&gt;</span><span style="color: #f8f8f2">tm_sec);</span>
  1597. <span style="color: #f8f8f2">server.send(</span><span style="color: #ae81ff">200</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;text/plain&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">dateTime);</span>
  1598. <span style="color: #f8f8f2">}</span>
  1599. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">setup</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1600. <span style="color: #f8f8f2">delay(</span><span style="color: #ae81ff">1000</span><span style="color: #f8f8f2">);</span>
  1601. <span style="color: #f8f8f2">portal.load(FPSTR(JSPAGE));</span>
  1602. <span style="color: #66d9ef">if</span> <span style="color: #f8f8f2">(portal.begin())</span> <span style="color: #f8f8f2">{</span>
  1603. <span style="color: #f8f8f2">server.on(</span><span style="color: #e6db74">&quot;/clock&quot;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">auxClock);</span>
  1604. <span style="color: #f8f8f2">configTime(</span><span style="color: #ae81ff">0</span><span style="color: #f8f8f2">,</span> <span style="color: #ae81ff">0</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&quot;europe.pool.ntp.org&quot;</span><span style="color: #f8f8f2">);</span>
  1605. <span style="color: #f8f8f2">}</span>
  1606. <span style="color: #f8f8f2">}</span>
  1607. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">loop</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1608. <span style="color: #f8f8f2">portal.handleClient();</span>
  1609. <span style="color: #f8f8f2">}</span>
  1610. </code></pre></div>
  1611. <h2 id="transitions-of-the-custom-web-pages">Transitions of the custom Web pages<a class="headerlink" href="#transitions-of-the-custom-web-pages" title="Permanent link">&para;</a></h2>
  1612. <h3 id="scope-lifetime-of-autoconnectaux">Scope &amp; Lifetime of AutoConnectAux<a class="headerlink" href="#scope-lifetime-of-autoconnectaux" title="Permanent link">&para;</a></h3>
  1613. <p>AutoConnectAux and AutoConnectElements must live while the custom Web pages are available. The implementation of the custom Web page inherits from requestHandler driven from ESP8266WebServer (WebServer for ESP32), so the instance of AutoConnectAux and AutoConnectElements must exist for the duration of effect of handleClient. The following example is incorrect for manipulating custom Web pages. Its AutoConnectAux instance will be destructed at the exit of the setup().</p>
  1614. <div class="highlight" style="background: #272822"><pre style="line-height: 125%; margin: 0;"><span></span><code><span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;ESP8266WiFi.h&gt;</span>
  1615. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;ESP8266WebServer.h&gt;</span>
  1616. <span style="color: #75715e">#include</span> <span style="color: #75715e">&lt;AutoConnect.h&gt;</span>
  1617. <span style="color: #66d9ef">static</span> <span style="color: #66d9ef">const</span> <span style="color: #f8f8f2">auxPage[]</span> <span style="color: #f8f8f2">PROGMEM</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">R&quot;raw(</span>
  1618. <span style="color: #e6db74">{</span>
  1619. <span style="color: #e6db74"> &quot;title&quot;: &quot;Page-1&quot;,</span>
  1620. <span style="color: #e6db74"> &quot;uri&quot;: &quot;/page1&quot;,</span>
  1621. <span style="color: #e6db74"> &quot;menu&quot;: true,</span>
  1622. <span style="color: #e6db74"> &quot;element&quot;: [</span>
  1623. <span style="color: #e6db74"> { &quot;name&quot;:&quot;Server&quot;, &quot;type&quot;:&quot;ACText&quot;, &quot;label&quot;:&quot;Server address&quot; }</span>
  1624. <span style="color: #e6db74"> ]</span>
  1625. <span style="color: #e6db74">}</span>
  1626. <span style="color: #e6db74">)raw&quot;</span><span style="color: #f8f8f2">;</span>
  1627. <span style="color: #f8f8f2">AutoConnect</span> <span style="color: #f8f8f2">portal;</span>
  1628. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">setup</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1629. <span style="color: #75715e">// This declaration is wrong.</span>
  1630. <span style="background-color: #49483e"> <span style="color: #f8f8f2">AutoConnectAux</span> <span style="color: #f8f8f2">aux;</span>
  1631. </span> <span style="color: #f8f8f2">aux.load(auxPage);</span>
  1632. <span style="color: #f8f8f2">portal.join(aux);</span>
  1633. <span style="color: #f8f8f2">portal.begin();</span>
  1634. <span style="color: #f8f8f2">}</span>
  1635. <span style="color: #66d9ef">void</span> <span style="color: #a6e22e">loop</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
  1636. <span style="color: #f8f8f2">portal.handleClient();</span>
  1637. <span style="color: #f8f8f2">}</span>
  1638. </code></pre></div>
  1639. <h3 id="the-uri-of-the-custom-web-pages">The URI of the custom Web pages<a class="headerlink" href="#the-uri-of-the-custom-web-pages" title="Permanent link">&para;</a></h3>
  1640. <p>The transition of the custom Web page follows the URI of the page, but the ESP8266WebServer class does not know the URI of an AutoConnectAux page. (Registering a custom Web page does not use the <em>ESP8266WebServer::on</em>/<em>WebServer::on</em> function.) Therefore ESP8266WebServer class does not detect its URI access. If you want to detect an http request to AutoConnectAux's custom Web page, you need to register its URI with the <a href="apiaux.html#on">AutoConnectAux::on</a> function.</p>
  1641. <p>In addition to this, there are restrictions in the handler for the custom Web page as shown in the following section.</p>
  1642. <h3 id="limitations">Limitations<a class="headerlink" href="#limitations" title="Permanent link">&para;</a></h3>
  1643. <p>The custom Web pages handler has the following limitations.</p>
  1644. <ul>
  1645. <li>
  1646. <p>Do not send HTTP responses from the handler.</p>
  1647. <p>If the handler returns its own response, the custom Web page will be lost.</p>
  1648. </li>
  1649. <li>
  1650. <p>Use AutoConnectSubmit whenever possible.</p>
  1651. <p>AutoConnect will hold the values of a custom Web Page is sent by AutoConnectSubmit.</p>
  1652. </li>
  1653. <li>
  1654. <p>Can not handle the custom Web pages during a connection is not established yet.</p>
  1655. <p>During the connection attempt, the web browser of the client will send a probe for a captive portal. Its request will cause unintended custom Web page transitions.</p>
  1656. </li>
  1657. <li>
  1658. <p>Can not place URI of the custom Web pages to AUTOCONNECT_URI.</p>
  1659. <p>AutoConnect will not work if you place a custom Web page to <a href="api.html#defined-macros">AUTOCONNECT_URI</a>.</p>
  1660. </li>
  1661. <li>
  1662. <p>Can not use the element named <strong>SUBMIT</strong>.</p>
  1663. <p>You can not use 'SUBMIT' as the element name of AutoConnectElements in a custom Web page that declares the AutoConnectSubmit element. (Case sensitive ignored) AutoConnect does not rely on the <code>input type=submit</code> element for the form submission and uses <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit">HTML form element submit</a> function instead. So, the submit function will fail if there is an element named 'submit' in the form.</p>
  1664. </li>
  1665. </ul>
  1666. <div class="admonition caution">
  1667. <p class="admonition-title">Do not handle for the same page</p>
  1668. <p>Do not duplicate AutoConnect::on with ESP8266WebServer::on (also WebServer::on) for the same custom web page.</p>
  1669. </div>
  1670. <script>
  1671. window.onload = function() {
  1672. Gifffer();
  1673. };
  1674. </script>
  1675. <div class="footnote">
  1676. <hr />
  1677. <ol>
  1678. <li id="fn:1">
  1679. <p>The valid scope of the name is within an AutoConnectAux.&#160;<a class="footnote-backref" href="#fnref:1" title="Jump back to footnote 1 in the text">&#8617;</a></p>
  1680. </li>
  1681. <li id="fn:2">
  1682. <p>Regular expression specification as a pattern of AutoConnectInput is <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">JavaScript compliant</a>.&#160;<a class="footnote-backref" href="#fnref:2" title="Jump back to footnote 2 in the text">&#8617;</a></p>
  1683. </li>
  1684. </ol>
  1685. </div>
  1686. </article>
  1687. </div>
  1688. </div>
  1689. </main>
  1690. <footer class="md-footer">
  1691. <div class="md-footer-nav">
  1692. <nav class="md-footer-nav__inner md-grid" aria-label="Footer">
  1693. <a href="acjson.html" class="md-footer-nav__link md-footer-nav__link--prev" rel="prev">
  1694. <div class="md-footer-nav__button md-icon">
  1695. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg>
  1696. </div>
  1697. <div class="md-footer-nav__title">
  1698. <div class="md-ellipsis">
  1699. <span class="md-footer-nav__direction">
  1700. Previous
  1701. </span>
  1702. Custom Web pages with JSON
  1703. </div>
  1704. </div>
  1705. </a>
  1706. <a href="otaupdate.html" class="md-footer-nav__link md-footer-nav__link--next" rel="next">
  1707. <div class="md-footer-nav__title">
  1708. <div class="md-ellipsis">
  1709. <span class="md-footer-nav__direction">
  1710. Next
  1711. </span>
  1712. OTA Updates
  1713. </div>
  1714. </div>
  1715. <div class="md-footer-nav__button md-icon">
  1716. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4z"/></svg>
  1717. </div>
  1718. </a>
  1719. </nav>
  1720. </div>
  1721. <div class="md-footer-meta md-typeset">
  1722. <div class="md-footer-meta__inner md-grid">
  1723. <div class="md-footer-copyright">
  1724. <div class="md-footer-copyright__highlight">
  1725. Copyright &copy; 2018-2020 Hieromon Ikasamo
  1726. </div>
  1727. Made with
  1728. <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
  1729. Material for MkDocs
  1730. </a>
  1731. </div>
  1732. <div class="md-footer-social">
  1733. <a href="https://github.com/Hieromon" target="_blank" rel="noopener" title="github.com" class="md-footer-social__link">
  1734. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
  1735. </a>
  1736. <a href="https://twitter.com/hieromon" target="_blank" rel="noopener" title="twitter.com" class="md-footer-social__link">
  1737. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"/></svg>
  1738. </a>
  1739. </div>
  1740. </div>
  1741. </div>
  1742. </footer>
  1743. </div>
  1744. <script src="assets/javascripts/vendor.fd16492e.min.js"></script>
  1745. <script src="assets/javascripts/bundle.7836ba4d.min.js"></script><script id="__lang" type="application/json">{"clipboard.copy": "Copy to clipboard", "clipboard.copied": "Copied to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.placeholder": "Search", "search.result.placeholder": "Type to start searching", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.term.missing": "Missing"}</script>
  1746. <script>
  1747. app = initialize({
  1748. base: ".",
  1749. features: [],
  1750. search: Object.assign({
  1751. worker: "assets/javascripts/worker/search.4ac00218.min.js"
  1752. }, typeof search !== "undefined" && search)
  1753. })
  1754. </script>
  1755. <script src="js/gifffer.min.js"></script>
  1756. </body>
  1757. </html>