5 <title>Source: luci.js</title>
8 <script src="scripts/prettify/prettify.js"></script>
9 <script src="scripts/prettify/lang-css.js"></script>
10 <script src="scripts/jquery.min.js"></script>
12 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
14 <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
15 <link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css">
16 <link type="text/css" rel="stylesheet" href="styles/jaguar.css">
20 var config = {"monospaceLinks":true,"cleverLinks":true,"default":{"outputSourceFiles":true}};
27 <div id="wrap" class="clearfix">
29 <div class="navigation">
30 <h3 class="applicationName"><a href="index.html"></a></h3>
33 <input id="search" type="text" class="form-control input-sm" placeholder="Search Documentations">
37 <li class="item" data-name="LuCI">
39 <a href="LuCI.html">LuCI</a>
42 <ul class="members itemMembers">
44 <span class="subtitle">Members</span>
46 <li data-name="LuCI#env"><a href="LuCI.html#env">env</a></li>
49 <ul class="typedefs itemMembers">
51 <span class="subtitle">Typedefs</span>
53 <li data-name="LuCI.requestCallbackFn"><a href="LuCI.html#.requestCallbackFn">requestCallbackFn</a></li>
56 <ul class="typedefs itemMembers">
59 <ul class="methods itemMembers">
61 <span class="subtitle">Methods</span>
63 <li data-name="LuCI#bind"><a href="LuCI.html#bind">bind</a></li>
65 <li data-name="LuCI#error"><a href="LuCI.html#error">error</a></li>
67 <li data-name="LuCI#get"><a href="LuCI.html#get">get</a></li>
69 <li data-name="LuCI#halt"><a href="LuCI.html#halt">halt</a></li>
71 <li data-name="LuCI#hasSystemFeature"><a href="LuCI.html#hasSystemFeature">hasSystemFeature</a></li>
73 <li data-name="LuCI#isObject"><a href="LuCI.html#isObject">isObject</a></li>
75 <li data-name="LuCI#location"><a href="LuCI.html#location">location</a></li>
77 <li data-name="LuCI#media"><a href="LuCI.html#media">media</a></li>
79 <li data-name="LuCI#path"><a href="LuCI.html#path">path</a></li>
81 <li data-name="LuCI#poll"><a href="LuCI.html#poll">poll</a></li>
83 <li data-name="LuCI#post"><a href="LuCI.html#post">post</a></li>
85 <li data-name="LuCI#raise"><a href="LuCI.html#raise">raise</a></li>
87 <li data-name="LuCI#require"><a href="LuCI.html#require">require</a></li>
89 <li data-name="LuCI#resolveDefault"><a href="LuCI.html#resolveDefault">resolveDefault</a></li>
91 <li data-name="LuCI#resource"><a href="LuCI.html#resource">resource</a></li>
93 <li data-name="LuCI#run"><a href="LuCI.html#run">run</a></li>
95 <li data-name="LuCI#sortedKeys"><a href="LuCI.html#sortedKeys">sortedKeys</a></li>
97 <li data-name="LuCI#stop"><a href="LuCI.html#stop">stop</a></li>
99 <li data-name="LuCI#toArray"><a href="LuCI.html#toArray">toArray</a></li>
101 <li data-name="LuCI#url"><a href="LuCI.html#url">url</a></li>
104 <ul class="events itemMembers">
109 <li class="item" data-name="LuCI.Class">
111 <a href="LuCI.Class.html">LuCI.Class</a>
114 <ul class="members itemMembers">
117 <ul class="typedefs itemMembers">
120 <ul class="typedefs itemMembers">
123 <ul class="methods itemMembers">
125 <span class="subtitle">Methods</span>
127 <li data-name="LuCI.Class.extend"><a href="LuCI.Class.html#.extend">extend</a></li>
129 <li data-name="LuCI.Class.instantiate"><a href="LuCI.Class.html#.instantiate">instantiate</a></li>
131 <li data-name="LuCI.Class.isSubclass"><a href="LuCI.Class.html#.isSubclass">isSubclass</a></li>
133 <li data-name="LuCI.Class.singleton"><a href="LuCI.Class.html#.singleton">singleton</a></li>
135 <li data-name="LuCI.Class#super"><a href="LuCI.Class.html#super">super</a></li>
137 <li data-name="LuCI.Class#varargs"><a href="LuCI.Class.html#varargs">varargs</a></li>
140 <ul class="events itemMembers">
145 <li class="item" data-name="LuCI.dom">
147 <a href="LuCI.dom.html">LuCI.dom</a>
150 <ul class="members itemMembers">
153 <ul class="typedefs itemMembers">
155 <span class="subtitle">Typedefs</span>
157 <li data-name="LuCI.dom~ignoreCallbackFn"><a href="LuCI.dom.html#~ignoreCallbackFn">ignoreCallbackFn</a></li>
160 <ul class="typedefs itemMembers">
163 <ul class="methods itemMembers">
165 <span class="subtitle">Methods</span>
167 <li data-name="LuCI.dom#append"><a href="LuCI.dom.html#append">append</a></li>
169 <li data-name="LuCI.dom#attr"><a href="LuCI.dom.html#attr">attr</a></li>
171 <li data-name="LuCI.dom#bindClassInstance"><a href="LuCI.dom.html#bindClassInstance">bindClassInstance</a></li>
173 <li data-name="LuCI.dom#callClassMethod"><a href="LuCI.dom.html#callClassMethod">callClassMethod</a></li>
175 <li data-name="LuCI.dom#content"><a href="LuCI.dom.html#content">content</a></li>
177 <li data-name="LuCI.dom#create"><a href="LuCI.dom.html#create">create</a></li>
179 <li data-name="LuCI.dom#data"><a href="LuCI.dom.html#data">data</a></li>
181 <li data-name="LuCI.dom#elem"><a href="LuCI.dom.html#elem">elem</a></li>
183 <li data-name="LuCI.dom#findClassInstance"><a href="LuCI.dom.html#findClassInstance">findClassInstance</a></li>
185 <li data-name="LuCI.dom#isEmpty"><a href="LuCI.dom.html#isEmpty">isEmpty</a></li>
187 <li data-name="LuCI.dom#matches"><a href="LuCI.dom.html#matches">matches</a></li>
189 <li data-name="LuCI.dom#parent"><a href="LuCI.dom.html#parent">parent</a></li>
191 <li data-name="LuCI.dom#parse"><a href="LuCI.dom.html#parse">parse</a></li>
194 <ul class="events itemMembers">
199 <li class="item" data-name="LuCI.fs">
201 <a href="LuCI.fs.html">LuCI.fs</a>
204 <ul class="members itemMembers">
207 <ul class="typedefs itemMembers">
209 <span class="subtitle">Typedefs</span>
211 <li data-name="LuCI.fs.FileExecResult"><a href="LuCI.fs.html#.FileExecResult">FileExecResult</a></li>
213 <li data-name="LuCI.fs.FileStatEntry"><a href="LuCI.fs.html#.FileStatEntry">FileStatEntry</a></li>
216 <ul class="typedefs itemMembers">
219 <ul class="methods itemMembers">
221 <span class="subtitle">Methods</span>
223 <li data-name="LuCI.fs#exec"><a href="LuCI.fs.html#exec">exec</a></li>
225 <li data-name="LuCI.fs#exec_direct"><a href="LuCI.fs.html#exec_direct">exec_direct</a></li>
227 <li data-name="LuCI.fs#lines"><a href="LuCI.fs.html#lines">lines</a></li>
229 <li data-name="LuCI.fs#list"><a href="LuCI.fs.html#list">list</a></li>
231 <li data-name="LuCI.fs#read"><a href="LuCI.fs.html#read">read</a></li>
233 <li data-name="LuCI.fs#read_direct"><a href="LuCI.fs.html#read_direct">read_direct</a></li>
235 <li data-name="LuCI.fs#remove"><a href="LuCI.fs.html#remove">remove</a></li>
237 <li data-name="LuCI.fs#stat"><a href="LuCI.fs.html#stat">stat</a></li>
239 <li data-name="LuCI.fs#trimmed"><a href="LuCI.fs.html#trimmed">trimmed</a></li>
241 <li data-name="LuCI.fs#write"><a href="LuCI.fs.html#write">write</a></li>
244 <ul class="events itemMembers">
249 <li class="item" data-name="LuCI.Headers">
251 <a href="LuCI.Headers.html">LuCI.Headers</a>
254 <ul class="members itemMembers">
257 <ul class="typedefs itemMembers">
260 <ul class="typedefs itemMembers">
263 <ul class="methods itemMembers">
265 <span class="subtitle">Methods</span>
267 <li data-name="LuCI.Headers#get"><a href="LuCI.Headers.html#get">get</a></li>
269 <li data-name="LuCI.Headers#has"><a href="LuCI.Headers.html#has">has</a></li>
272 <ul class="events itemMembers">
277 <li class="item" data-name="LuCI.Network">
279 <a href="LuCI.Network.html">LuCI.Network</a>
282 <ul class="members itemMembers">
285 <ul class="typedefs itemMembers">
287 <span class="subtitle">Typedefs</span>
289 <li data-name="LuCI.Network.SwitchTopology"><a href="LuCI.Network.html#.SwitchTopology">SwitchTopology</a></li>
291 <li data-name="LuCI.Network.WifiEncryption"><a href="LuCI.Network.html#.WifiEncryption">WifiEncryption</a></li>
293 <li data-name="LuCI.Network.WifiPeerEntry"><a href="LuCI.Network.html#.WifiPeerEntry">WifiPeerEntry</a></li>
295 <li data-name="LuCI.Network.WifiRateEntry"><a href="LuCI.Network.html#.WifiRateEntry">WifiRateEntry</a></li>
297 <li data-name="LuCI.Network.WifiScanResult"><a href="LuCI.Network.html#.WifiScanResult">WifiScanResult</a></li>
300 <ul class="typedefs itemMembers">
303 <ul class="methods itemMembers">
305 <span class="subtitle">Methods</span>
307 <li data-name="LuCI.Network#addNetwork"><a href="LuCI.Network.html#addNetwork">addNetwork</a></li>
309 <li data-name="LuCI.Network#addWifiNetwork"><a href="LuCI.Network.html#addWifiNetwork">addWifiNetwork</a></li>
311 <li data-name="LuCI.Network#deleteNetwork"><a href="LuCI.Network.html#deleteNetwork">deleteNetwork</a></li>
313 <li data-name="LuCI.Network#deleteWifiNetwork"><a href="LuCI.Network.html#deleteWifiNetwork">deleteWifiNetwork</a></li>
315 <li data-name="LuCI.Network#flushCache"><a href="LuCI.Network.html#flushCache">flushCache</a></li>
317 <li data-name="LuCI.Network#formatWifiEncryption"><a href="LuCI.Network.html#formatWifiEncryption">formatWifiEncryption</a></li>
319 <li data-name="LuCI.Network#getDevice"><a href="LuCI.Network.html#getDevice">getDevice</a></li>
321 <li data-name="LuCI.Network#getDevices"><a href="LuCI.Network.html#getDevices">getDevices</a></li>
323 <li data-name="LuCI.Network#getDSLModemType"><a href="LuCI.Network.html#getDSLModemType">getDSLModemType</a></li>
325 <li data-name="LuCI.Network#getHostHints"><a href="LuCI.Network.html#getHostHints">getHostHints</a></li>
327 <li data-name="LuCI.Network#getIfnameOf"><a href="LuCI.Network.html#getIfnameOf">getIfnameOf</a></li>
329 <li data-name="LuCI.Network#getNetwork"><a href="LuCI.Network.html#getNetwork">getNetwork</a></li>
331 <li data-name="LuCI.Network#getNetworks"><a href="LuCI.Network.html#getNetworks">getNetworks</a></li>
333 <li data-name="LuCI.Network#getProtocol"><a href="LuCI.Network.html#getProtocol">getProtocol</a></li>
335 <li data-name="LuCI.Network#getProtocols"><a href="LuCI.Network.html#getProtocols">getProtocols</a></li>
337 <li data-name="LuCI.Network#getSwitchTopologies"><a href="LuCI.Network.html#getSwitchTopologies">getSwitchTopologies</a></li>
339 <li data-name="LuCI.Network#getWAN6Networks"><a href="LuCI.Network.html#getWAN6Networks">getWAN6Networks</a></li>
341 <li data-name="LuCI.Network#getWANNetworks"><a href="LuCI.Network.html#getWANNetworks">getWANNetworks</a></li>
343 <li data-name="LuCI.Network#getWifiDevice"><a href="LuCI.Network.html#getWifiDevice">getWifiDevice</a></li>
345 <li data-name="LuCI.Network#getWifiDevices"><a href="LuCI.Network.html#getWifiDevices">getWifiDevices</a></li>
347 <li data-name="LuCI.Network#getWifiNetwork"><a href="LuCI.Network.html#getWifiNetwork">getWifiNetwork</a></li>
349 <li data-name="LuCI.Network#getWifiNetworks"><a href="LuCI.Network.html#getWifiNetworks">getWifiNetworks</a></li>
351 <li data-name="LuCI.Network#isIgnoredDevice"><a href="LuCI.Network.html#isIgnoredDevice">isIgnoredDevice</a></li>
353 <li data-name="LuCI.Network#maskToPrefix"><a href="LuCI.Network.html#maskToPrefix">maskToPrefix</a></li>
355 <li data-name="LuCI.Network#prefixToMask"><a href="LuCI.Network.html#prefixToMask">prefixToMask</a></li>
357 <li data-name="LuCI.Network#registerErrorCode"><a href="LuCI.Network.html#registerErrorCode">registerErrorCode</a></li>
359 <li data-name="LuCI.Network#registerPatternVirtual"><a href="LuCI.Network.html#registerPatternVirtual">registerPatternVirtual</a></li>
361 <li data-name="LuCI.Network#registerProtocol"><a href="LuCI.Network.html#registerProtocol">registerProtocol</a></li>
363 <li data-name="LuCI.Network#renameNetwork"><a href="LuCI.Network.html#renameNetwork">renameNetwork</a></li>
366 <ul class="events itemMembers">
371 <li class="item" data-name="LuCI.Network.Device">
373 <a href="LuCI.Network.Device.html">LuCI.Network.Device</a>
376 <ul class="members itemMembers">
379 <ul class="typedefs itemMembers">
382 <ul class="typedefs itemMembers">
385 <ul class="methods itemMembers">
387 <span class="subtitle">Methods</span>
389 <li data-name="LuCI.Network.Device#getBridgeID"><a href="LuCI.Network.Device.html#getBridgeID">getBridgeID</a></li>
391 <li data-name="LuCI.Network.Device#getBridgeSTP"><a href="LuCI.Network.Device.html#getBridgeSTP">getBridgeSTP</a></li>
393 <li data-name="LuCI.Network.Device#getI18n"><a href="LuCI.Network.Device.html#getI18n">getI18n</a></li>
395 <li data-name="LuCI.Network.Device#getIP6Addrs"><a href="LuCI.Network.Device.html#getIP6Addrs">getIP6Addrs</a></li>
397 <li data-name="LuCI.Network.Device#getIPAddrs"><a href="LuCI.Network.Device.html#getIPAddrs">getIPAddrs</a></li>
399 <li data-name="LuCI.Network.Device#getMAC"><a href="LuCI.Network.Device.html#getMAC">getMAC</a></li>
401 <li data-name="LuCI.Network.Device#getMTU"><a href="LuCI.Network.Device.html#getMTU">getMTU</a></li>
403 <li data-name="LuCI.Network.Device#getName"><a href="LuCI.Network.Device.html#getName">getName</a></li>
405 <li data-name="LuCI.Network.Device#getNetwork"><a href="LuCI.Network.Device.html#getNetwork">getNetwork</a></li>
407 <li data-name="LuCI.Network.Device#getNetworks"><a href="LuCI.Network.Device.html#getNetworks">getNetworks</a></li>
409 <li data-name="LuCI.Network.Device#getPorts"><a href="LuCI.Network.Device.html#getPorts">getPorts</a></li>
411 <li data-name="LuCI.Network.Device#getRXBytes"><a href="LuCI.Network.Device.html#getRXBytes">getRXBytes</a></li>
413 <li data-name="LuCI.Network.Device#getRXPackets"><a href="LuCI.Network.Device.html#getRXPackets">getRXPackets</a></li>
415 <li data-name="LuCI.Network.Device#getShortName"><a href="LuCI.Network.Device.html#getShortName">getShortName</a></li>
417 <li data-name="LuCI.Network.Device#getTXBytes"><a href="LuCI.Network.Device.html#getTXBytes">getTXBytes</a></li>
419 <li data-name="LuCI.Network.Device#getTXPackets"><a href="LuCI.Network.Device.html#getTXPackets">getTXPackets</a></li>
421 <li data-name="LuCI.Network.Device#getType"><a href="LuCI.Network.Device.html#getType">getType</a></li>
423 <li data-name="LuCI.Network.Device#getTypeI18n"><a href="LuCI.Network.Device.html#getTypeI18n">getTypeI18n</a></li>
425 <li data-name="LuCI.Network.Device#getWifiNetwork"><a href="LuCI.Network.Device.html#getWifiNetwork">getWifiNetwork</a></li>
427 <li data-name="LuCI.Network.Device#isBridge"><a href="LuCI.Network.Device.html#isBridge">isBridge</a></li>
429 <li data-name="LuCI.Network.Device#isBridgePort"><a href="LuCI.Network.Device.html#isBridgePort">isBridgePort</a></li>
431 <li data-name="LuCI.Network.Device#isUp"><a href="LuCI.Network.Device.html#isUp">isUp</a></li>
434 <ul class="events itemMembers">
439 <li class="item" data-name="LuCI.Network.Hosts">
441 <a href="LuCI.Network.Hosts.html">LuCI.Network.Hosts</a>
444 <ul class="members itemMembers">
447 <ul class="typedefs itemMembers">
450 <ul class="typedefs itemMembers">
453 <ul class="methods itemMembers">
455 <span class="subtitle">Methods</span>
457 <li data-name="LuCI.Network.Hosts#getHostnameByIP6Addr"><a href="LuCI.Network.Hosts.html#getHostnameByIP6Addr">getHostnameByIP6Addr</a></li>
459 <li data-name="LuCI.Network.Hosts#getHostnameByIPAddr"><a href="LuCI.Network.Hosts.html#getHostnameByIPAddr">getHostnameByIPAddr</a></li>
461 <li data-name="LuCI.Network.Hosts#getHostnameByMACAddr"><a href="LuCI.Network.Hosts.html#getHostnameByMACAddr">getHostnameByMACAddr</a></li>
463 <li data-name="LuCI.Network.Hosts#getIP6AddrByMACAddr"><a href="LuCI.Network.Hosts.html#getIP6AddrByMACAddr">getIP6AddrByMACAddr</a></li>
465 <li data-name="LuCI.Network.Hosts#getIPAddrByMACAddr"><a href="LuCI.Network.Hosts.html#getIPAddrByMACAddr">getIPAddrByMACAddr</a></li>
467 <li data-name="LuCI.Network.Hosts#getMACAddrByIP6Addr"><a href="LuCI.Network.Hosts.html#getMACAddrByIP6Addr">getMACAddrByIP6Addr</a></li>
469 <li data-name="LuCI.Network.Hosts#getMACAddrByIPAddr"><a href="LuCI.Network.Hosts.html#getMACAddrByIPAddr">getMACAddrByIPAddr</a></li>
471 <li data-name="LuCI.Network.Hosts#getMACHints"><a href="LuCI.Network.Hosts.html#getMACHints">getMACHints</a></li>
474 <ul class="events itemMembers">
479 <li class="item" data-name="LuCI.Network.Protocol">
481 <a href="LuCI.Network.Protocol.html">LuCI.Network.Protocol</a>
484 <ul class="members itemMembers">
487 <ul class="typedefs itemMembers">
490 <ul class="typedefs itemMembers">
493 <ul class="methods itemMembers">
495 <span class="subtitle">Methods</span>
497 <li data-name="LuCI.Network.Protocol#addDevice"><a href="LuCI.Network.Protocol.html#addDevice">addDevice</a></li>
499 <li data-name="LuCI.Network.Protocol#containsDevice"><a href="LuCI.Network.Protocol.html#containsDevice">containsDevice</a></li>
501 <li data-name="LuCI.Network.Protocol#deleteDevice"><a href="LuCI.Network.Protocol.html#deleteDevice">deleteDevice</a></li>
503 <li data-name="LuCI.Network.Protocol#get"><a href="LuCI.Network.Protocol.html#get">get</a></li>
505 <li data-name="LuCI.Network.Protocol#getDevice"><a href="LuCI.Network.Protocol.html#getDevice">getDevice</a></li>
507 <li data-name="LuCI.Network.Protocol#getDevices"><a href="LuCI.Network.Protocol.html#getDevices">getDevices</a></li>
509 <li data-name="LuCI.Network.Protocol#getDNS6Addrs"><a href="LuCI.Network.Protocol.html#getDNS6Addrs">getDNS6Addrs</a></li>
511 <li data-name="LuCI.Network.Protocol#getDNSAddrs"><a href="LuCI.Network.Protocol.html#getDNSAddrs">getDNSAddrs</a></li>
513 <li data-name="LuCI.Network.Protocol#getErrors"><a href="LuCI.Network.Protocol.html#getErrors">getErrors</a></li>
515 <li data-name="LuCI.Network.Protocol#getExpiry"><a href="LuCI.Network.Protocol.html#getExpiry">getExpiry</a></li>
517 <li data-name="LuCI.Network.Protocol#getGateway6Addr"><a href="LuCI.Network.Protocol.html#getGateway6Addr">getGateway6Addr</a></li>
519 <li data-name="LuCI.Network.Protocol#getGatewayAddr"><a href="LuCI.Network.Protocol.html#getGatewayAddr">getGatewayAddr</a></li>
521 <li data-name="LuCI.Network.Protocol#getI18n"><a href="LuCI.Network.Protocol.html#getI18n">getI18n</a></li>
523 <li data-name="LuCI.Network.Protocol#getIfname"><a href="LuCI.Network.Protocol.html#getIfname">getIfname</a></li>
525 <li data-name="LuCI.Network.Protocol#getIP6Addr"><a href="LuCI.Network.Protocol.html#getIP6Addr">getIP6Addr</a></li>
527 <li data-name="LuCI.Network.Protocol#getIP6Addrs"><a href="LuCI.Network.Protocol.html#getIP6Addrs">getIP6Addrs</a></li>
529 <li data-name="LuCI.Network.Protocol#getIP6Prefix"><a href="LuCI.Network.Protocol.html#getIP6Prefix">getIP6Prefix</a></li>
531 <li data-name="LuCI.Network.Protocol#getIPAddr"><a href="LuCI.Network.Protocol.html#getIPAddr">getIPAddr</a></li>
533 <li data-name="LuCI.Network.Protocol#getIPAddrs"><a href="LuCI.Network.Protocol.html#getIPAddrs">getIPAddrs</a></li>
535 <li data-name="LuCI.Network.Protocol#getL2Device"><a href="LuCI.Network.Protocol.html#getL2Device">getL2Device</a></li>
537 <li data-name="LuCI.Network.Protocol#getL3Device"><a href="LuCI.Network.Protocol.html#getL3Device">getL3Device</a></li>
539 <li data-name="LuCI.Network.Protocol#getMetric"><a href="LuCI.Network.Protocol.html#getMetric">getMetric</a></li>
541 <li data-name="LuCI.Network.Protocol#getName"><a href="LuCI.Network.Protocol.html#getName">getName</a></li>
543 <li data-name="LuCI.Network.Protocol#getNetmask"><a href="LuCI.Network.Protocol.html#getNetmask">getNetmask</a></li>
545 <li data-name="LuCI.Network.Protocol#getOpkgPackage"><a href="LuCI.Network.Protocol.html#getOpkgPackage">getOpkgPackage</a></li>
547 <li data-name="LuCI.Network.Protocol#getProtocol"><a href="LuCI.Network.Protocol.html#getProtocol">getProtocol</a></li>
549 <li data-name="LuCI.Network.Protocol#getType"><a href="LuCI.Network.Protocol.html#getType">getType</a></li>
551 <li data-name="LuCI.Network.Protocol#getUptime"><a href="LuCI.Network.Protocol.html#getUptime">getUptime</a></li>
553 <li data-name="LuCI.Network.Protocol#getZoneName"><a href="LuCI.Network.Protocol.html#getZoneName">getZoneName</a></li>
555 <li data-name="LuCI.Network.Protocol#isAlias"><a href="LuCI.Network.Protocol.html#isAlias">isAlias</a></li>
557 <li data-name="LuCI.Network.Protocol#isBridge"><a href="LuCI.Network.Protocol.html#isBridge">isBridge</a></li>
559 <li data-name="LuCI.Network.Protocol#isDynamic"><a href="LuCI.Network.Protocol.html#isDynamic">isDynamic</a></li>
561 <li data-name="LuCI.Network.Protocol#isEmpty"><a href="LuCI.Network.Protocol.html#isEmpty">isEmpty</a></li>
563 <li data-name="LuCI.Network.Protocol#isFloating"><a href="LuCI.Network.Protocol.html#isFloating">isFloating</a></li>
565 <li data-name="LuCI.Network.Protocol#isInstalled"><a href="LuCI.Network.Protocol.html#isInstalled">isInstalled</a></li>
567 <li data-name="LuCI.Network.Protocol#isUp"><a href="LuCI.Network.Protocol.html#isUp">isUp</a></li>
569 <li data-name="LuCI.Network.Protocol#isVirtual"><a href="LuCI.Network.Protocol.html#isVirtual">isVirtual</a></li>
571 <li data-name="LuCI.Network.Protocol#set"><a href="LuCI.Network.Protocol.html#set">set</a></li>
574 <ul class="events itemMembers">
579 <li class="item" data-name="LuCI.Network.WifiDevice">
581 <a href="LuCI.Network.WifiDevice.html">LuCI.Network.WifiDevice</a>
584 <ul class="members itemMembers">
587 <ul class="typedefs itemMembers">
590 <ul class="typedefs itemMembers">
593 <ul class="methods itemMembers">
595 <span class="subtitle">Methods</span>
597 <li data-name="LuCI.Network.WifiDevice#addWifiNetwork"><a href="LuCI.Network.WifiDevice.html#addWifiNetwork">addWifiNetwork</a></li>
599 <li data-name="LuCI.Network.WifiDevice#deleteWifiNetwork"><a href="LuCI.Network.WifiDevice.html#deleteWifiNetwork">deleteWifiNetwork</a></li>
601 <li data-name="LuCI.Network.WifiDevice#get"><a href="LuCI.Network.WifiDevice.html#get">get</a></li>
603 <li data-name="LuCI.Network.WifiDevice#getHTModes"><a href="LuCI.Network.WifiDevice.html#getHTModes">getHTModes</a></li>
605 <li data-name="LuCI.Network.WifiDevice#getHWModes"><a href="LuCI.Network.WifiDevice.html#getHWModes">getHWModes</a></li>
607 <li data-name="LuCI.Network.WifiDevice#getI18n"><a href="LuCI.Network.WifiDevice.html#getI18n">getI18n</a></li>
609 <li data-name="LuCI.Network.WifiDevice#getName"><a href="LuCI.Network.WifiDevice.html#getName">getName</a></li>
611 <li data-name="LuCI.Network.WifiDevice#getScanList"><a href="LuCI.Network.WifiDevice.html#getScanList">getScanList</a></li>
613 <li data-name="LuCI.Network.WifiDevice#getWifiNetwork"><a href="LuCI.Network.WifiDevice.html#getWifiNetwork">getWifiNetwork</a></li>
615 <li data-name="LuCI.Network.WifiDevice#getWifiNetworks"><a href="LuCI.Network.WifiDevice.html#getWifiNetworks">getWifiNetworks</a></li>
617 <li data-name="LuCI.Network.WifiDevice#isDisabled"><a href="LuCI.Network.WifiDevice.html#isDisabled">isDisabled</a></li>
619 <li data-name="LuCI.Network.WifiDevice#isUp"><a href="LuCI.Network.WifiDevice.html#isUp">isUp</a></li>
621 <li data-name="LuCI.Network.WifiDevice#set"><a href="LuCI.Network.WifiDevice.html#set">set</a></li>
624 <ul class="events itemMembers">
629 <li class="item" data-name="LuCI.Network.WifiNetwork">
631 <a href="LuCI.Network.WifiNetwork.html">LuCI.Network.WifiNetwork</a>
634 <ul class="members itemMembers">
637 <ul class="typedefs itemMembers">
640 <ul class="typedefs itemMembers">
643 <ul class="methods itemMembers">
645 <span class="subtitle">Methods</span>
647 <li data-name="LuCI.Network.WifiNetwork#disconnectClient"><a href="LuCI.Network.WifiNetwork.html#disconnectClient">disconnectClient</a></li>
649 <li data-name="LuCI.Network.WifiNetwork#get"><a href="LuCI.Network.WifiNetwork.html#get">get</a></li>
651 <li data-name="LuCI.Network.WifiNetwork#getActiveBSSID"><a href="LuCI.Network.WifiNetwork.html#getActiveBSSID">getActiveBSSID</a></li>
653 <li data-name="LuCI.Network.WifiNetwork#getActiveEncryption"><a href="LuCI.Network.WifiNetwork.html#getActiveEncryption">getActiveEncryption</a></li>
655 <li data-name="LuCI.Network.WifiNetwork#getActiveMode"><a href="LuCI.Network.WifiNetwork.html#getActiveMode">getActiveMode</a></li>
657 <li data-name="LuCI.Network.WifiNetwork#getActiveModeI18n"><a href="LuCI.Network.WifiNetwork.html#getActiveModeI18n">getActiveModeI18n</a></li>
659 <li data-name="LuCI.Network.WifiNetwork#getActiveSSID"><a href="LuCI.Network.WifiNetwork.html#getActiveSSID">getActiveSSID</a></li>
661 <li data-name="LuCI.Network.WifiNetwork#getAssocList"><a href="LuCI.Network.WifiNetwork.html#getAssocList">getAssocList</a></li>
663 <li data-name="LuCI.Network.WifiNetwork#getBitRate"><a href="LuCI.Network.WifiNetwork.html#getBitRate">getBitRate</a></li>
665 <li data-name="LuCI.Network.WifiNetwork#getBSSID"><a href="LuCI.Network.WifiNetwork.html#getBSSID">getBSSID</a></li>
667 <li data-name="LuCI.Network.WifiNetwork#getChannel"><a href="LuCI.Network.WifiNetwork.html#getChannel">getChannel</a></li>
669 <li data-name="LuCI.Network.WifiNetwork#getCountryCode"><a href="LuCI.Network.WifiNetwork.html#getCountryCode">getCountryCode</a></li>
671 <li data-name="LuCI.Network.WifiNetwork#getDevice"><a href="LuCI.Network.WifiNetwork.html#getDevice">getDevice</a></li>
673 <li data-name="LuCI.Network.WifiNetwork#getFrequency"><a href="LuCI.Network.WifiNetwork.html#getFrequency">getFrequency</a></li>
675 <li data-name="LuCI.Network.WifiNetwork#getI18n"><a href="LuCI.Network.WifiNetwork.html#getI18n">getI18n</a></li>
677 <li data-name="LuCI.Network.WifiNetwork#getID"><a href="LuCI.Network.WifiNetwork.html#getID">getID</a></li>
679 <li data-name="LuCI.Network.WifiNetwork#getIfname"><a href="LuCI.Network.WifiNetwork.html#getIfname">getIfname</a></li>
681 <li data-name="LuCI.Network.WifiNetwork#getMeshID"><a href="LuCI.Network.WifiNetwork.html#getMeshID">getMeshID</a></li>
683 <li data-name="LuCI.Network.WifiNetwork#getMode"><a href="LuCI.Network.WifiNetwork.html#getMode">getMode</a></li>
685 <li data-name="LuCI.Network.WifiNetwork#getName"><a href="LuCI.Network.WifiNetwork.html#getName">getName</a></li>
687 <li data-name="LuCI.Network.WifiNetwork#getNetwork"><a href="LuCI.Network.WifiNetwork.html#getNetwork">getNetwork</a></li>
689 <li data-name="LuCI.Network.WifiNetwork#getNetworkNames"><a href="LuCI.Network.WifiNetwork.html#getNetworkNames">getNetworkNames</a></li>
691 <li data-name="LuCI.Network.WifiNetwork#getNetworks"><a href="LuCI.Network.WifiNetwork.html#getNetworks">getNetworks</a></li>
693 <li data-name="LuCI.Network.WifiNetwork#getNoise"><a href="LuCI.Network.WifiNetwork.html#getNoise">getNoise</a></li>
695 <li data-name="LuCI.Network.WifiNetwork#getShortName"><a href="LuCI.Network.WifiNetwork.html#getShortName">getShortName</a></li>
697 <li data-name="LuCI.Network.WifiNetwork#getSignal"><a href="LuCI.Network.WifiNetwork.html#getSignal">getSignal</a></li>
699 <li data-name="LuCI.Network.WifiNetwork#getSignalLevel"><a href="LuCI.Network.WifiNetwork.html#getSignalLevel">getSignalLevel</a></li>
701 <li data-name="LuCI.Network.WifiNetwork#getSignalPercent"><a href="LuCI.Network.WifiNetwork.html#getSignalPercent">getSignalPercent</a></li>
703 <li data-name="LuCI.Network.WifiNetwork#getSSID"><a href="LuCI.Network.WifiNetwork.html#getSSID">getSSID</a></li>
705 <li data-name="LuCI.Network.WifiNetwork#getTXPower"><a href="LuCI.Network.WifiNetwork.html#getTXPower">getTXPower</a></li>
707 <li data-name="LuCI.Network.WifiNetwork#getTXPowerOffset"><a href="LuCI.Network.WifiNetwork.html#getTXPowerOffset">getTXPowerOffset</a></li>
709 <li data-name="LuCI.Network.WifiNetwork#getWifiDevice"><a href="LuCI.Network.WifiNetwork.html#getWifiDevice">getWifiDevice</a></li>
711 <li data-name="LuCI.Network.WifiNetwork#getWifiDeviceName"><a href="LuCI.Network.WifiNetwork.html#getWifiDeviceName">getWifiDeviceName</a></li>
713 <li data-name="LuCI.Network.WifiNetwork#isClientDisconnectSupported"><a href="LuCI.Network.WifiNetwork.html#isClientDisconnectSupported">isClientDisconnectSupported</a></li>
715 <li data-name="LuCI.Network.WifiNetwork#isDisabled"><a href="LuCI.Network.WifiNetwork.html#isDisabled">isDisabled</a></li>
717 <li data-name="LuCI.Network.WifiNetwork#isUp"><a href="LuCI.Network.WifiNetwork.html#isUp">isUp</a></li>
719 <li data-name="LuCI.Network.WifiNetwork#set"><a href="LuCI.Network.WifiNetwork.html#set">set</a></li>
722 <ul class="events itemMembers">
727 <li class="item" data-name="LuCI.Poll">
729 <a href="LuCI.Poll.html">LuCI.Poll</a>
732 <ul class="members itemMembers">
735 <ul class="typedefs itemMembers">
738 <ul class="typedefs itemMembers">
741 <ul class="methods itemMembers">
743 <span class="subtitle">Methods</span>
745 <li data-name="LuCI.Poll#active"><a href="LuCI.Poll.html#active">active</a></li>
747 <li data-name="LuCI.Poll#add"><a href="LuCI.Poll.html#add">add</a></li>
749 <li data-name="LuCI.Poll#remove"><a href="LuCI.Poll.html#remove">remove</a></li>
751 <li data-name="LuCI.Poll#start"><a href="LuCI.Poll.html#start">start</a></li>
753 <li data-name="LuCI.Poll#stop"><a href="LuCI.Poll.html#stop">stop</a></li>
756 <ul class="events itemMembers">
761 <li class="item" data-name="LuCI.Request">
763 <a href="LuCI.Request.html">LuCI.Request</a>
766 <ul class="members itemMembers">
769 <ul class="typedefs itemMembers">
771 <span class="subtitle">Typedefs</span>
773 <li data-name="LuCI.Request.interceptorFn"><a href="LuCI.Request.html#.interceptorFn">interceptorFn</a></li>
775 <li data-name="LuCI.Request.RequestOptions"><a href="LuCI.Request.html#.RequestOptions">RequestOptions</a></li>
778 <ul class="typedefs itemMembers">
781 <ul class="methods itemMembers">
783 <span class="subtitle">Methods</span>
785 <li data-name="LuCI.Request#addInterceptor"><a href="LuCI.Request.html#addInterceptor">addInterceptor</a></li>
787 <li data-name="LuCI.Request#expandURL"><a href="LuCI.Request.html#expandURL">expandURL</a></li>
789 <li data-name="LuCI.Request#get"><a href="LuCI.Request.html#get">get</a></li>
791 <li data-name="LuCI.Request#post"><a href="LuCI.Request.html#post">post</a></li>
793 <li data-name="LuCI.Request#removeInterceptor"><a href="LuCI.Request.html#removeInterceptor">removeInterceptor</a></li>
795 <li data-name="LuCI.Request#request"><a href="LuCI.Request.html#request">request</a></li>
798 <ul class="events itemMembers">
803 <li class="item" data-name="LuCI.Request.poll">
805 <a href="LuCI.Request.poll.html">LuCI.Request.poll</a>
808 <ul class="members itemMembers">
811 <ul class="typedefs itemMembers">
813 <span class="subtitle">Typedefs</span>
815 <li data-name="LuCI.Request.poll~callbackFn"><a href="LuCI.Request.poll.html#~callbackFn">callbackFn</a></li>
818 <ul class="typedefs itemMembers">
821 <ul class="methods itemMembers">
823 <span class="subtitle">Methods</span>
825 <li data-name="LuCI.Request.poll#active"><a href="LuCI.Request.poll.html#active">active</a></li>
827 <li data-name="LuCI.Request.poll#add"><a href="LuCI.Request.poll.html#add">add</a></li>
829 <li data-name="LuCI.Request.poll#remove"><a href="LuCI.Request.poll.html#remove">remove</a></li>
831 <li data-name="LuCI.Request.poll#start"><a href="LuCI.Request.poll.html#start">start</a></li>
833 <li data-name="LuCI.Request.poll#stop"><a href="LuCI.Request.poll.html#stop">stop</a></li>
836 <ul class="events itemMembers">
841 <li class="item" data-name="LuCI.Response">
843 <a href="LuCI.Response.html">LuCI.Response</a>
846 <ul class="members itemMembers">
848 <span class="subtitle">Members</span>
850 <li data-name="LuCI.Response#duration"><a href="LuCI.Response.html#duration">duration</a></li>
852 <li data-name="LuCI.Response#headers"><a href="LuCI.Response.html#headers">headers</a></li>
854 <li data-name="LuCI.Response#ok"><a href="LuCI.Response.html#ok">ok</a></li>
856 <li data-name="LuCI.Response#status"><a href="LuCI.Response.html#status">status</a></li>
858 <li data-name="LuCI.Response#statusText"><a href="LuCI.Response.html#statusText">statusText</a></li>
860 <li data-name="LuCI.Response#url"><a href="LuCI.Response.html#url">url</a></li>
863 <ul class="typedefs itemMembers">
866 <ul class="typedefs itemMembers">
869 <ul class="methods itemMembers">
871 <span class="subtitle">Methods</span>
873 <li data-name="LuCI.Response#blob"><a href="LuCI.Response.html#blob">blob</a></li>
875 <li data-name="LuCI.Response#clone"><a href="LuCI.Response.html#clone">clone</a></li>
877 <li data-name="LuCI.Response#json"><a href="LuCI.Response.html#json">json</a></li>
879 <li data-name="LuCI.Response#text"><a href="LuCI.Response.html#text">text</a></li>
882 <ul class="events itemMembers">
887 <li class="item" data-name="LuCI.rpc">
889 <a href="LuCI.rpc.html">LuCI.rpc</a>
892 <ul class="members itemMembers">
895 <ul class="typedefs itemMembers">
897 <span class="subtitle">Typedefs</span>
899 <li data-name="LuCI.rpc.DeclareOptions"><a href="LuCI.rpc.html#.DeclareOptions">DeclareOptions</a></li>
901 <li data-name="LuCI.rpc~filterFn"><a href="LuCI.rpc.html#~filterFn">filterFn</a></li>
903 <li data-name="LuCI.rpc~interceptorFn"><a href="LuCI.rpc.html#~interceptorFn">interceptorFn</a></li>
905 <li data-name="LuCI.rpc~invokeFn"><a href="LuCI.rpc.html#~invokeFn">invokeFn</a></li>
908 <ul class="typedefs itemMembers">
911 <ul class="methods itemMembers">
913 <span class="subtitle">Methods</span>
915 <li data-name="LuCI.rpc#addInterceptor"><a href="LuCI.rpc.html#addInterceptor">addInterceptor</a></li>
917 <li data-name="LuCI.rpc#declare"><a href="LuCI.rpc.html#declare">declare</a></li>
919 <li data-name="LuCI.rpc#getBaseURL"><a href="LuCI.rpc.html#getBaseURL">getBaseURL</a></li>
921 <li data-name="LuCI.rpc#getSessionID"><a href="LuCI.rpc.html#getSessionID">getSessionID</a></li>
923 <li data-name="LuCI.rpc#getStatusText"><a href="LuCI.rpc.html#getStatusText">getStatusText</a></li>
925 <li data-name="LuCI.rpc#list"><a href="LuCI.rpc.html#list">list</a></li>
927 <li data-name="LuCI.rpc#removeInterceptor"><a href="LuCI.rpc.html#removeInterceptor">removeInterceptor</a></li>
929 <li data-name="LuCI.rpc#setBaseURL"><a href="LuCI.rpc.html#setBaseURL">setBaseURL</a></li>
931 <li data-name="LuCI.rpc#setSessionID"><a href="LuCI.rpc.html#setSessionID">setSessionID</a></li>
934 <ul class="events itemMembers">
939 <li class="item" data-name="LuCI.uci">
941 <a href="LuCI.uci.html">LuCI.uci</a>
944 <ul class="members itemMembers">
947 <ul class="typedefs itemMembers">
949 <span class="subtitle">Typedefs</span>
951 <li data-name="LuCI.uci.ChangeRecord"><a href="LuCI.uci.html#.ChangeRecord">ChangeRecord</a></li>
953 <li data-name="LuCI.uci.SectionObject"><a href="LuCI.uci.html#.SectionObject">SectionObject</a></li>
955 <li data-name="LuCI.uci~sectionsFn"><a href="LuCI.uci.html#~sectionsFn">sectionsFn</a></li>
958 <ul class="typedefs itemMembers">
961 <ul class="methods itemMembers">
963 <span class="subtitle">Methods</span>
965 <li data-name="LuCI.uci#add"><a href="LuCI.uci.html#add">add</a></li>
967 <li data-name="LuCI.uci#apply"><a href="LuCI.uci.html#apply">apply</a></li>
969 <li data-name="LuCI.uci#changes"><a href="LuCI.uci.html#changes">changes</a></li>
971 <li data-name="LuCI.uci#createSID"><a href="LuCI.uci.html#createSID">createSID</a></li>
973 <li data-name="LuCI.uci#get"><a href="LuCI.uci.html#get">get</a></li>
975 <li data-name="LuCI.uci#get_first"><a href="LuCI.uci.html#get_first">get_first</a></li>
977 <li data-name="LuCI.uci#load"><a href="LuCI.uci.html#load">load</a></li>
979 <li data-name="LuCI.uci#move"><a href="LuCI.uci.html#move">move</a></li>
981 <li data-name="LuCI.uci#remove"><a href="LuCI.uci.html#remove">remove</a></li>
983 <li data-name="LuCI.uci#resolveSID"><a href="LuCI.uci.html#resolveSID">resolveSID</a></li>
985 <li data-name="LuCI.uci#save"><a href="LuCI.uci.html#save">save</a></li>
987 <li data-name="LuCI.uci#sections"><a href="LuCI.uci.html#sections">sections</a></li>
989 <li data-name="LuCI.uci#set"><a href="LuCI.uci.html#set">set</a></li>
991 <li data-name="LuCI.uci#set_first"><a href="LuCI.uci.html#set_first">set_first</a></li>
993 <li data-name="LuCI.uci#unload"><a href="LuCI.uci.html#unload">unload</a></li>
995 <li data-name="LuCI.uci#unset"><a href="LuCI.uci.html#unset">unset</a></li>
997 <li data-name="LuCI.uci#unset_first"><a href="LuCI.uci.html#unset_first">unset_first</a></li>
1000 <ul class="events itemMembers">
1005 <li class="item" data-name="LuCI.view">
1006 <span class="title">
1007 <a href="LuCI.view.html">LuCI.view</a>
1010 <ul class="members itemMembers">
1013 <ul class="typedefs itemMembers">
1016 <ul class="typedefs itemMembers">
1019 <ul class="methods itemMembers">
1021 <span class="subtitle">Methods</span>
1023 <li data-name="LuCI.view#addFooter"><a href="LuCI.view.html#addFooter">addFooter</a></li>
1025 <li data-name="LuCI.view#handleReset"><a href="LuCI.view.html#handleReset">handleReset</a></li>
1027 <li data-name="LuCI.view#handleSave"><a href="LuCI.view.html#handleSave">handleSave</a></li>
1029 <li data-name="LuCI.view#handleSaveApply"><a href="LuCI.view.html#handleSaveApply">handleSaveApply</a></li>
1031 <li data-name="LuCI.view#load"><a href="LuCI.view.html#load">load</a></li>
1033 <li data-name="LuCI.view#render"><a href="LuCI.view.html#render">render</a></li>
1036 <ul class="events itemMembers">
1041 <li class="item" data-name="LuCI.XHR">
1042 <span class="title">
1043 <a href="LuCI.XHR.html">LuCI.XHR</a>
1046 <ul class="members itemMembers">
1049 <ul class="typedefs itemMembers">
1052 <ul class="typedefs itemMembers">
1055 <ul class="methods itemMembers">
1057 <span class="subtitle">Methods</span>
1059 <li data-name="LuCI.XHR#abort"><a href="LuCI.XHR.html#abort">abort</a></li>
1061 <li data-name="LuCI.XHR#busy"><a href="LuCI.XHR.html#busy">busy</a></li>
1063 <li data-name="LuCI.XHR#cancel"><a href="LuCI.XHR.html#cancel">cancel</a></li>
1065 <li data-name="LuCI.XHR#get"><a href="LuCI.XHR.html#get">get</a></li>
1067 <li data-name="LuCI.XHR#post"><a href="LuCI.XHR.html#post">post</a></li>
1069 <li data-name="LuCI.XHR#send_form"><a href="LuCI.XHR.html#send_form">send_form</a></li>
1072 <ul class="events itemMembers">
1080 <h1 class="page-title" data-filename="luci.js.html">Source: luci.js</h1>
1087 <pre id="source-code" class="prettyprint source "><code>/**
1091 * This is the LuCI base class. It is automatically instantiated and
1092 * accessible using the global `L` variable.
1094 * @param {Object} env
1095 * The environment settings to use for the LuCI runtime.
1098 (function(window, document, undefined) {
1101 /* Object.assign polyfill for IE */
1102 if (typeof Object.assign !== 'function') {
1103 Object.defineProperty(Object, 'assign', {
1104 value: function assign(target, varArgs) {
1106 throw new TypeError('Cannot convert undefined or null to object');
1108 var to = Object(target);
1110 for (var index = 1; index < arguments.length; index++)
1111 if (arguments[index] != null)
1112 for (var nextKey in arguments[index])
1113 if (Object.prototype.hasOwnProperty.call(arguments[index], nextKey))
1114 to[nextKey] = arguments[index][nextKey];
1123 /* Promise.finally polyfill */
1124 if (typeof Promise.prototype.finally !== 'function') {
1125 Promise.prototype.finally = function(fn) {
1126 var onFinally = function(cb) {
1127 return Promise.resolve(fn.call(this)).then(cb);
1131 function(result) { return onFinally.call(this, function() { return result }) },
1132 function(reason) { return onFinally.call(this, function() { return Promise.reject(reason) }) }
1138 * Class declaration and inheritance helper
1141 var toCamelCase = function(s) {
1142 return s.replace(/(?:^|[\. -])(.)/g, function(m0, m1) { return m1.toUpperCase() });
1151 * `LuCI.Class` is the abstract base class all LuCI classes inherit from.
1153 * It provides simple means to create subclasses of given classes and
1154 * implements prototypal inheritance.
1156 var superContext = {}, classIndex = 0, Class = Object.assign(function() {}, {
1158 * Extends this base class with the properties described in
1159 * `properties` and returns a new subclassed Class instance
1161 * @memberof LuCI.Class
1163 * @param {Object<string, *>} properties
1164 * An object describing the properties to add to the new
1167 * @returns {LuCI.Class}
1168 * Returns a new LuCI.Class sublassed from this class, extended
1169 * by the given properties and with its prototype set to this base
1170 * class to enable inheritance. The resulting value represents a
1171 * class constructor and can be instantiated with `new`.
1173 extend: function(properties) {
1175 __id__: { value: classIndex },
1176 __base__: { value: this.prototype },
1177 __name__: { value: properties.__name__ || 'anonymous' + classIndex++ }
1180 var ClassConstructor = function() {
1181 if (!(this instanceof ClassConstructor))
1182 throw new TypeError('Constructor must not be called without "new"');
1184 if (Object.getPrototypeOf(this).hasOwnProperty('__init__')) {
1185 if (typeof(this.__init__) != 'function')
1186 throw new TypeError('Class __init__ member is not a function');
1188 this.__init__.apply(this, arguments)
1191 this.super('__init__', arguments);
1195 for (var key in properties)
1196 if (!props[key] && properties.hasOwnProperty(key))
1197 props[key] = { value: properties[key], writable: true };
1199 ClassConstructor.prototype = Object.create(this.prototype, props);
1200 ClassConstructor.prototype.constructor = ClassConstructor;
1201 Object.assign(ClassConstructor, this);
1202 ClassConstructor.displayName = toCamelCase(props.__name__.value + 'Class');
1204 return ClassConstructor;
1208 * Extends this base class with the properties described in
1209 * `properties`, instantiates the resulting subclass using
1210 * the additional optional arguments passed to this function
1211 * and returns the resulting subclassed Class instance.
1213 * This function serves as a convenience shortcut for
1214 * {@link LuCI.Class.extend Class.extend()} and subsequent
1217 * @memberof LuCI.Class
1219 * @param {Object<string, *>} properties
1220 * An object describing the properties to add to the new
1223 * @param {...*} [new_args]
1224 * Specifies arguments to be passed to the subclass constructor
1225 * as-is in order to instantiate the new subclass.
1227 * @returns {LuCI.Class}
1228 * Returns a new LuCI.Class instance extended by the given
1229 * properties with its prototype set to this base class to
1230 * enable inheritance.
1232 singleton: function(properties /*, ... */) {
1233 return Class.extend(properties)
1234 .instantiate(Class.prototype.varargs(arguments, 1));
1238 * Calls the class constructor using `new` with the given argument
1239 * array being passed as variadic parameters to the constructor.
1241 * @memberof LuCI.Class
1243 * @param {Array<*>} params
1244 * An array of arbitrary values which will be passed as arguments
1245 * to the constructor function.
1247 * @param {...*} [new_args]
1248 * Specifies arguments to be passed to the subclass constructor
1249 * as-is in order to instantiate the new subclass.
1251 * @returns {LuCI.Class}
1252 * Returns a new LuCI.Class instance extended by the given
1253 * properties with its prototype set to this base class to
1254 * enable inheritance.
1256 instantiate: function(args) {
1257 return new (Function.prototype.bind.apply(this,
1258 Class.prototype.varargs(args, 0, null)))();
1262 call: function(self, method) {
1263 if (typeof(this.prototype[method]) != 'function')
1264 throw new ReferenceError(method + ' is not defined in class');
1266 return this.prototype[method].apply(self, self.varargs(arguments, 1));
1270 * Checks whether the given class value is a subclass of this class.
1272 * @memberof LuCI.Class
1274 * @param {LuCI.Class} classValue
1275 * The class object to test.
1277 * @returns {boolean}
1278 * Returns `true` when the given `classValue` is a subclass of this
1279 * class or `false` if the given value is not a valid class or not
1280 * a subclass of this class'.
1282 isSubclass: function(classValue) {
1283 return (classValue != null &&
1284 typeof(classValue) == 'function' &&
1285 classValue.prototype instanceof this);
1290 * Extract all values from the given argument array beginning from
1291 * `offset` and prepend any further given optional parameters to
1292 * the beginning of the resulting array copy.
1294 * @memberof LuCI.Class
1297 * @param {Array<*>} args
1298 * The array to extract the values from.
1300 * @param {number} offset
1301 * The offset from which to extract the values. An offset of `0`
1302 * would copy all values till the end.
1304 * @param {...*} [extra_args]
1305 * Extra arguments to add to prepend to the resultung array.
1307 * @returns {Array<*>}
1308 * Returns a new array consisting of the optional extra arguments
1309 * and the values extracted from the `args` array beginning with
1312 varargs: function(args, offset /*, ... */) {
1313 return Array.prototype.slice.call(arguments, 2)
1314 .concat(Array.prototype.slice.call(args, offset));
1318 * Walks up the parent class chain and looks for a class member
1319 * called `key` in any of the parent classes this class inherits
1320 * from. Returns the member value of the superclass or calls the
1321 * member as function and returns its return value when the
1322 * optional `callArgs` array is given.
1324 * This function has two signatures and is sensitive to the
1325 * amount of arguments passed to it:
1326 * - `super('key')` -
1327 * Returns the value of `key` when found within one of the
1329 * - `super('key', ['arg1', 'arg2'])` -
1330 * Calls the `key()` method with parameters `arg1` and `arg2`
1331 * when found within one of the parent classes.
1333 * @memberof LuCI.Class
1336 * @param {string} key
1337 * The name of the superclass member to retrieve.
1339 * @param {Array<*>} [callArgs]
1340 * An optional array of function call parameters to use. When
1341 * this parameter is specified, the found member value is called
1342 * as function using the values of this array as arguments.
1344 * @throws {ReferenceError}
1345 * Throws a `ReferenceError` when `callArgs` are specified and
1346 * the found member named by `key` is not a function value.
1349 * Returns the value of the found member or the return value of
1350 * the call to the found method. Returns `null` when no member
1351 * was found in the parent class chain or when the call to the
1352 * superclass method returned `null`.
1354 super: function(key, callArgs) {
1358 var slotIdx = this.__id__ + '.' + key,
1359 symStack = superContext[slotIdx],
1362 for (protoCtx = Object.getPrototypeOf(symStack ? symStack[0] : Object.getPrototypeOf(this));
1363 protoCtx != null && !protoCtx.hasOwnProperty(key);
1364 protoCtx = Object.getPrototypeOf(protoCtx)) {}
1366 if (protoCtx == null)
1369 var res = protoCtx[key];
1371 if (arguments.length > 1) {
1372 if (typeof(res) != 'function')
1373 throw new ReferenceError(key + ' is not a function in base class');
1375 if (typeof(callArgs) != 'object')
1376 callArgs = this.varargs(arguments, 1);
1379 symStack.unshift(protoCtx);
1381 superContext[slotIdx] = [ protoCtx ];
1383 res = res.apply(this, callArgs);
1385 if (symStack && symStack.length > 1)
1386 symStack.shift(protoCtx);
1388 delete superContext[slotIdx];
1395 * Returns a string representation of this class.
1398 * Returns a string representation of this class containing the
1399 * constructor functions `displayName` and describing the class
1400 * members and their respective types.
1402 toString: function() {
1403 var s = '[' + this.constructor.displayName + ']', f = true;
1404 for (var k in this) {
1405 if (this.hasOwnProperty(k)) {
1406 s += (f ? ' {\n' : '') + ' ' + k + ': ' + typeof(this[k]) + '\n';
1410 return s + (f ? '' : '}');
1422 * The `Headers` class is an internal utility class exposed in HTTP
1423 * response objects using the `response.headers` property.
1425 var Headers = Class.extend(/** @lends LuCI.Headers.prototype */ {
1426 __name__: 'LuCI.XHR.Headers',
1427 __init__: function(xhr) {
1428 var hdrs = this.headers = {};
1429 xhr.getAllResponseHeaders().split(/\r\n/).forEach(function(line) {
1430 var m = /^([^:]+):(.*)$/.exec(line);
1432 hdrs[m[1].trim().toLowerCase()] = m[2].trim();
1437 * Checks whether the given header name is present.
1438 * Note: Header-Names are case-insensitive.
1441 * @memberof LuCI.Headers
1442 * @param {string} name
1443 * The header name to check
1445 * @returns {boolean}
1446 * Returns `true` if the header name is present, `false` otherwise
1448 has: function(name) {
1449 return this.headers.hasOwnProperty(String(name).toLowerCase());
1453 * Returns the value of the given header name.
1454 * Note: Header-Names are case-insensitive.
1457 * @memberof LuCI.Headers
1458 * @param {string} name
1459 * The header name to read
1461 * @returns {string|null}
1462 * The value of the given header name or `null` if the header isn't present.
1464 get: function(name) {
1465 var key = String(name).toLowerCase();
1466 return this.headers.hasOwnProperty(key) ? this.headers[key] : null;
1476 * The `Response` class is an internal utility class representing HTTP responses.
1478 var Response = Class.extend({
1479 __name__: 'LuCI.XHR.Response',
1480 __init__: function(xhr, url, duration, headers, content) {
1482 * Describes whether the response is successful (status codes `200..299`) or not
1484 * @memberof LuCI.Response
1488 this.ok = (xhr.status >= 200 && xhr.status <= 299);
1491 * The numeric HTTP status code of the response
1493 * @memberof LuCI.Response
1497 this.status = xhr.status;
1500 * The HTTP status description message of the response
1502 * @memberof LuCI.Response
1506 this.statusText = xhr.statusText;
1509 * The HTTP headers of the response
1511 * @memberof LuCI.Response
1513 * @type {LuCI.Headers}
1515 this.headers = (headers != null) ? headers : new Headers(xhr);
1518 * The total duration of the HTTP request in milliseconds
1520 * @memberof LuCI.Response
1524 this.duration = duration;
1527 * The final URL of the request, i.e. after following redirects.
1529 * @memberof LuCI.Response
1538 if (content instanceof Blob) {
1539 this.responseBlob = content;
1540 this.responseJSON = null;
1541 this.responseText = null;
1543 else if (content != null && typeof(content) == 'object') {
1544 this.responseBlob = null;
1545 this.responseJSON = content;
1546 this.responseText = null;
1548 else if (content != null) {
1549 this.responseBlob = null;
1550 this.responseJSON = null;
1551 this.responseText = String(content);
1554 this.responseJSON = null;
1556 if (xhr.responseType == 'blob') {
1557 this.responseBlob = xhr.response;
1558 this.responseText = null;
1561 this.responseBlob = null;
1562 this.responseText = xhr.responseText;
1568 * Clones the given response object, optionally overriding the content
1569 * of the cloned instance.
1572 * @memberof LuCI.Response
1573 * @param {*} [content]
1574 * Override the content of the cloned response. Object values will be
1575 * treated as JSON response data, all other types will be converted
1576 * using `String()` and treated as response text.
1578 * @returns {LuCI.Response}
1579 * The cloned `Response` instance.
1581 clone: function(content) {
1582 var copy = new Response(this.xhr, this.url, this.duration, this.headers, content);
1585 copy.status = this.status;
1586 copy.statusText = this.statusText;
1592 * Access the response content as JSON data.
1595 * @memberof LuCI.Response
1596 * @throws {SyntaxError}
1597 * Throws `SyntaxError` if the content isn't valid JSON.
1600 * The parsed JSON data.
1603 if (this.responseJSON == null)
1604 this.responseJSON = JSON.parse(this.responseText);
1606 return this.responseJSON;
1610 * Access the response content as string.
1613 * @memberof LuCI.Response
1615 * The response content.
1618 if (this.responseText == null && this.responseJSON != null)
1619 this.responseText = JSON.stringify(this.responseJSON);
1621 return this.responseText;
1625 * Access the response content as blob.
1628 * @memberof LuCI.Response
1630 * The response content as blob.
1633 return this.responseBlob;
1638 var requestQueue = [];
1640 function isQueueableRequest(opt) {
1644 if (opt.method != 'POST' || typeof(opt.content) != 'object')
1647 if (opt.nobatch === true)
1650 var rpcBaseURL = Request.expandURL(classes.rpc.getBaseURL());
1652 return (rpcBaseURL != null && opt.url.indexOf(rpcBaseURL) == 0);
1655 function flushRequestQueue() {
1656 if (!requestQueue.length)
1659 var reqopt = Object.assign({}, requestQueue[0][0], { content: [], nobatch: true }),
1662 for (var i = 0; i < requestQueue.length; i++) {
1663 batch[i] = requestQueue[i];
1664 reqopt.content[i] = batch[i][0].content;
1667 requestQueue.length = 0;
1669 Request.request(rpcBaseURL, reqopt).then(function(reply) {
1670 var json = null, req = null;
1672 try { json = reply.json() }
1675 while ((req = batch.shift()) != null)
1676 if (Array.isArray(json) && json.length)
1677 req[2].call(reqopt, reply.clone(json.shift()));
1679 req[1].call(reqopt, new Error('No related RPC reply'));
1680 }).catch(function(error) {
1683 while ((req = batch.shift()) != null)
1684 req[1].call(reqopt, error);
1694 * The `Request` class allows initiating HTTP requests and provides utilities
1695 * for dealing with responses.
1697 var Request = Class.singleton(/** @lends LuCI.Request.prototype */ {
1698 __name__: 'LuCI.Request',
1703 * Turn the given relative URL into an absolute URL if necessary.
1706 * @memberof LuCI.Request
1707 * @param {string} url
1708 * The URL to convert.
1711 * The absolute URL derived from the given one, or the original URL
1712 * if it already was absolute.
1714 expandURL: function(url) {
1715 if (!/^(?:[^/]+:)?\/\//.test(url))
1716 url = location.protocol + '//' + location.host + url;
1722 * @typedef {Object} RequestOptions
1723 * @memberof LuCI.Request
1725 * @property {string} [method=GET]
1726 * The HTTP method to use, e.g. `GET` or `POST`.
1728 * @property {Object<string, Object|string>} [query]
1729 * Query string data to append to the URL. Non-string values of the
1730 * given object will be converted to JSON.
1732 * @property {boolean} [cache=false]
1733 * Specifies whether the HTTP response may be retrieved from cache.
1735 * @property {string} [username]
1736 * Provides a username for HTTP basic authentication.
1738 * @property {string} [password]
1739 * Provides a password for HTTP basic authentication.
1741 * @property {number} [timeout]
1742 * Specifies the request timeout in seconds.
1744 * @property {boolean} [credentials=false]
1745 * Whether to include credentials such as cookies in the request.
1747 * @property {string} [responseType=text]
1748 * Overrides the request response type. Valid values or `text` to
1749 * interpret the response as UTF-8 string or `blob` to handle the
1750 * response as binary `Blob` data.
1752 * @property {*} [content]
1753 * Specifies the HTTP message body to send along with the request.
1754 * If the value is a function, it is invoked and the return value
1755 * used as content, if it is a FormData instance, it is used as-is,
1756 * if it is an object, it will be converted to JSON, in all other
1757 * cases it is converted to a string.
1759 * @property {Object<string, string>} [header]
1760 * Specifies HTTP headers to set for the request.
1762 * @property {function} [progress]
1763 * An optional request callback function which receives ProgressEvent
1764 * instances as sole argument during the HTTP request transfer.
1768 * Initiate an HTTP request to the given target.
1771 * @memberof LuCI.Request
1772 * @param {string} target
1773 * The URL to request.
1775 * @param {LuCI.Request.RequestOptions} [options]
1776 * Additional options to configure the request.
1778 * @returns {Promise<LuCI.Response>}
1779 * The resulting HTTP response.
1781 request: function(target, options) {
1782 var state = { xhr: new XMLHttpRequest(), url: this.expandURL(target), start: Date.now() },
1783 opt = Object.assign({}, options, state),
1786 callback = this.handleReadyStateChange;
1788 return new Promise(function(resolveFn, rejectFn) {
1789 opt.xhr.onreadystatechange = callback.bind(opt, resolveFn, rejectFn);
1790 opt.method = String(opt.method || 'GET').toUpperCase();
1792 if ('query' in opt) {
1793 var q = (opt.query != null) ? Object.keys(opt.query).map(function(k) {
1794 if (opt.query[k] != null) {
1795 var v = (typeof(opt.query[k]) == 'object')
1796 ? JSON.stringify(opt.query[k])
1797 : String(opt.query[k]);
1799 return '%s=%s'.format(encodeURIComponent(k), encodeURIComponent(v));
1802 return encodeURIComponent(k);
1804 }).join('&') : '';
1807 switch (opt.method) {
1811 opt.url += ((/\?/).test(opt.url) ? '&' : '?') + q;
1815 if (content == null) {
1817 contenttype = 'application/x-www-form-urlencoded';
1824 opt.url += ((/\?/).test(opt.url) ? '&' : '?') + (new Date()).getTime();
1826 if (isQueueableRequest(opt)) {
1827 requestQueue.push([opt, rejectFn, resolveFn]);
1828 requestAnimationFrame(flushRequestQueue);
1832 if ('username' in opt && 'password' in opt)
1833 opt.xhr.open(opt.method, opt.url, true, opt.username, opt.password);
1835 opt.xhr.open(opt.method, opt.url, true);
1837 opt.xhr.responseType = opt.responseType || 'text';
1839 if ('overrideMimeType' in opt.xhr)
1840 opt.xhr.overrideMimeType('application/octet-stream');
1842 if ('timeout' in opt)
1843 opt.xhr.timeout = +opt.timeout;
1845 if ('credentials' in opt)
1846 opt.xhr.withCredentials = !!opt.credentials;
1848 if (opt.content != null) {
1849 switch (typeof(opt.content)) {
1851 content = opt.content(xhr);
1855 if (!(opt.content instanceof FormData)) {
1856 content = JSON.stringify(opt.content);
1857 contenttype = 'application/json';
1860 content = opt.content;
1865 content = String(opt.content);
1869 if ('headers' in opt)
1870 for (var header in opt.headers)
1871 if (opt.headers.hasOwnProperty(header)) {
1872 if (header.toLowerCase() != 'content-type')
1873 opt.xhr.setRequestHeader(header, opt.headers[header]);
1875 contenttype = opt.headers[header];
1878 if ('progress' in opt && 'upload' in opt.xhr)
1879 opt.xhr.upload.addEventListener('progress', opt.progress);
1881 if (contenttype != null)
1882 opt.xhr.setRequestHeader('Content-Type', contenttype);
1885 opt.xhr.send(content);
1888 rejectFn.call(opt, e);
1893 handleReadyStateChange: function(resolveFn, rejectFn, ev) {
1895 duration = Date.now() - this.start;
1897 if (xhr.readyState !== 4)
1900 if (xhr.status === 0 && xhr.statusText === '') {
1901 if (duration >= this.timeout)
1902 rejectFn.call(this, new Error('XHR request timed out'));
1904 rejectFn.call(this, new Error('XHR request aborted by browser'));
1907 var response = new Response(
1908 xhr, xhr.responseURL || this.url, duration);
1910 Promise.all(Request.interceptors.map(function(fn) { return fn(response) }))
1911 .then(resolveFn.bind(this, response))
1912 .catch(rejectFn.bind(this));
1917 * Initiate an HTTP GET request to the given target.
1920 * @memberof LuCI.Request
1921 * @param {string} target
1922 * The URL to request.
1924 * @param {LuCI.Request.RequestOptions} [options]
1925 * Additional options to configure the request.
1927 * @returns {Promise<LuCI.Response>}
1928 * The resulting HTTP response.
1930 get: function(url, options) {
1931 return this.request(url, Object.assign({ method: 'GET' }, options));
1935 * Initiate an HTTP POST request to the given target.
1938 * @memberof LuCI.Request
1939 * @param {string} target
1940 * The URL to request.
1943 * The request data to send, see {@link LuCI.Request.RequestOptions} for details.
1945 * @param {LuCI.Request.RequestOptions} [options]
1946 * Additional options to configure the request.
1948 * @returns {Promise<LuCI.Response>}
1949 * The resulting HTTP response.
1951 post: function(url, data, options) {
1952 return this.request(url, Object.assign({ method: 'POST', content: data }, options));
1956 * Interceptor functions are invoked whenever an HTTP reply is received, in the order
1957 * these functions have been registered.
1958 * @callback LuCI.Request.interceptorFn
1959 * @param {LuCI.Response} res
1960 * The HTTP response object
1964 * Register an HTTP response interceptor function. Interceptor
1965 * functions are useful to perform default actions on incoming HTTP
1966 * responses, such as checking for expired authentication or for
1967 * implementing request retries before returning a failure.
1970 * @memberof LuCI.Request
1971 * @param {LuCI.Request.interceptorFn} interceptorFn
1972 * The interceptor function to register.
1974 * @returns {LuCI.Request.interceptorFn}
1975 * The registered function.
1977 addInterceptor: function(interceptorFn) {
1978 if (typeof(interceptorFn) == 'function')
1979 this.interceptors.push(interceptorFn);
1980 return interceptorFn;
1984 * Remove an HTTP response interceptor function. The passed function
1985 * value must be the very same value that was used to register the
1989 * @memberof LuCI.Request
1990 * @param {LuCI.Request.interceptorFn} interceptorFn
1991 * The interceptor function to remove.
1993 * @returns {boolean}
1994 * Returns `true` if any function has been removed, else `false`.
1996 removeInterceptor: function(interceptorFn) {
1997 var oldlen = this.interceptors.length, i = oldlen;
1999 if (this.interceptors[i] === interceptorFn)
2000 this.interceptors.splice(i, 1);
2001 return (this.interceptors.length < oldlen);
2006 * @memberof LuCI.Request
2010 * The `Request.poll` class provides some convience wrappers around
2011 * {@link LuCI.Poll} mainly to simplify registering repeating HTTP
2012 * request calls as polling functions.
2016 * The callback function is invoked whenever an HTTP reply to a
2017 * polled request is received or when the polled request timed
2020 * @callback LuCI.Request.poll~callbackFn
2021 * @param {LuCI.Response} res
2022 * The HTTP response object.
2025 * The response JSON if the response could be parsed as such,
2028 * @param {number} duration
2029 * The total duration of the request in milliseconds.
2033 * Register a repeating HTTP request with an optional callback
2034 * to invoke whenever a response for the request is received.
2037 * @memberof LuCI.Request.poll
2038 * @param {number} interval
2039 * The poll interval in seconds.
2041 * @param {string} url
2042 * The URL to request on each poll.
2044 * @param {LuCI.Request.RequestOptions} [options]
2045 * Additional options to configure the request.
2047 * @param {LuCI.Request.poll~callbackFn} [callback]
2048 * {@link LuCI.Request.poll~callbackFn Callback} function to
2049 * invoke for each HTTP reply.
2051 * @throws {TypeError}
2052 * Throws `TypeError` when an invalid interval was passed.
2054 * @returns {function}
2055 * Returns the internally created poll function.
2057 add: function(interval, url, options, callback) {
2058 if (isNaN(interval) || interval <= 0)
2059 throw new TypeError('Invalid poll interval');
2061 var ival = interval >>> 0,
2062 opts = Object.assign({}, options, { timeout: ival * 1000 - 5 });
2064 var fn = function() {
2065 return Request.request(url, options).then(function(res) {
2070 callback(res, res.json(), res.duration);
2073 callback(res, null, res.duration);
2078 return (Poll.add(fn, ival) ? fn : null);
2082 * Remove a polling request that has been previously added using `add()`.
2083 * This function is essentially a wrapper around
2084 * {@link LuCI.Poll.remove LuCI.Poll.remove()}.
2087 * @memberof LuCI.Request.poll
2088 * @param {function} entry
2089 * The poll function returned by {@link LuCI.Request.poll#add add()}.
2091 * @returns {boolean}
2092 * Returns `true` if any function has been removed, else `false`.
2094 remove: function(entry) { return Poll.remove(entry) },
2097 * Alias for {@link LuCI.Poll.start LuCI.Poll.start()}.
2100 * @memberof LuCI.Request.poll
2102 start: function() { return Poll.start() },
2105 * Alias for {@link LuCI.Poll.stop LuCI.Poll.stop()}.
2108 * @memberof LuCI.Request.poll
2110 stop: function() { return Poll.stop() },
2113 * Alias for {@link LuCI.Poll.active LuCI.Poll.active()}.
2116 * @memberof LuCI.Request.poll
2118 active: function() { return Poll.active() }
2128 * The `Poll` class allows registering and unregistering poll actions,
2129 * as well as starting, stopping and querying the state of the polling
2132 var Poll = Class.singleton(/** @lends LuCI.Poll.prototype */ {
2133 __name__: 'LuCI.Poll',
2138 * Add a new operation to the polling loop. If the polling loop is not
2139 * already started at this point, it will be implicitely started.
2142 * @memberof LuCI.Poll
2143 * @param {function} fn
2144 * The function to invoke on each poll interval.
2146 * @param {number} interval
2147 * The poll interval in seconds.
2149 * @throws {TypeError}
2150 * Throws `TypeError` when an invalid interval was passed.
2152 * @returns {boolean}
2153 * Returns `true` if the function has been added or `false` if it
2154 * already is registered.
2156 add: function(fn, interval) {
2157 if (interval == null || interval <= 0)
2158 interval = window.L ? window.L.env.pollinterval : null;
2160 if (isNaN(interval) || typeof(fn) != 'function')
2161 throw new TypeError('Invalid argument to LuCI.Poll.add()');
2163 for (var i = 0; i < this.queue.length; i++)
2164 if (this.queue[i].fn === fn)
2175 if (this.tick != null && !this.active())
2182 * Remove an operation from the polling loop. If no further operatons
2183 * are registered, the polling loop is implicitely stopped.
2186 * @memberof LuCI.Poll
2187 * @param {function} fn
2188 * The function to remove.
2190 * @throws {TypeError}
2191 * Throws `TypeError` when the given argument isn't a function.
2193 * @returns {boolean}
2194 * Returns `true` if the function has been removed or `false` if it
2197 remove: function(fn) {
2198 if (typeof(fn) != 'function')
2199 throw new TypeError('Invalid argument to LuCI.Poll.remove()');
2201 var len = this.queue.length;
2203 for (var i = len; i > 0; i--)
2204 if (this.queue[i-1].fn === fn)
2205 this.queue.splice(i-1, 1);
2207 if (!this.queue.length && this.stop())
2210 return (this.queue.length != len);
2214 * (Re)start the polling loop. Dispatches a custom `poll-start` event
2215 * to the `document` object upon successful start.
2218 * @memberof LuCI.Poll
2219 * @returns {boolean}
2220 * Returns `true` if polling has been started (or if no functions
2221 * where registered) or `false` when the polling loop already runs.
2229 if (this.queue.length) {
2230 this.timer = window.setInterval(this.step, 1000);
2232 document.dispatchEvent(new CustomEvent('poll-start'));
2239 * Stop the polling loop. Dispatches a custom `poll-stop` event
2240 * to the `document` object upon successful stop.
2243 * @memberof LuCI.Poll
2244 * @returns {boolean}
2245 * Returns `true` if polling has been stopped or `false` if it din't
2246 * run to begin with.
2252 document.dispatchEvent(new CustomEvent('poll-stop'));
2253 window.clearInterval(this.timer);
2261 for (var i = 0, e = null; (e = Poll.queue[i]) != null; i++) {
2262 if ((Poll.tick % e.i) != 0)
2270 Promise.resolve(e.fn()).finally((function() { this.r = true }).bind(e));
2273 Poll.tick = (Poll.tick + 1) % Math.pow(2, 32);
2277 * Test whether the polling loop is running.
2280 * @memberof LuCI.Poll
2281 * @returns {boolean} - Returns `true` if polling is active, else `false`.
2283 active: function() {
2284 return (this.timer != null);
2289 var dummyElem = null,
2291 originalCBIInit = null,
2296 var LuCI = Class.extend(/** @lends LuCI.prototype */ {
2298 __init__: function(env) {
2300 document.querySelectorAll('script[src*="/luci.js"]').forEach(function(s) {
2301 if (env.base_url == null || env.base_url == '') {
2302 var m = (s.getAttribute('src') || '').match(/^(.*)\/luci\.js(?:\?v=([^?]+))?$/);
2304 env.base_url = m[1];
2305 env.resource_version = m[2];
2310 if (env.base_url == null)
2311 this.error('InternalError', 'Cannot find url of luci.js');
2313 env.cgi_base = env.scriptname.replace(/\/[^\/]+$/, '');
2315 Object.assign(this.env, env);
2317 document.addEventListener('poll-start', function(ev) {
2318 document.querySelectorAll('[id^="xhr_poll_status"]').forEach(function(e) {
2319 e.style.display = (e.id == 'xhr_poll_status_off') ? 'none' : '';
2323 document.addEventListener('poll-stop', function(ev) {
2324 document.querySelectorAll('[id^="xhr_poll_status"]').forEach(function(e) {
2325 e.style.display = (e.id == 'xhr_poll_status_on') ? 'none' : '';
2329 var domReady = new Promise(function(resolveFn, rejectFn) {
2330 document.addEventListener('DOMContentLoaded', resolveFn);
2336 this.require('rpc'),
2337 this.require('form'),
2338 this.probeRPCBaseURL()
2339 ]).then(this.setupDOM.bind(this)).catch(this.error);
2341 originalCBIInit = window.cbi_init;
2342 window.cbi_init = function() {};
2346 * Captures the current stack trace and throws an error of the
2347 * specified type as a new exception. Also logs the exception as
2348 * error to the debug console if it is available.
2353 * @param {Error|string} [type=Error]
2354 * Either a string specifying the type of the error to throw or an
2355 * existing `Error` instance to copy.
2357 * @param {string} [fmt=Unspecified error]
2358 * A format string which is used to form the error message, together
2359 * with all subsequent optional arguments.
2361 * @param {...*} [args]
2362 * Zero or more variable arguments to the supplied format string.
2365 * Throws the created error object with the captured stack trace
2366 * appended to the message and the type set to the given type
2367 * argument or copied from the given error instance.
2369 raise: function(type, fmt /*, ...*/) {
2371 msg = fmt ? String.prototype.format.apply(fmt, this.varargs(arguments, 2)) : null,
2374 if (type instanceof Error) {
2378 e.message = msg + ': ' + e.message;
2381 try { throw new Error('stacktrace') }
2382 catch (e2) { stack = (e2.stack || '').split(/\n/) }
2384 e = new (window[type || 'Error'] || Error)(msg || 'Unspecified error');
2385 e.name = type || 'Error';
2388 stack = (stack || []).map(function(frame) {
2389 frame = frame.replace(/(.*?)@(.+):(\d+):(\d+)/g, 'at $1 ($2:$3:$4)').trim();
2390 return frame ? ' ' + frame : '';
2393 if (!/^ at /.test(stack[0]))
2396 if (/\braise /.test(stack[0]))
2399 if (/\berror /.test(stack[0]))
2403 e.message += '\n' + stack.join('\n');
2405 if (window.console && console.debug)
2412 * A wrapper around {@link LuCI#raise raise()} which also renders
2413 * the error either as modal overlay when `ui.js` is already loaed
2414 * or directly into the view body.
2419 * @param {Error|string} [type=Error]
2420 * Either a string specifying the type of the error to throw or an
2421 * existing `Error` instance to copy.
2423 * @param {string} [fmt=Unspecified error]
2424 * A format string which is used to form the error message, together
2425 * with all subsequent optional arguments.
2427 * @param {...*} [args]
2428 * Zero or more variable arguments to the supplied format string.
2431 * Throws the created error object with the captured stack trace
2432 * appended to the message and the type set to the given type
2433 * argument or copied from the given error instance.
2435 error: function(type, fmt /*, ...*/) {
2437 L.raise.apply(L, Array.prototype.slice.call(arguments));
2442 L.ui.addNotification(e.name || _('Runtime error'),
2443 E('pre', {}, e.message), 'danger');
2445 L.dom.content(document.querySelector('#maincontent'),
2446 E('pre', { 'class': 'alert-message error' }, e.message));
2456 * Return a bound function using the given `self` as `this` context
2457 * and any further arguments as parameters to the bound function.
2462 * @param {function} fn
2463 * The function to bind.
2466 * The value to bind as `this` context to the specified function.
2468 * @param {...*} [args]
2469 * Zero or more variable arguments which are bound to the function
2472 * @returns {function}
2473 * Returns the bound function.
2475 bind: function(fn, self /*, ... */) {
2476 return Function.prototype.bind.apply(fn, this.varargs(arguments, 2, self));
2480 * Load an additional LuCI JavaScript class and its dependencies,
2481 * instantiate it and return the resulting class instance. Each
2482 * class is only loaded once. Subsequent attempts to load the same
2483 * class will return the already instantiated class.
2488 * @param {string} name
2489 * The name of the class to load in dotted notation. Dots will
2490 * be replaced by spaces and joined with the runtime-determined
2491 * base URL of LuCI.js to form an absolute URL to load the class
2494 * @throws {DependencyError}
2495 * Throws a `DependencyError` when the class to load includes
2496 * circular dependencies.
2498 * @throws {NetworkError}
2499 * Throws `NetworkError` when the underlying {@link LuCI.Request}
2502 * @throws {SyntaxError}
2503 * Throws `SyntaxError` when the loaded class file code cannot
2504 * be interpreted by `eval`.
2506 * @throws {TypeError}
2507 * Throws `TypeError` when the class file could be loaded and
2508 * interpreted, but when invoking its code did not yield a valid
2511 * @returns {Promise<LuCI#Class>}
2512 * Returns the instantiated class.
2514 require: function(name, from) {
2515 var L = this, url = null, from = from || [];
2517 /* Class already loaded */
2518 if (classes[name] != null) {
2519 /* Circular dependency */
2520 if (from.indexOf(name) != -1)
2521 L.raise('DependencyError',
2522 'Circular dependency: class "%s" depends on "%s"',
2523 name, from.join('" which depends on "'));
2525 return Promise.resolve(classes[name]);
2528 url = '%s/%s.js%s'.format(L.env.base_url, name.replace(/\./g, '/'), (L.env.resource_version ? '?v=' + L.env.resource_version : ''));
2529 from = [ name ].concat(from);
2531 var compileClass = function(res) {
2533 L.raise('NetworkError',
2534 'HTTP error %d while loading class file "%s"', res.status, url);
2536 var source = res.text(),
2537 requirematch = /^require[ \t]+(\S+)(?:[ \t]+as[ \t]+([a-zA-Z_]\S*))?$/,
2538 strictmatch = /^use[ \t]+strict$/,
2542 /* find require statements in source */
2543 for (var i = 0, off = -1, quote = -1, esc = false; i < source.length; i++) {
2544 var chr = source.charCodeAt(i);
2549 else if (chr == 92) {
2552 else if (chr == quote) {
2553 var s = source.substring(off, i),
2554 m = requirematch.exec(s);
2557 var dep = m[1], as = m[2] || dep.replace(/[^a-zA-Z0-9_]/g, '_');
2558 depends.push(L.require(dep, from));
2561 else if (!strictmatch.exec(s)) {
2568 else if (quote == -1 && (chr == 34 || chr == 39)) {
2574 /* load dependencies and instantiate class */
2575 return Promise.all(depends).then(function(instances) {
2576 var _factory, _class;
2580 '(function(window, document, L%s) { %s })\n\n//# sourceURL=%s\n'
2581 .format(args, source, res.url));
2584 L.raise('SyntaxError', '%s\n in %s:%s',
2585 error.message, res.url, error.lineNumber || '?');
2588 _factory.displayName = toCamelCase(name + 'ClassFactory');
2589 _class = _factory.apply(_factory, [window, document, L].concat(instances));
2591 if (!Class.isSubclass(_class))
2592 L.error('TypeError', '"%s" factory yields invalid constructor', name);
2594 if (_class.displayName == 'AnonymousClass')
2595 _class.displayName = toCamelCase(name + 'Class');
2597 var ptr = Object.getPrototypeOf(L),
2598 parts = name.split(/\./),
2599 instance = new _class();
2601 for (var i = 0; ptr && i < parts.length - 1; i++)
2602 ptr = ptr[parts[i]];
2605 ptr[parts[i]] = instance;
2607 classes[name] = instance;
2613 /* Request class file */
2614 classes[name] = Request.get(url, { cache: true }).then(compileClass);
2616 return classes[name];
2620 probeRPCBaseURL: function() {
2621 if (rpcBaseURL == null) {
2623 rpcBaseURL = window.sessionStorage.getItem('rpcBaseURL');
2628 if (rpcBaseURL == null) {
2629 var rpcFallbackURL = this.url('admin/ubus');
2631 rpcBaseURL = Request.get(this.env.ubuspath).then(function(res) {
2632 return (rpcBaseURL = (res.status == 400) ? L.env.ubuspath : rpcFallbackURL);
2634 return (rpcBaseURL = rpcFallbackURL);
2635 }).then(function(url) {
2637 window.sessionStorage.setItem('rpcBaseURL', url);
2645 return Promise.resolve(rpcBaseURL);
2648 probeSystemFeatures: function() {
2649 var sessionid = classes.rpc.getSessionID();
2651 if (sysFeatures == null) {
2653 var data = JSON.parse(window.sessionStorage.getItem('sysFeatures'));
2655 if (this.isObject(data) && this.isObject(data[sessionid]))
2656 sysFeatures = data[sessionid];
2661 if (!this.isObject(sysFeatures)) {
2662 sysFeatures = classes.rpc.declare({
2664 method: 'getFeatures',
2666 })().then(function(features) {
2669 data[sessionid] = features;
2671 window.sessionStorage.setItem('sysFeatures', JSON.stringify(data));
2675 sysFeatures = features;
2681 return Promise.resolve(sysFeatures);
2685 * Test whether a particular system feature is available, such as
2686 * hostapd SAE support or an installed firewall. The features are
2687 * queried once at the beginning of the LuCI session and cached in
2688 * `SessionStorage` throughout the lifetime of the associated tab or
2694 * @param {string} feature
2695 * The feature to test. For detailed list of known feature flags,
2696 * see `/modules/luci-base/root/usr/libexec/rpcd/luci`.
2698 * @param {string} [subfeature]
2699 * Some feature classes like `hostapd` provide sub-feature flags,
2700 * such as `sae` or `11w` support. The `subfeature` argument can
2701 * be used to query these.
2703 * @return {boolean|null}
2704 * Return `true` if the queried feature (and sub-feature) is available
2705 * or `false` if the requested feature isn't present or known.
2706 * Return `null` when a sub-feature was queried for a feature which
2707 * has no sub-features.
2709 hasSystemFeature: function() {
2710 var ft = sysFeatures[arguments[0]];
2712 if (arguments.length == 2)
2713 return this.isObject(ft) ? ft[arguments[1]] : null;
2715 return (ft != null && ft != false);
2719 notifySessionExpiry: function() {
2722 L.ui.showModal(_('Session expired'), [
2723 E('div', { class: 'alert-message warning' },
2724 _('A new login is required since the authentication session expired.')),
2725 E('div', { class: 'right' },
2727 class: 'btn primary',
2729 var loc = window.location;
2730 window.location = loc.protocol + '//' + loc.host + loc.pathname + loc.search;
2732 }, _('To login…')))
2735 L.raise('SessionError', 'Login session is expired');
2739 setupDOM: function(res) {
2744 rpcBaseURL = res[4];
2746 rpcClass.setBaseURL(rpcBaseURL);
2748 rpcClass.addInterceptor(function(msg, req) {
2749 if (!L.isObject(msg) || !L.isObject(msg.error) || msg.error.code != -32002)
2752 if (!L.isObject(req) || (req.object == 'session' && req.method == 'access'))
2755 return rpcClass.declare({
2756 'object': 'session',
2758 'params': [ 'scope', 'object', 'function' ],
2759 'expect': { access: true }
2760 })('uci', 'luci', 'read').catch(L.notifySessionExpiry);
2763 Request.addInterceptor(function(res) {
2764 var isDenied = false;
2766 if (res.status == 403 && res.headers.get('X-LuCI-Login-Required') == 'yes')
2772 L.notifySessionExpiry();
2775 return this.probeSystemFeatures().finally(this.initDOM);
2779 initDOM: function() {
2782 document.dispatchEvent(new CustomEvent('luci-loaded'));
2786 * The `env` object holds environment settings used by LuCI, such
2787 * as request timeouts, base URLs etc.
2795 * Construct a relative URL path from the given prefix and parts.
2796 * The resulting URL is guaranteed to only contain the characters
2797 * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well
2798 * as `/` for the path separator.
2803 * @param {string} [prefix]
2804 * The prefix to join the given parts with. If the `prefix` is
2805 * omitted, it defaults to an empty string.
2807 * @param {string[]} [parts]
2808 * An array of parts to join into an URL path. Parts may contain
2809 * slashes and any of the other characters mentioned above.
2812 * Return the joined URL path.
2814 path: function(prefix, parts) {
2815 var url = [ prefix || '' ];
2817 for (var i = 0; i < parts.length; i++)
2818 if (/^(?:[a-zA-Z0-9_.%,;-]+\/)*[a-zA-Z0-9_.%,;-]+$/.test(parts[i]))
2819 url.push('/', parts[i]);
2821 if (url.length === 1)
2824 return url.join('');
2828 * Construct an URL pathrelative to the script path of the server
2829 * side LuCI application (usually `/cgi-bin/luci`).
2831 * The resulting URL is guaranteed to only contain the characters
2832 * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well
2833 * as `/` for the path separator.
2838 * @param {string[]} [parts]
2839 * An array of parts to join into an URL path. Parts may contain
2840 * slashes and any of the other characters mentioned above.
2843 * Returns the resulting URL path.
2846 return this.path(this.env.scriptname, arguments);
2850 * Construct an URL path relative to the global static resource path
2851 * of the LuCI ui (usually `/luci-static/resources`).
2853 * The resulting URL is guaranteed to only contain the characters
2854 * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well
2855 * as `/` for the path separator.
2860 * @param {string[]} [parts]
2861 * An array of parts to join into an URL path. Parts may contain
2862 * slashes and any of the other characters mentioned above.
2865 * Returns the resulting URL path.
2867 resource: function() {
2868 return this.path(this.env.resource, arguments);
2872 * Construct an URL path relative to the media resource path of the
2873 * LuCI ui (usually `/luci-static/$theme_name`).
2875 * The resulting URL is guaranteed to only contain the characters
2876 * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well
2877 * as `/` for the path separator.
2882 * @param {string[]} [parts]
2883 * An array of parts to join into an URL path. Parts may contain
2884 * slashes and any of the other characters mentioned above.
2887 * Returns the resulting URL path.
2890 return this.path(this.env.media, arguments);
2894 * Return the complete URL path to the current view.
2900 * Returns the URL path to the current view.
2902 location: function() {
2903 return this.path(this.env.scriptname, this.env.requestpath);
2908 * Tests whether the passed argument is a JavaScript object.
2909 * This function is meant to be an object counterpart to the
2910 * standard `Array.isArray()` function.
2919 * Returns `true` if the given value is of type object and
2920 * not `null`, else returns `false`.
2922 isObject: function(val) {
2923 return (val != null && typeof(val) == 'object');
2927 * Return an array of sorted object keys, optionally sorted by
2928 * a different key or a different sorting mode.
2933 * @param {object} obj
2934 * The object to extract the keys from. If the given value is
2935 * not an object, the function will return an empty array.
2937 * @param {string} [key]
2938 * Specifies the key to order by. This is mainly useful for
2939 * nested objects of objects or objects of arrays when sorting
2940 * shall not be performed by the primary object keys but by
2941 * some other key pointing to a value within the nested values.
2943 * @param {string} [sortmode]
2944 * May be either `addr` or `num` to override the natural
2945 * lexicographic sorting with a sorting suitable for IP/MAC style
2946 * addresses or numeric values respectively.
2948 * @return {string[]}
2949 * Returns an array containing the sorted keys of the given object.
2951 sortedKeys: function(obj, key, sortmode) {
2952 if (obj == null || typeof(obj) != 'object')
2955 return Object.keys(obj).map(function(e) {
2956 var v = (key != null) ? obj[e][key] : e;
2960 v = (v != null) ? v.replace(/(?:^|[.:])([0-9a-fA-F]{1,4})/g,
2961 function(m0, m1) { return ('000' + m1.toLowerCase()).substr(-4) }) : null;
2965 v = (v != null) ? +v : null;
2970 }).filter(function(e) {
2971 return (e[1] != null);
2972 }).sort(function(a, b) {
2973 return (a[1] > b[1]);
2974 }).map(function(e) {
2980 * Converts the given value to an array. If the given value is of
2981 * type array, it is returned as-is, values of type object are
2982 * returned as one-element array containing the object, empty
2983 * strings and `null` values are returned as empty array, all other
2984 * values are converted using `String()`, trimmed, split on white
2985 * space and returned as array.
2991 * The value to convert into an array.
2993 * @return {Array<*>}
2994 * Returns the resulting array.
2996 toArray: function(val) {
2999 else if (Array.isArray(val))
3001 else if (typeof(val) == 'object')
3004 var s = String(val).trim();
3009 return s.split(/\s+/);
3013 * Returns a promise resolving with either the given value or or with
3014 * the given default in case the input value is a rejecting promise.
3020 * The value to resolve the promise with.
3022 * @param {*} defvalue
3023 * The default value to resolve the promise with in case the given
3024 * input value is a rejecting promise.
3026 * @returns {Promise<*>}
3027 * Returns a new promise resolving either to the given input value or
3028 * to the given default value on error.
3030 resolveDefault: function(value, defvalue) {
3031 return Promise.resolve(value).catch(function() { return defvalue });
3035 * The request callback function is invoked whenever an HTTP
3036 * reply to a request made using the `L.get()`, `L.post()` or
3037 * `L.poll()` function is timed out or received successfully.
3042 * @callback LuCI.requestCallbackFn
3043 * @param {XMLHTTPRequest} xhr
3044 * The XMLHTTPRequest instance used to make the request.
3047 * The response JSON if the response could be parsed as such,
3050 * @param {number} duration
3051 * The total duration of the request in milliseconds.
3055 * Issues a GET request to the given url and invokes the specified
3056 * callback function. The function is a wrapper around
3057 * {@link LuCI.Request#request Request.request()}.
3063 * @param {string} url
3064 * The URL to request.
3066 * @param {Object<string, string>} [args]
3067 * Additional query string arguments to append to the URL.
3069 * @param {LuCI.requestCallbackFn} cb
3070 * The callback function to invoke when the request finishes.
3072 * @return {Promise<null>}
3073 * Returns a promise resolving to `null` when concluded.
3075 get: function(url, args, cb) {
3076 return this.poll(null, url, args, cb, false);
3080 * Issues a POST request to the given url and invokes the specified
3081 * callback function. The function is a wrapper around
3082 * {@link LuCI.Request#request Request.request()}. The request is
3083 * sent using `application/x-www-form-urlencoded` encoding and will
3084 * contain a field `token` with the current value of `LuCI.env.token`
3091 * @param {string} url
3092 * The URL to request.
3094 * @param {Object<string, string>} [args]
3095 * Additional post arguments to append to the request body.
3097 * @param {LuCI.requestCallbackFn} cb
3098 * The callback function to invoke when the request finishes.
3100 * @return {Promise<null>}
3101 * Returns a promise resolving to `null` when concluded.
3103 post: function(url, args, cb) {
3104 return this.poll(null, url, args, cb, true);
3108 * Register a polling HTTP request that invokes the specified
3109 * callback function. The function is a wrapper around
3110 * {@link LuCI.Request.poll#add Request.poll.add()}.
3116 * @param {number} interval
3117 * The poll interval to use. If set to a value less than or equal
3118 * to `0`, it will default to the global poll interval configured
3119 * in `LuCI.env.pollinterval`.
3121 * @param {string} url
3122 * The URL to request.
3124 * @param {Object<string, string>} [args]
3125 * Specifies additional arguments for the request. For GET requests,
3126 * the arguments are appended to the URL as query string, for POST
3127 * requests, they'll be added to the request body.
3129 * @param {LuCI.requestCallbackFn} cb
3130 * The callback function to invoke whenever a request finishes.
3132 * @param {boolean} [post=false]
3133 * When set to `false` or not specified, poll requests will be made
3134 * using the GET method. When set to `true`, POST requests will be
3135 * issued. In case of POST requests, the request body will contain
3136 * an argument `token` with the current value of `LuCI.env.token` by
3137 * default, regardless of the parameters specified with `args`.
3139 * @return {function}
3140 * Returns the internally created function that has been passed to
3141 * {@link LuCI.Request.poll#add Request.poll.add()}. This value can
3142 * be passed to {@link LuCI.Poll.remove Poll.remove()} to remove the
3145 poll: function(interval, url, args, cb, post) {
3146 if (interval !== null && interval <= 0)
3147 interval = this.env.pollinterval;
3149 var data = post ? { token: this.env.token } : null,
3150 method = post ? 'POST' : 'GET';
3152 if (!/^(?:\/|\S+:\/\/)/.test(url))
3153 url = this.url(url);
3156 data = Object.assign(data || {}, args);
3158 if (interval !== null)
3159 return Request.poll.add(interval, url, { method: method, query: data }, cb);
3161 return Request.request(url, { method: method, query: data })
3162 .then(function(res) {
3164 if (/^application\/json\b/.test(res.headers.get('Content-Type')))
3165 try { json = res.json() } catch(e) {}
3166 cb(res.xhr, json, res.duration);
3171 * Deprecated wrapper around {@link LuCI.Poll.remove Poll.remove()}.
3177 * @param {function} entry
3178 * The polling function to remove.
3181 * Returns `true` when the function has been removed or `false` if
3182 * it could not be found.
3184 stop: function(entry) { return Poll.remove(entry) },
3187 * Deprecated wrapper around {@link LuCI.Poll.stop Poll.stop()}.
3194 * Returns `true` when the polling loop has been stopped or `false`
3195 * when it didn't run to begin with.
3197 halt: function() { return Poll.stop() },
3200 * Deprecated wrapper around {@link LuCI.Poll.start Poll.start()}.
3207 * Returns `true` when the polling loop has been started or `false`
3208 * when it was already running.
3210 run: function() { return Poll.start() },
3219 * The `dom` class provides convenience method for creating and
3220 * manipulating DOM elements.
3222 dom: Class.singleton(/* @lends LuCI.dom.prototype */ {
3223 __name__: 'LuCI.DOM',
3226 * Tests whether the given argument is a valid DOM `Node`.
3229 * @memberof LuCI.dom
3231 * The value to test.
3233 * @returns {boolean}
3234 * Returns `true` if the value is a DOM `Node`, else `false`.
3237 return (e != null && typeof(e) == 'object' && 'nodeType' in e);
3241 * Parses a given string as HTML and returns the first child node.
3244 * @memberof LuCI.dom
3246 * A string containing an HTML fragment to parse. Note that only
3247 * the first result of the resulting structure is returned, so an
3248 * input value of `<div>foo</div> <div>bar</div>` will only return
3249 * the first `div` element node.
3252 * Returns the first DOM `Node` extracted from the HTML fragment or
3253 * `null` on parsing failures or if no element could be found.
3255 parse: function(s) {
3259 domParser = domParser || new DOMParser();
3260 elem = domParser.parseFromString(s, 'text/html').body.firstChild;
3266 dummyElem = dummyElem || document.createElement('div');
3267 dummyElem.innerHTML = s;
3268 elem = dummyElem.firstChild;
3273 return elem || null;
3277 * Tests whether a given `Node` matches the given query selector.
3279 * This function is a convenience wrapper around the standard
3280 * `Node.matches("selector")` function with the added benefit that
3281 * the `node` argument may be a non-`Node` value, in which case
3282 * this function simply returns `false`.
3285 * @memberof LuCI.dom
3287 * The `Node` argument to test the selector against.
3289 * @param {string} [selector]
3290 * The query selector expression to test against the given node.
3292 * @returns {boolean}
3293 * Returns `true` if the given node matches the specified selector
3294 * or `false` when the node argument is no valid DOM `Node` or the
3295 * selector didn't match.
3297 matches: function(node, selector) {
3298 var m = this.elem(node) ? node.matches || node.msMatchesSelector : null;
3299 return m ? m.call(node, selector) : false;
3303 * Returns the closest parent node that matches the given query
3304 * selector expression.
3306 * This function is a convenience wrapper around the standard
3307 * `Node.closest("selector")` function with the added benefit that
3308 * the `node` argument may be a non-`Node` value, in which case
3309 * this function simply returns `null`.
3312 * @memberof LuCI.dom
3314 * The `Node` argument to find the closest parent for.
3316 * @param {string} [selector]
3317 * The query selector expression to test against each parent.
3319 * @returns {Node|null}
3320 * Returns the closest parent node matching the selector or
3321 * `null` when the node argument is no valid DOM `Node` or the
3322 * selector didn't match any parent.
3324 parent: function(node, selector) {
3325 if (this.elem(node) && node.closest)
3326 return node.closest(selector);
3328 while (this.elem(node))
3329 if (this.matches(node, selector))
3332 node = node.parentNode;
3338 * Appends the given children data to the given node.
3341 * @memberof LuCI.dom
3343 * The `Node` argument to append the children to.
3345 * @param {*} [children]
3346 * The childrens to append to the given node.
3348 * When `children` is an array, then each item of the array
3349 * will be either appended as child element or text node,
3350 * depending on whether the item is a DOM `Node` instance or
3351 * some other non-`null` value. Non-`Node`, non-`null` values
3352 * will be converted to strings first before being passed as
3353 * argument to `createTextNode()`.
3355 * When `children` is a function, it will be invoked with
3356 * the passed `node` argument as sole parameter and the `append`
3357 * function will be invoked again, with the given `node` argument
3358 * as first and the return value of the `children` function as
3361 * When `children` is is a DOM `Node` instance, it will be
3362 * appended to the given `node`.
3364 * When `children` is any other non-`null` value, it will be
3365 * converted to a string and appened to the `innerHTML` property
3366 * of the given `node`.
3368 * @returns {Node|null}
3369 * Returns the last children `Node` appended to the node or `null`
3370 * if either the `node` argument was no valid DOM `node` or if the
3371 * `children` was `null` or didn't result in further DOM nodes.
3373 append: function(node, children) {
3374 if (!this.elem(node))
3377 if (Array.isArray(children)) {
3378 for (var i = 0; i < children.length; i++)
3379 if (this.elem(children[i]))
3380 node.appendChild(children[i]);
3381 else if (children !== null && children !== undefined)
3382 node.appendChild(document.createTextNode('' + children[i]));
3384 return node.lastChild;
3386 else if (typeof(children) === 'function') {
3387 return this.append(node, children(node));
3389 else if (this.elem(children)) {
3390 return node.appendChild(children);
3392 else if (children !== null && children !== undefined) {
3393 node.innerHTML = '' + children;
3394 return node.lastChild;
3401 * Replaces the content of the given node with the given children.
3403 * This function first removes any children of the given DOM
3404 * `Node` and then adds the given given children following the
3405 * rules outlined below.
3408 * @memberof LuCI.dom
3410 * The `Node` argument to replace the children of.
3412 * @param {*} [children]
3413 * The childrens to replace into the given node.
3415 * When `children` is an array, then each item of the array
3416 * will be either appended as child element or text node,
3417 * depending on whether the item is a DOM `Node` instance or
3418 * some other non-`null` value. Non-`Node`, non-`null` values
3419 * will be converted to strings first before being passed as
3420 * argument to `createTextNode()`.
3422 * When `children` is a function, it will be invoked with
3423 * the passed `node` argument as sole parameter and the `append`
3424 * function will be invoked again, with the given `node` argument
3425 * as first and the return value of the `children` function as
3428 * When `children` is is a DOM `Node` instance, it will be
3429 * appended to the given `node`.
3431 * When `children` is any other non-`null` value, it will be
3432 * converted to a string and appened to the `innerHTML` property
3433 * of the given `node`.
3435 * @returns {Node|null}
3436 * Returns the last children `Node` appended to the node or `null`
3437 * if either the `node` argument was no valid DOM `node` or if the
3438 * `children` was `null` or didn't result in further DOM nodes.
3440 content: function(node, children) {
3441 if (!this.elem(node))
3444 var dataNodes = node.querySelectorAll('[data-idref]');
3446 for (var i = 0; i < dataNodes.length; i++)
3447 delete this.registry[dataNodes[i].getAttribute('data-idref')];
3449 while (node.firstChild)
3450 node.removeChild(node.firstChild);
3452 return this.append(node, children);
3456 * Sets attributes or registers event listeners on element nodes.
3459 * @memberof LuCI.dom
3461 * The `Node` argument to set the attributes or add the event
3462 * listeners for. When the given `node` value is not a valid
3463 * DOM `Node`, the function returns and does nothing.
3465 * @param {string|Object<string, *>} key
3466 * Specifies either the attribute or event handler name to use,
3467 * or an object containing multiple key, value pairs which are
3468 * each added to the node as either attribute or event handler,
3469 * depending on the respective value.
3472 * Specifies the attribute value or event handler function to add.
3473 * If the `key` parameter is an `Object`, this parameter will be
3476 * When `val` is of type function, it will be registered as event
3477 * handler on the given `node` with the `key` parameter being the
3480 * When `val` is of type object, it will be serialized as JSON and
3481 * added as attribute to the given `node`, using the given `key`
3482 * as attribute name.
3484 * When `val` is of any other type, it will be added as attribute
3485 * to the given `node` as-is, with the underlying `setAttribute()`
3486 * call implicitely turning it into a string.
3488 attr: function(node, key, val) {
3489 if (!this.elem(node))
3494 if (typeof(key) === 'object' && key !== null)
3496 else if (typeof(key) === 'string')
3497 attr = {}, attr[key] = val;
3500 if (!attr.hasOwnProperty(key) || attr[key] == null)
3503 switch (typeof(attr[key])) {
3505 node.addEventListener(key, attr[key]);
3509 node.setAttribute(key, JSON.stringify(attr[key]));
3513 node.setAttribute(key, attr[key]);
3519 * Creates a new DOM `Node` from the given `html`, `attr` and
3520 * `data` parameters.
3522 * This function has multiple signatures, it can be either invoked
3523 * in the form `create(html[, attr[, data]])` or in the form
3524 * `create(html[, data])`. The used variant is determined from the
3525 * type of the second argument.
3528 * @memberof LuCI.dom
3530 * Describes the node to create.
3532 * When the value of `html` is of type array, a `DocumentFragment`
3533 * node is created and each item of the array is first converted
3534 * to a DOM `Node` by passing it through `create()` and then added
3535 * as child to the fragment.
3537 * When the value of `html` is a DOM `Node` instance, no new
3538 * element will be created but the node will be used as-is.
3540 * When the value of `html` is a string starting with `<`, it will
3541 * be passed to `dom.parse()` and the resulting value is used.
3543 * When the value of `html` is any other string, it will be passed
3544 * to `document.createElement()` for creating a new DOM `Node` of
3547 * @param {Object<string, *>} [attr]
3548 * Specifies an Object of key, value pairs to set as attributes
3549 * or event handlers on the created node. Refer to
3550 * {@link LuCI.dom#attr dom.attr()} for details.
3553 * Specifies children to append to the newly created element.
3554 * Refer to {@link LuCI.dom#append dom.append()} for details.
3556 * @throws {InvalidCharacterError}
3557 * Throws an `InvalidCharacterError` when the given `html`
3558 * argument contained malformed markup (such as not escaped
3559 * `&` characters in XHTML mode) or when the given node name
3560 * in `html` contains characters which are not legal in DOM
3561 * element names, such as spaces.
3564 * Returns the newly created `Node`.
3566 create: function() {
3567 var html = arguments[0],
3568 attr = arguments[1],
3569 data = arguments[2],
3572 if (!(attr instanceof Object) || Array.isArray(attr))
3573 data = attr, attr = null;
3575 if (Array.isArray(html)) {
3576 elem = document.createDocumentFragment();
3577 for (var i = 0; i < html.length; i++)
3578 elem.appendChild(this.create(html[i]));
3580 else if (this.elem(html)) {
3583 else if (html.charCodeAt(0) === 60) {
3584 elem = this.parse(html);
3587 elem = document.createElement(html);
3593 this.attr(elem, attr);
3594 this.append(elem, data);
3602 * Attaches or detaches arbitrary data to and from a DOM `Node`.
3604 * This function is useful to attach non-string values or runtime
3605 * data that is not serializable to DOM nodes. To decouple data
3606 * from the DOM, values are not added directly to nodes, but
3607 * inserted into a registry instead which is then referenced by a
3608 * string key stored as `data-idref` attribute in the node.
3610 * This function has multiple signatures and is sensitive to the
3611 * number of arguments passed to it.
3613 * - `dom.data(node)` -
3614 * Fetches all data associated with the given node.
3615 * - `dom.data(node, key)` -
3616 * Fetches a specific key associated with the given node.
3617 * - `dom.data(node, key, val)` -
3618 * Sets a specific key to the given value associated with the
3620 * - `dom.data(node, null)` -
3621 * Clears any data associated with the node.
3622 * - `dom.data(node, key, null)` -
3623 * Clears the given key associated with the node.
3626 * @memberof LuCI.dom
3627 * @param {Node} node
3628 * The DOM `Node` instance to set or retrieve the data for.
3630 * @param {string|null} [key]
3631 * This is either a string specifying the key to retrieve, or
3632 * `null` to unset the entire node data.
3634 * @param {*|null} [val]
3635 * This is either a non-`null` value to set for a given key or
3636 * `null` to remove the given `key` from the specified node.
3639 * Returns the get or set value, or `null` when no value could
3642 data: function(node, key, val) {
3643 var id = node.getAttribute('data-idref');
3645 /* clear all data */
3646 if (arguments.length > 1 && key == null) {
3648 node.removeAttribute('data-idref');
3649 val = this.registry[id]
3650 delete this.registry[id];
3658 else if (arguments.length > 2 && key != null && val == null) {
3660 val = this.registry[id][key];
3661 delete this.registry[id][key];
3669 else if (arguments.length > 2 && key != null && val != null) {
3671 do { id = Math.floor(Math.random() * 0xffffffff).toString(16) }
3672 while (this.registry.hasOwnProperty(id));
3674 node.setAttribute('data-idref', id);
3675 this.registry[id] = {};
3678 return (this.registry[id][key] = val);
3682 else if (arguments.length == 1) {
3684 return this.registry[id];
3690 else if (arguments.length == 2) {
3692 return this.registry[id][key];
3699 * Binds the given class instance ot the specified DOM `Node`.
3701 * This function uses the `dom.data()` facility to attach the
3702 * passed instance of a Class to a node. This is needed for
3703 * complex widget elements or similar where the corresponding
3704 * class instance responsible for the element must be retrieved
3705 * from DOM nodes obtained by `querySelector()` or similar means.
3708 * @memberof LuCI.dom
3709 * @param {Node} node
3710 * The DOM `Node` instance to bind the class to.
3712 * @param {Class} inst
3713 * The Class instance to bind to the node.
3715 * @throws {TypeError}
3716 * Throws a `TypeError` when the given instance argument isn't
3717 * a valid Class instance.
3720 * Returns the bound class instance.
3722 bindClassInstance: function(node, inst) {
3723 if (!(inst instanceof Class))
3724 L.error('TypeError', 'Argument must be a class instance');
3726 return this.data(node, '_class', inst);
3730 * Finds a bound class instance on the given node itself or the
3731 * first bound instance on its closest parent node.
3734 * @memberof LuCI.dom
3735 * @param {Node} node
3736 * The DOM `Node` instance to start from.
3738 * @returns {Class|null}
3739 * Returns the founds class instance if any or `null` if no bound
3740 * class could be found on the node itself or any of its parents.
3742 findClassInstance: function(node) {
3746 inst = this.data(node, '_class');
3747 node = node.parentNode;
3749 while (!(inst instanceof Class) && node != null);
3755 * Finds a bound class instance on the given node itself or the
3756 * first bound instance on its closest parent node and invokes
3757 * the specified method name on the found class instance.
3760 * @memberof LuCI.dom
3761 * @param {Node} node
3762 * The DOM `Node` instance to start from.
3764 * @param {string} method
3765 * The name of the method to invoke on the found class instance.
3767 * @param {...*} params
3768 * Additional arguments to pass to the invoked method as-is.
3771 * Returns the return value of the invoked method if a class
3772 * instance and method has been found. Returns `null` if either
3773 * no bound class instance could be found, or if the found
3774 * instance didn't have the requested `method`.
3776 callClassMethod: function(node, method /*, ... */) {
3777 var inst = this.findClassInstance(node);
3779 if (inst == null || typeof(inst[method]) != 'function')
3782 return inst[method].apply(inst, inst.varargs(arguments, 2));
3786 * The ignore callback function is invoked by `isEmpty()` for each
3787 * child node to decide whether to ignore a child node or not.
3789 * When this function returns `false`, the node passed to it is
3790 * ignored, else not.
3792 * @callback LuCI.dom~ignoreCallbackFn
3793 * @param {Node} node
3794 * The child node to test.
3796 * @returns {boolean}
3797 * Boolean indicating whether to ignore the node or not.
3801 * Tests whether a given DOM `Node` instance is empty or appears
3804 * Any element child nodes which have the CSS class `hidden` set
3805 * or for which the optionally passed `ignoreFn` callback function
3806 * returns `false` are ignored.
3809 * @memberof LuCI.dom
3810 * @param {Node} node
3811 * The DOM `Node` instance to test.
3813 * @param {LuCI.dom~ignoreCallbackFn} [ignoreFn]
3814 * Specifies an optional function which is invoked for each child
3815 * node to decide whether the child node should be ignored or not.
3817 * @returns {boolean}
3818 * Returns `true` if the node does not have any children or if
3819 * any children node either has a `hidden` CSS class or a `false`
3820 * result when testing it using the given `ignoreFn`.
3822 isEmpty: function(node, ignoreFn) {
3823 for (var child = node.firstElementChild; child != null; child = child.nextElementSibling)
3824 if (!child.classList.contains('hidden') && (!ignoreFn || !ignoreFn(child)))
3841 * The `view` class forms the basis of views and provides a standard
3842 * set of methods to inherit from.
3844 view: Class.extend(/* @lends LuCI.view.prototype */ {
3845 __name__: 'LuCI.View',
3847 __init__: function() {
3848 var vp = document.getElementById('view');
3850 L.dom.content(vp, E('div', { 'class': 'spinning' }, _('Loading view…')));
3852 return Promise.resolve(this.load())
3853 .then(L.bind(this.render, this))
3854 .then(L.bind(function(nodes) {
3855 var vp = document.getElementById('view');
3857 L.dom.content(vp, nodes);
3858 L.dom.append(vp, this.addFooter());
3859 }, this)).catch(L.error);
3863 * The load function is invoked before the view is rendered.
3865 * The invocation of this function is wrapped by
3866 * `Promise.resolve()` so it may return Promises if needed.
3868 * The return value of the function (or the resolved values
3869 * of the promise returned by it) will be passed as first
3870 * argument to `render()`.
3872 * This function is supposed to be overwritten by subclasses,
3873 * the default implementation does nothing.
3877 * @memberof LuCI.view
3879 * @returns {*|Promise<*>}
3880 * May return any value or a Promise resolving to any value.
3882 load: function() {},
3885 * The render function is invoked after the
3886 * {@link LuCI.view#load load()} function and responsible
3887 * for setting up the view contents. It must return a DOM
3888 * `Node` or `DocumentFragment` holding the contents to
3889 * insert into the view area.
3891 * The invocation of this function is wrapped by
3892 * `Promise.resolve()` so it may return Promises if needed.
3894 * The return value of the function (or the resolved values
3895 * of the promise returned by it) will be inserted into the
3896 * main content area using
3897 * {@link LuCI.dom#append dom.append()}.
3899 * This function is supposed to be overwritten by subclasses,
3900 * the default implementation does nothing.
3904 * @memberof LuCI.view
3905 * @param {*|null} load_results
3906 * This function will receive the return value of the
3907 * {@link LuCI.view#load view.load()} function as first
3910 * @returns {Node|Promise<Node>}
3911 * Should return a DOM `Node` value or a `Promise` resolving
3912 * to a `Node` value.
3914 render: function() {},
3917 * The handleSave function is invoked when the user clicks
3918 * the `Save` button in the page action footer.
3920 * The default implementation should be sufficient for most
3921 * views using {@link form#Map form.Map()} based forms - it
3922 * will iterate all forms present in the view and invoke
3923 * the {@link form#Map#save Map.save()} method on each form.
3925 * Views not using `Map` instances or requiring other special
3926 * logic should overwrite `handleSave()` with a custom
3929 * To disable the `Save` page footer button, views extending
3930 * this base class should overwrite the `handleSave` function
3933 * The invocation of this function is wrapped by
3934 * `Promise.resolve()` so it may return Promises if needed.
3937 * @memberof LuCI.view
3939 * The DOM event that triggered the function.
3941 * @returns {*|Promise<*>}
3942 * Any return values of this function are discarded, but
3943 * passed through `Promise.resolve()` to ensure that any
3944 * returned promise runs to completion before the button
3947 handleSave: function(ev) {
3950 document.getElementById('maincontent')
3951 .querySelectorAll('.cbi-map').forEach(function(map) {
3952 tasks.push(L.dom.callClassMethod(map, 'save'));
3955 return Promise.all(tasks);
3959 * The handleSaveApply function is invoked when the user clicks
3960 * the `Save & Apply` button in the page action footer.
3962 * The default implementation should be sufficient for most
3963 * views using {@link form#Map form.Map()} based forms - it
3965 * {@link LuCI.view.handleSave view.handleSave()} and then
3966 * call {@link ui#changes#apply ui.changes.apply()} to start the
3967 * modal config apply and page reload flow.
3969 * Views not using `Map` instances or requiring other special
3970 * logic should overwrite `handleSaveApply()` with a custom
3973 * To disable the `Save & Apply` page footer button, views
3974 * extending this base class should overwrite the
3975 * `handleSaveApply` function with `null`.
3977 * The invocation of this function is wrapped by
3978 * `Promise.resolve()` so it may return Promises if needed.
3981 * @memberof LuCI.view
3983 * The DOM event that triggered the function.
3985 * @returns {*|Promise<*>}
3986 * Any return values of this function are discarded, but
3987 * passed through `Promise.resolve()` to ensure that any
3988 * returned promise runs to completion before the button
3991 handleSaveApply: function(ev, mode) {
3992 return this.handleSave(ev).then(function() {
3993 L.ui.changes.apply(mode == '0');
3998 * The handleReset function is invoked when the user clicks
3999 * the `Reset` button in the page action footer.
4001 * The default implementation should be sufficient for most
4002 * views using {@link form#Map form.Map()} based forms - it
4003 * will iterate all forms present in the view and invoke
4004 * the {@link form#Map#save Map.reset()} method on each form.
4006 * Views not using `Map` instances or requiring other special
4007 * logic should overwrite `handleReset()` with a custom
4010 * To disable the `Reset` page footer button, views extending
4011 * this base class should overwrite the `handleReset` function
4014 * The invocation of this function is wrapped by
4015 * `Promise.resolve()` so it may return Promises if needed.
4018 * @memberof LuCI.view
4020 * The DOM event that triggered the function.
4022 * @returns {*|Promise<*>}
4023 * Any return values of this function are discarded, but
4024 * passed through `Promise.resolve()` to ensure that any
4025 * returned promise runs to completion before the button
4028 handleReset: function(ev) {
4031 document.getElementById('maincontent')
4032 .querySelectorAll('.cbi-map').forEach(function(map) {
4033 tasks.push(L.dom.callClassMethod(map, 'reset'));
4036 return Promise.all(tasks);
4040 * Renders a standard page action footer if any of the
4041 * `handleSave()`, `handleSaveApply()` or `handleReset()`
4042 * functions are defined.
4044 * The default implementation should be sufficient for most
4045 * views - it will render a standard page footer with action
4046 * buttons labeled `Save`, `Save & Apply` and `Reset`
4047 * triggering the `handleSave()`, `handleSaveApply()` and
4048 * `handleReset()` functions respectively.
4050 * When any of these `handle*()` functions is overwritten
4051 * with `null` by a view extending this class, the
4052 * corresponding button will not be rendered.
4055 * @memberof LuCI.view
4056 * @returns {DocumentFragment}
4057 * Returns a `DocumentFragment` containing the footer bar
4058 * with buttons for each corresponding `handle*()` action
4059 * or an empty `DocumentFragment` if all three `handle*()`
4060 * methods are overwritten with `null`.
4062 addFooter: function() {
4065 var saveApplyBtn = this.handleSaveApply ? new L.ui.ComboButton('0', {
4066 0: [ _('Save & Apply') ],
4067 1: [ _('Apply unchecked') ]
4070 0: 'cbi-button cbi-button-apply important',
4071 1: 'cbi-button cbi-button-negative important'
4073 click: L.ui.createHandlerFn(this, 'handleSaveApply')
4074 }).render() : E([]);
4076 if (this.handleSaveApply || this.handleSave || this.handleReset) {
4077 footer.appendChild(E('div', { 'class': 'cbi-page-actions' }, [
4079 this.handleSave ? E('button', {
4080 'class': 'cbi-button cbi-button-save',
4081 'click': L.ui.createHandlerFn(this, 'handleSave')
4082 }, [ _('Save') ]) : '', ' ',
4083 this.handleReset ? E('button', {
4084 'class': 'cbi-button cbi-button-reset',
4085 'click': L.ui.createHandlerFn(this, 'handleReset')
4086 }, [ _('Reset') ]) : ''
4101 * The `LuCI.XHR` class is a legacy compatibility shim for the
4102 * functionality formerly provided by `xhr.js`. It is registered as global
4103 * `window.XHR` symbol for compatibility with legacy code.
4105 * New code should use {@link LuCI.Request} instead to implement HTTP
4108 var XHR = Class.extend(/** @lends LuCI.XHR.prototype */ {
4109 __name__: 'LuCI.XHR',
4110 __init__: function() {
4111 if (window.console && console.debug)
4112 console.debug('Direct use XHR() is deprecated, please use L.Request instead');
4115 _response: function(cb, res, json, duration) {
4117 cb(res, json, duration);
4122 * This function is a legacy wrapper around
4123 * {@link LuCI#get LuCI.get()}.
4127 * @memberof LuCI.XHR
4129 * @param {string} url
4130 * The URL to request
4132 * @param {Object} [data]
4133 * Additional query string data
4135 * @param {LuCI.requestCallbackFn} [callback]
4136 * Callback function to invoke on completion
4138 * @param {number} [timeout]
4139 * Request timeout to use
4141 * @return {Promise<null>}
4143 get: function(url, data, callback, timeout) {
4145 L.get(url, data, this._response.bind(this, callback), timeout);
4149 * This function is a legacy wrapper around
4150 * {@link LuCI#post LuCI.post()}.
4154 * @memberof LuCI.XHR
4156 * @param {string} url
4157 * The URL to request
4159 * @param {Object} [data]
4160 * Additional data to append to the request body.
4162 * @param {LuCI.requestCallbackFn} [callback]
4163 * Callback function to invoke on completion
4165 * @param {number} [timeout]
4166 * Request timeout to use
4168 * @return {Promise<null>}
4170 post: function(url, data, callback, timeout) {
4172 L.post(url, data, this._response.bind(this, callback), timeout);
4176 * Cancels a running request.
4178 * This function does not actually cancel the underlying
4179 * `XMLHTTPRequest` request but it sets a flag which prevents the
4180 * invocation of the callback function when the request eventually
4181 * finishes or timed out.
4185 * @memberof LuCI.XHR
4187 cancel: function() { delete this.active },
4190 * Checks the running state of the request.
4194 * @memberof LuCI.XHR
4196 * @returns {boolean}
4197 * Returns `true` if the request is still running or `false` if it
4198 * already completed.
4200 busy: function() { return (this.active === true) },
4203 * Ignored for backwards compatibility.
4205 * This function does nothing.
4209 * @memberof LuCI.XHR
4211 abort: function() {},
4214 * Existing for backwards compatibility.
4216 * This function simply throws an `InternalError` when invoked.
4220 * @memberof LuCI.XHR
4222 * @throws {InternalError}
4223 * Throws an `InternalError` with the message `Not implemented`
4226 send_form: function() { L.error('InternalError', 'Not implemented') },
4229 XHR.get = function() { return window.L.get.apply(window.L, arguments) };
4230 XHR.post = function() { return window.L.post.apply(window.L, arguments) };
4231 XHR.poll = function() { return window.L.poll.apply(window.L, arguments) };
4232 XHR.stop = Request.poll.remove.bind(Request.poll);
4233 XHR.halt = Request.poll.stop.bind(Request.poll);
4234 XHR.run = Request.poll.start.bind(Request.poll);
4235 XHR.running = Request.poll.active.bind(Request.poll);
4239 })(window, document);
4252 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Wed Feb 12 2020 11:56:59 GMT+0100 (Central European Standard Time)
4256 <script>prettyPrint();</script>
4257 <script src="scripts/jaguar.js"></script>