1<%- 2 local ubus = require "ubus" 3 local sys = require "luci.sys" 4 local utl = require "luci.util" 5 6 function getnetworkkey() 7 local k, v, result 8 9 local conn = ubus.connect() 10 if not conn then 11 error("Failed to connect to ubusd") 12 end 13 14 result = conn:call("otbr", "networkkey", {}).Networkkey 15 16 return result 17 end 18-%> 19<%+header%> 20 21<h2><%:Join Network: %><%=luci.http.formvalue("NetworkName")%></h2> 22<br /> 23 24<br/><br/> 25 26<form class="inline" action="<%=url('admin/network/thread_attach')%>" method="post" onsubmit="return validateForm()" name="networkkeyForm"> 27<div style="width:80%;margin-left:20%;"> 28 <span><strong><%:Network Key %></strong></span> 29 <span style="margin-left:3%;"></span> 30 <input type="text" name="networkkey" value="<%=getnetworkkey()%>" style="width:50%;"/> 31 <div style="margin-left:13%;margin-top:1%;"> 32 <span><img src="<%=resource .. "/cbi/help.gif"%>"/><%:Please input your network key to ensure you join the right network.%></span> 33 </div> 34</div> 35<br/><br/><br/> 36<div class="cbi-page-actions right"> 37 <input class="cbi-button cbi-button-neutral" style="float:left;" type="button" onclick="window.location.href='thread_scan'" value="<%:Back to scan result%>" /> 38 <input type="hidden" name="token" value="<%=token%>" /> 39 <input type="hidden" name="panid" value="<%=luci.http.formvalue("PanId")%>" /> 40 <input type="hidden" name="channel" value="<%=luci.http.formvalue("Channel")%>" /> 41 <input class="cbi-button cbi-button-add important" type="submit" value="<%:Attach%>" /> 42</div> 43</form> 44 45<%+footer%> 46<script type="text/javascript">//<![CDATA[ 47 function validateForm() 48 { 49 var networkkey = document.forms["networkkeyForm"]["networkkey"].value; 50 if(networkkey.length != 32) 51 { 52 alert("Networkkey length must be 16 bytes"); 53 return false; 54 } 55 } 56//]]></script> 57