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#path"><a href=
"LuCI.html#path">path
</a></li>
79 <li data-name=
"LuCI#poll"><a href=
"LuCI.html#poll">poll
</a></li>
81 <li data-name=
"LuCI#post"><a href=
"LuCI.html#post">post
</a></li>
83 <li data-name=
"LuCI#raise"><a href=
"LuCI.html#raise">raise
</a></li>
85 <li data-name=
"LuCI#require"><a href=
"LuCI.html#require">require
</a></li>
87 <li data-name=
"LuCI#resolveDefault"><a href=
"LuCI.html#resolveDefault">resolveDefault
</a></li>
89 <li data-name=
"LuCI#resource"><a href=
"LuCI.html#resource">resource
</a></li>
91 <li data-name=
"LuCI#run"><a href=
"LuCI.html#run">run
</a></li>
93 <li data-name=
"LuCI#sortedKeys"><a href=
"LuCI.html#sortedKeys">sortedKeys
</a></li>
95 <li data-name=
"LuCI#stop"><a href=
"LuCI.html#stop">stop
</a></li>
97 <li data-name=
"LuCI#toArray"><a href=
"LuCI.html#toArray">toArray
</a></li>
99 <li data-name=
"LuCI#url"><a href=
"LuCI.html#url">url
</a></li>
102 <ul class=
"events itemMembers">
107 <li class=
"item" data-name=
"LuCI.Class">
109 <a href=
"LuCI.Class.html">LuCI.Class
</a>
112 <ul class=
"members itemMembers">
115 <ul class=
"typedefs itemMembers">
118 <ul class=
"typedefs itemMembers">
121 <ul class=
"methods itemMembers">
123 <span class=
"subtitle">Methods
</span>
125 <li data-name=
"LuCI.Class.extend"><a href=
"LuCI.Class.html#.extend">extend
</a></li>
127 <li data-name=
"LuCI.Class.instantiate"><a href=
"LuCI.Class.html#.instantiate">instantiate
</a></li>
129 <li data-name=
"LuCI.Class.isSubclass"><a href=
"LuCI.Class.html#.isSubclass">isSubclass
</a></li>
131 <li data-name=
"LuCI.Class.singleton"><a href=
"LuCI.Class.html#.singleton">singleton
</a></li>
133 <li data-name=
"LuCI.Class#super"><a href=
"LuCI.Class.html#super">super
</a></li>
135 <li data-name=
"LuCI.Class#varargs"><a href=
"LuCI.Class.html#varargs">varargs
</a></li>
138 <ul class=
"events itemMembers">
143 <li class=
"item" data-name=
"LuCI.dom">
145 <a href=
"LuCI.dom.html">LuCI.dom
</a>
148 <ul class=
"members itemMembers">
151 <ul class=
"typedefs itemMembers">
153 <span class=
"subtitle">Typedefs
</span>
155 <li data-name=
"LuCI.dom~ignoreCallbackFn"><a href=
"LuCI.dom.html#~ignoreCallbackFn">ignoreCallbackFn
</a></li>
158 <ul class=
"typedefs itemMembers">
161 <ul class=
"methods itemMembers">
163 <span class=
"subtitle">Methods
</span>
165 <li data-name=
"LuCI.dom#append"><a href=
"LuCI.dom.html#append">append
</a></li>
167 <li data-name=
"LuCI.dom#attr"><a href=
"LuCI.dom.html#attr">attr
</a></li>
169 <li data-name=
"LuCI.dom#bindClassInstance"><a href=
"LuCI.dom.html#bindClassInstance">bindClassInstance
</a></li>
171 <li data-name=
"LuCI.dom#callClassMethod"><a href=
"LuCI.dom.html#callClassMethod">callClassMethod
</a></li>
173 <li data-name=
"LuCI.dom#content"><a href=
"LuCI.dom.html#content">content
</a></li>
175 <li data-name=
"LuCI.dom#create"><a href=
"LuCI.dom.html#create">create
</a></li>
177 <li data-name=
"LuCI.dom#data"><a href=
"LuCI.dom.html#data">data
</a></li>
179 <li data-name=
"LuCI.dom#elem"><a href=
"LuCI.dom.html#elem">elem
</a></li>
181 <li data-name=
"LuCI.dom#findClassInstance"><a href=
"LuCI.dom.html#findClassInstance">findClassInstance
</a></li>
183 <li data-name=
"LuCI.dom#isEmpty"><a href=
"LuCI.dom.html#isEmpty">isEmpty
</a></li>
185 <li data-name=
"LuCI.dom#matches"><a href=
"LuCI.dom.html#matches">matches
</a></li>
187 <li data-name=
"LuCI.dom#parent"><a href=
"LuCI.dom.html#parent">parent
</a></li>
189 <li data-name=
"LuCI.dom#parse"><a href=
"LuCI.dom.html#parse">parse
</a></li>
192 <ul class=
"events itemMembers">
197 <li class=
"item" data-name=
"LuCI.fs">
199 <a href=
"LuCI.fs.html">LuCI.fs
</a>
202 <ul class=
"members itemMembers">
205 <ul class=
"typedefs itemMembers">
207 <span class=
"subtitle">Typedefs
</span>
209 <li data-name=
"LuCI.fs.FileExecResult"><a href=
"LuCI.fs.html#.FileExecResult">FileExecResult
</a></li>
211 <li data-name=
"LuCI.fs.FileStatEntry"><a href=
"LuCI.fs.html#.FileStatEntry">FileStatEntry
</a></li>
214 <ul class=
"typedefs itemMembers">
217 <ul class=
"methods itemMembers">
219 <span class=
"subtitle">Methods
</span>
221 <li data-name=
"LuCI.fs#exec"><a href=
"LuCI.fs.html#exec">exec
</a></li>
223 <li data-name=
"LuCI.fs#lines"><a href=
"LuCI.fs.html#lines">lines
</a></li>
225 <li data-name=
"LuCI.fs#list"><a href=
"LuCI.fs.html#list">list
</a></li>
227 <li data-name=
"LuCI.fs#read"><a href=
"LuCI.fs.html#read">read
</a></li>
229 <li data-name=
"LuCI.fs#remove"><a href=
"LuCI.fs.html#remove">remove
</a></li>
231 <li data-name=
"LuCI.fs#stat"><a href=
"LuCI.fs.html#stat">stat
</a></li>
233 <li data-name=
"LuCI.fs#trimmed"><a href=
"LuCI.fs.html#trimmed">trimmed
</a></li>
235 <li data-name=
"LuCI.fs#write"><a href=
"LuCI.fs.html#write">write
</a></li>
238 <ul class=
"events itemMembers">
243 <li class=
"item" data-name=
"LuCI.Headers">
245 <a href=
"LuCI.Headers.html">LuCI.Headers
</a>
248 <ul class=
"members itemMembers">
251 <ul class=
"typedefs itemMembers">
254 <ul class=
"typedefs itemMembers">
257 <ul class=
"methods itemMembers">
259 <span class=
"subtitle">Methods
</span>
261 <li data-name=
"LuCI.Headers#get"><a href=
"LuCI.Headers.html#get">get
</a></li>
263 <li data-name=
"LuCI.Headers#has"><a href=
"LuCI.Headers.html#has">has
</a></li>
266 <ul class=
"events itemMembers">
271 <li class=
"item" data-name=
"LuCI.Network">
273 <a href=
"LuCI.Network.html">LuCI.Network
</a>
276 <ul class=
"members itemMembers">
279 <ul class=
"typedefs itemMembers">
281 <span class=
"subtitle">Typedefs
</span>
283 <li data-name=
"LuCI.Network.SwitchTopology"><a href=
"LuCI.Network.html#.SwitchTopology">SwitchTopology
</a></li>
285 <li data-name=
"LuCI.Network.WifiEncryption"><a href=
"LuCI.Network.html#.WifiEncryption">WifiEncryption
</a></li>
287 <li data-name=
"LuCI.Network.WifiPeerEntry"><a href=
"LuCI.Network.html#.WifiPeerEntry">WifiPeerEntry
</a></li>
289 <li data-name=
"LuCI.Network.WifiRateEntry"><a href=
"LuCI.Network.html#.WifiRateEntry">WifiRateEntry
</a></li>
291 <li data-name=
"LuCI.Network.WifiScanResult"><a href=
"LuCI.Network.html#.WifiScanResult">WifiScanResult
</a></li>
294 <ul class=
"typedefs itemMembers">
297 <ul class=
"methods itemMembers">
299 <span class=
"subtitle">Methods
</span>
301 <li data-name=
"LuCI.Network#addNetwork"><a href=
"LuCI.Network.html#addNetwork">addNetwork
</a></li>
303 <li data-name=
"LuCI.Network#addWifiNetwork"><a href=
"LuCI.Network.html#addWifiNetwork">addWifiNetwork
</a></li>
305 <li data-name=
"LuCI.Network#deleteNetwork"><a href=
"LuCI.Network.html#deleteNetwork">deleteNetwork
</a></li>
307 <li data-name=
"LuCI.Network#deleteWifiNetwork"><a href=
"LuCI.Network.html#deleteWifiNetwork">deleteWifiNetwork
</a></li>
309 <li data-name=
"LuCI.Network#flushCache"><a href=
"LuCI.Network.html#flushCache">flushCache
</a></li>
311 <li data-name=
"LuCI.Network#formatWifiEncryption"><a href=
"LuCI.Network.html#formatWifiEncryption">formatWifiEncryption
</a></li>
313 <li data-name=
"LuCI.Network#getDevice"><a href=
"LuCI.Network.html#getDevice">getDevice
</a></li>
315 <li data-name=
"LuCI.Network#getDevices"><a href=
"LuCI.Network.html#getDevices">getDevices
</a></li>
317 <li data-name=
"LuCI.Network#getDSLModemType"><a href=
"LuCI.Network.html#getDSLModemType">getDSLModemType
</a></li>
319 <li data-name=
"LuCI.Network#getHostHints"><a href=
"LuCI.Network.html#getHostHints">getHostHints
</a></li>
321 <li data-name=
"LuCI.Network#getIfnameOf"><a href=
"LuCI.Network.html#getIfnameOf">getIfnameOf
</a></li>
323 <li data-name=
"LuCI.Network#getNetwork"><a href=
"LuCI.Network.html#getNetwork">getNetwork
</a></li>
325 <li data-name=
"LuCI.Network#getNetworks"><a href=
"LuCI.Network.html#getNetworks">getNetworks
</a></li>
327 <li data-name=
"LuCI.Network#getProtocol"><a href=
"LuCI.Network.html#getProtocol">getProtocol
</a></li>
329 <li data-name=
"LuCI.Network#getProtocols"><a href=
"LuCI.Network.html#getProtocols">getProtocols
</a></li>
331 <li data-name=
"LuCI.Network#getSwitchTopologies"><a href=
"LuCI.Network.html#getSwitchTopologies">getSwitchTopologies
</a></li>
333 <li data-name=
"LuCI.Network#getWAN6Networks"><a href=
"LuCI.Network.html#getWAN6Networks">getWAN6Networks
</a></li>
335 <li data-name=
"LuCI.Network#getWANNetworks"><a href=
"LuCI.Network.html#getWANNetworks">getWANNetworks
</a></li>
337 <li data-name=
"LuCI.Network#getWifiDevice"><a href=
"LuCI.Network.html#getWifiDevice">getWifiDevice
</a></li>
339 <li data-name=
"LuCI.Network#getWifiDevices"><a href=
"LuCI.Network.html#getWifiDevices">getWifiDevices
</a></li>
341 <li data-name=
"LuCI.Network#getWifiNetwork"><a href=
"LuCI.Network.html#getWifiNetwork">getWifiNetwork
</a></li>
343 <li data-name=
"LuCI.Network#getWifiNetworks"><a href=
"LuCI.Network.html#getWifiNetworks">getWifiNetworks
</a></li>
345 <li data-name=
"LuCI.Network#isIgnoredDevice"><a href=
"LuCI.Network.html#isIgnoredDevice">isIgnoredDevice
</a></li>
347 <li data-name=
"LuCI.Network#maskToPrefix"><a href=
"LuCI.Network.html#maskToPrefix">maskToPrefix
</a></li>
349 <li data-name=
"LuCI.Network#prefixToMask"><a href=
"LuCI.Network.html#prefixToMask">prefixToMask
</a></li>
351 <li data-name=
"LuCI.Network#registerErrorCode"><a href=
"LuCI.Network.html#registerErrorCode">registerErrorCode
</a></li>
353 <li data-name=
"LuCI.Network#registerPatternVirtual"><a href=
"LuCI.Network.html#registerPatternVirtual">registerPatternVirtual
</a></li>
355 <li data-name=
"LuCI.Network#registerProtocol"><a href=
"LuCI.Network.html#registerProtocol">registerProtocol
</a></li>
357 <li data-name=
"LuCI.Network#renameNetwork"><a href=
"LuCI.Network.html#renameNetwork">renameNetwork
</a></li>
360 <ul class=
"events itemMembers">
365 <li class=
"item" data-name=
"LuCI.Network.Device">
367 <a href=
"LuCI.Network.Device.html">LuCI.Network.Device
</a>
370 <ul class=
"members itemMembers">
373 <ul class=
"typedefs itemMembers">
376 <ul class=
"typedefs itemMembers">
379 <ul class=
"methods itemMembers">
381 <span class=
"subtitle">Methods
</span>
383 <li data-name=
"LuCI.Network.Device#getBridgeID"><a href=
"LuCI.Network.Device.html#getBridgeID">getBridgeID
</a></li>
385 <li data-name=
"LuCI.Network.Device#getBridgeSTP"><a href=
"LuCI.Network.Device.html#getBridgeSTP">getBridgeSTP
</a></li>
387 <li data-name=
"LuCI.Network.Device#getI18n"><a href=
"LuCI.Network.Device.html#getI18n">getI18n
</a></li>
389 <li data-name=
"LuCI.Network.Device#getIP6Addrs"><a href=
"LuCI.Network.Device.html#getIP6Addrs">getIP6Addrs
</a></li>
391 <li data-name=
"LuCI.Network.Device#getIPAddrs"><a href=
"LuCI.Network.Device.html#getIPAddrs">getIPAddrs
</a></li>
393 <li data-name=
"LuCI.Network.Device#getMAC"><a href=
"LuCI.Network.Device.html#getMAC">getMAC
</a></li>
395 <li data-name=
"LuCI.Network.Device#getMTU"><a href=
"LuCI.Network.Device.html#getMTU">getMTU
</a></li>
397 <li data-name=
"LuCI.Network.Device#getName"><a href=
"LuCI.Network.Device.html#getName">getName
</a></li>
399 <li data-name=
"LuCI.Network.Device#getNetwork"><a href=
"LuCI.Network.Device.html#getNetwork">getNetwork
</a></li>
401 <li data-name=
"LuCI.Network.Device#getNetworks"><a href=
"LuCI.Network.Device.html#getNetworks">getNetworks
</a></li>
403 <li data-name=
"LuCI.Network.Device#getPorts"><a href=
"LuCI.Network.Device.html#getPorts">getPorts
</a></li>
405 <li data-name=
"LuCI.Network.Device#getRXBytes"><a href=
"LuCI.Network.Device.html#getRXBytes">getRXBytes
</a></li>
407 <li data-name=
"LuCI.Network.Device#getRXPackets"><a href=
"LuCI.Network.Device.html#getRXPackets">getRXPackets
</a></li>
409 <li data-name=
"LuCI.Network.Device#getShortName"><a href=
"LuCI.Network.Device.html#getShortName">getShortName
</a></li>
411 <li data-name=
"LuCI.Network.Device#getTXBytes"><a href=
"LuCI.Network.Device.html#getTXBytes">getTXBytes
</a></li>
413 <li data-name=
"LuCI.Network.Device#getTXPackets"><a href=
"LuCI.Network.Device.html#getTXPackets">getTXPackets
</a></li>
415 <li data-name=
"LuCI.Network.Device#getType"><a href=
"LuCI.Network.Device.html#getType">getType
</a></li>
417 <li data-name=
"LuCI.Network.Device#getTypeI18n"><a href=
"LuCI.Network.Device.html#getTypeI18n">getTypeI18n
</a></li>
419 <li data-name=
"LuCI.Network.Device#getWifiNetwork"><a href=
"LuCI.Network.Device.html#getWifiNetwork">getWifiNetwork
</a></li>
421 <li data-name=
"LuCI.Network.Device#isBridge"><a href=
"LuCI.Network.Device.html#isBridge">isBridge
</a></li>
423 <li data-name=
"LuCI.Network.Device#isBridgePort"><a href=
"LuCI.Network.Device.html#isBridgePort">isBridgePort
</a></li>
425 <li data-name=
"LuCI.Network.Device#isUp"><a href=
"LuCI.Network.Device.html#isUp">isUp
</a></li>
428 <ul class=
"events itemMembers">
433 <li class=
"item" data-name=
"LuCI.Network.Hosts">
435 <a href=
"LuCI.Network.Hosts.html">LuCI.Network.Hosts
</a>
438 <ul class=
"members itemMembers">
441 <ul class=
"typedefs itemMembers">
444 <ul class=
"typedefs itemMembers">
447 <ul class=
"methods itemMembers">
449 <span class=
"subtitle">Methods
</span>
451 <li data-name=
"LuCI.Network.Hosts#getHostnameByIP6Addr"><a href=
"LuCI.Network.Hosts.html#getHostnameByIP6Addr">getHostnameByIP6Addr
</a></li>
453 <li data-name=
"LuCI.Network.Hosts#getHostnameByIPAddr"><a href=
"LuCI.Network.Hosts.html#getHostnameByIPAddr">getHostnameByIPAddr
</a></li>
455 <li data-name=
"LuCI.Network.Hosts#getHostnameByMACAddr"><a href=
"LuCI.Network.Hosts.html#getHostnameByMACAddr">getHostnameByMACAddr
</a></li>
457 <li data-name=
"LuCI.Network.Hosts#getIP6AddrByMACAddr"><a href=
"LuCI.Network.Hosts.html#getIP6AddrByMACAddr">getIP6AddrByMACAddr
</a></li>
459 <li data-name=
"LuCI.Network.Hosts#getIPAddrByMACAddr"><a href=
"LuCI.Network.Hosts.html#getIPAddrByMACAddr">getIPAddrByMACAddr
</a></li>
461 <li data-name=
"LuCI.Network.Hosts#getMACAddrByIP6Addr"><a href=
"LuCI.Network.Hosts.html#getMACAddrByIP6Addr">getMACAddrByIP6Addr
</a></li>
463 <li data-name=
"LuCI.Network.Hosts#getMACAddrByIPAddr"><a href=
"LuCI.Network.Hosts.html#getMACAddrByIPAddr">getMACAddrByIPAddr
</a></li>
465 <li data-name=
"LuCI.Network.Hosts#getMACHints"><a href=
"LuCI.Network.Hosts.html#getMACHints">getMACHints
</a></li>
468 <ul class=
"events itemMembers">
473 <li class=
"item" data-name=
"LuCI.Network.Protocol">
475 <a href=
"LuCI.Network.Protocol.html">LuCI.Network.Protocol
</a>
478 <ul class=
"members itemMembers">
481 <ul class=
"typedefs itemMembers">
484 <ul class=
"typedefs itemMembers">
487 <ul class=
"methods itemMembers">
489 <span class=
"subtitle">Methods
</span>
491 <li data-name=
"LuCI.Network.Protocol#addDevice"><a href=
"LuCI.Network.Protocol.html#addDevice">addDevice
</a></li>
493 <li data-name=
"LuCI.Network.Protocol#containsDevice"><a href=
"LuCI.Network.Protocol.html#containsDevice">containsDevice
</a></li>
495 <li data-name=
"LuCI.Network.Protocol#deleteDevice"><a href=
"LuCI.Network.Protocol.html#deleteDevice">deleteDevice
</a></li>
497 <li data-name=
"LuCI.Network.Protocol#get"><a href=
"LuCI.Network.Protocol.html#get">get
</a></li>
499 <li data-name=
"LuCI.Network.Protocol#getDevice"><a href=
"LuCI.Network.Protocol.html#getDevice">getDevice
</a></li>
501 <li data-name=
"LuCI.Network.Protocol#getDevices"><a href=
"LuCI.Network.Protocol.html#getDevices">getDevices
</a></li>
503 <li data-name=
"LuCI.Network.Protocol#getDNS6Addrs"><a href=
"LuCI.Network.Protocol.html#getDNS6Addrs">getDNS6Addrs
</a></li>
505 <li data-name=
"LuCI.Network.Protocol#getDNSAddrs"><a href=
"LuCI.Network.Protocol.html#getDNSAddrs">getDNSAddrs
</a></li>
507 <li data-name=
"LuCI.Network.Protocol#getErrors"><a href=
"LuCI.Network.Protocol.html#getErrors">getErrors
</a></li>
509 <li data-name=
"LuCI.Network.Protocol#getExpiry"><a href=
"LuCI.Network.Protocol.html#getExpiry">getExpiry
</a></li>
511 <li data-name=
"LuCI.Network.Protocol#getGateway6Addr"><a href=
"LuCI.Network.Protocol.html#getGateway6Addr">getGateway6Addr
</a></li>
513 <li data-name=
"LuCI.Network.Protocol#getGatewayAddr"><a href=
"LuCI.Network.Protocol.html#getGatewayAddr">getGatewayAddr
</a></li>
515 <li data-name=
"LuCI.Network.Protocol#getI18n"><a href=
"LuCI.Network.Protocol.html#getI18n">getI18n
</a></li>
517 <li data-name=
"LuCI.Network.Protocol#getIfname"><a href=
"LuCI.Network.Protocol.html#getIfname">getIfname
</a></li>
519 <li data-name=
"LuCI.Network.Protocol#getIP6Addr"><a href=
"LuCI.Network.Protocol.html#getIP6Addr">getIP6Addr
</a></li>
521 <li data-name=
"LuCI.Network.Protocol#getIP6Addrs"><a href=
"LuCI.Network.Protocol.html#getIP6Addrs">getIP6Addrs
</a></li>
523 <li data-name=
"LuCI.Network.Protocol#getIP6Prefix"><a href=
"LuCI.Network.Protocol.html#getIP6Prefix">getIP6Prefix
</a></li>
525 <li data-name=
"LuCI.Network.Protocol#getIPAddr"><a href=
"LuCI.Network.Protocol.html#getIPAddr">getIPAddr
</a></li>
527 <li data-name=
"LuCI.Network.Protocol#getIPAddrs"><a href=
"LuCI.Network.Protocol.html#getIPAddrs">getIPAddrs
</a></li>
529 <li data-name=
"LuCI.Network.Protocol#getL2Device"><a href=
"LuCI.Network.Protocol.html#getL2Device">getL2Device
</a></li>
531 <li data-name=
"LuCI.Network.Protocol#getL3Device"><a href=
"LuCI.Network.Protocol.html#getL3Device">getL3Device
</a></li>
533 <li data-name=
"LuCI.Network.Protocol#getMetric"><a href=
"LuCI.Network.Protocol.html#getMetric">getMetric
</a></li>
535 <li data-name=
"LuCI.Network.Protocol#getName"><a href=
"LuCI.Network.Protocol.html#getName">getName
</a></li>
537 <li data-name=
"LuCI.Network.Protocol#getNetmask"><a href=
"LuCI.Network.Protocol.html#getNetmask">getNetmask
</a></li>
539 <li data-name=
"LuCI.Network.Protocol#getOpkgPackage"><a href=
"LuCI.Network.Protocol.html#getOpkgPackage">getOpkgPackage
</a></li>
541 <li data-name=
"LuCI.Network.Protocol#getProtocol"><a href=
"LuCI.Network.Protocol.html#getProtocol">getProtocol
</a></li>
543 <li data-name=
"LuCI.Network.Protocol#getType"><a href=
"LuCI.Network.Protocol.html#getType">getType
</a></li>
545 <li data-name=
"LuCI.Network.Protocol#getUptime"><a href=
"LuCI.Network.Protocol.html#getUptime">getUptime
</a></li>
547 <li data-name=
"LuCI.Network.Protocol#getZoneName"><a href=
"LuCI.Network.Protocol.html#getZoneName">getZoneName
</a></li>
549 <li data-name=
"LuCI.Network.Protocol#isAlias"><a href=
"LuCI.Network.Protocol.html#isAlias">isAlias
</a></li>
551 <li data-name=
"LuCI.Network.Protocol#isBridge"><a href=
"LuCI.Network.Protocol.html#isBridge">isBridge
</a></li>
553 <li data-name=
"LuCI.Network.Protocol#isDynamic"><a href=
"LuCI.Network.Protocol.html#isDynamic">isDynamic
</a></li>
555 <li data-name=
"LuCI.Network.Protocol#isEmpty"><a href=
"LuCI.Network.Protocol.html#isEmpty">isEmpty
</a></li>
557 <li data-name=
"LuCI.Network.Protocol#isFloating"><a href=
"LuCI.Network.Protocol.html#isFloating">isFloating
</a></li>
559 <li data-name=
"LuCI.Network.Protocol#isInstalled"><a href=
"LuCI.Network.Protocol.html#isInstalled">isInstalled
</a></li>
561 <li data-name=
"LuCI.Network.Protocol#isUp"><a href=
"LuCI.Network.Protocol.html#isUp">isUp
</a></li>
563 <li data-name=
"LuCI.Network.Protocol#isVirtual"><a href=
"LuCI.Network.Protocol.html#isVirtual">isVirtual
</a></li>
565 <li data-name=
"LuCI.Network.Protocol#set"><a href=
"LuCI.Network.Protocol.html#set">set
</a></li>
568 <ul class=
"events itemMembers">
573 <li class=
"item" data-name=
"LuCI.Network.WifiDevice">
575 <a href=
"LuCI.Network.WifiDevice.html">LuCI.Network.WifiDevice
</a>
578 <ul class=
"members itemMembers">
581 <ul class=
"typedefs itemMembers">
584 <ul class=
"typedefs itemMembers">
587 <ul class=
"methods itemMembers">
589 <span class=
"subtitle">Methods
</span>
591 <li data-name=
"LuCI.Network.WifiDevice#addWifiNetwork"><a href=
"LuCI.Network.WifiDevice.html#addWifiNetwork">addWifiNetwork
</a></li>
593 <li data-name=
"LuCI.Network.WifiDevice#deleteWifiNetwork"><a href=
"LuCI.Network.WifiDevice.html#deleteWifiNetwork">deleteWifiNetwork
</a></li>
595 <li data-name=
"LuCI.Network.WifiDevice#get"><a href=
"LuCI.Network.WifiDevice.html#get">get
</a></li>
597 <li data-name=
"LuCI.Network.WifiDevice#getHTModes"><a href=
"LuCI.Network.WifiDevice.html#getHTModes">getHTModes
</a></li>
599 <li data-name=
"LuCI.Network.WifiDevice#getHWModes"><a href=
"LuCI.Network.WifiDevice.html#getHWModes">getHWModes
</a></li>
601 <li data-name=
"LuCI.Network.WifiDevice#getI18n"><a href=
"LuCI.Network.WifiDevice.html#getI18n">getI18n
</a></li>
603 <li data-name=
"LuCI.Network.WifiDevice#getName"><a href=
"LuCI.Network.WifiDevice.html#getName">getName
</a></li>
605 <li data-name=
"LuCI.Network.WifiDevice#getScanList"><a href=
"LuCI.Network.WifiDevice.html#getScanList">getScanList
</a></li>
607 <li data-name=
"LuCI.Network.WifiDevice#getWifiNetwork"><a href=
"LuCI.Network.WifiDevice.html#getWifiNetwork">getWifiNetwork
</a></li>
609 <li data-name=
"LuCI.Network.WifiDevice#getWifiNetworks"><a href=
"LuCI.Network.WifiDevice.html#getWifiNetworks">getWifiNetworks
</a></li>
611 <li data-name=
"LuCI.Network.WifiDevice#isDisabled"><a href=
"LuCI.Network.WifiDevice.html#isDisabled">isDisabled
</a></li>
613 <li data-name=
"LuCI.Network.WifiDevice#isUp"><a href=
"LuCI.Network.WifiDevice.html#isUp">isUp
</a></li>
615 <li data-name=
"LuCI.Network.WifiDevice#set"><a href=
"LuCI.Network.WifiDevice.html#set">set
</a></li>
618 <ul class=
"events itemMembers">
623 <li class=
"item" data-name=
"LuCI.Network.WifiNetwork">
625 <a href=
"LuCI.Network.WifiNetwork.html">LuCI.Network.WifiNetwork
</a>
628 <ul class=
"members itemMembers">
631 <ul class=
"typedefs itemMembers">
634 <ul class=
"typedefs itemMembers">
637 <ul class=
"methods itemMembers">
639 <span class=
"subtitle">Methods
</span>
641 <li data-name=
"LuCI.Network.WifiNetwork#disconnectClient"><a href=
"LuCI.Network.WifiNetwork.html#disconnectClient">disconnectClient
</a></li>
643 <li data-name=
"LuCI.Network.WifiNetwork#get"><a href=
"LuCI.Network.WifiNetwork.html#get">get
</a></li>
645 <li data-name=
"LuCI.Network.WifiNetwork#getActiveBSSID"><a href=
"LuCI.Network.WifiNetwork.html#getActiveBSSID">getActiveBSSID
</a></li>
647 <li data-name=
"LuCI.Network.WifiNetwork#getActiveEncryption"><a href=
"LuCI.Network.WifiNetwork.html#getActiveEncryption">getActiveEncryption
</a></li>
649 <li data-name=
"LuCI.Network.WifiNetwork#getActiveMode"><a href=
"LuCI.Network.WifiNetwork.html#getActiveMode">getActiveMode
</a></li>
651 <li data-name=
"LuCI.Network.WifiNetwork#getActiveModeI18n"><a href=
"LuCI.Network.WifiNetwork.html#getActiveModeI18n">getActiveModeI18n
</a></li>
653 <li data-name=
"LuCI.Network.WifiNetwork#getActiveSSID"><a href=
"LuCI.Network.WifiNetwork.html#getActiveSSID">getActiveSSID
</a></li>
655 <li data-name=
"LuCI.Network.WifiNetwork#getAssocList"><a href=
"LuCI.Network.WifiNetwork.html#getAssocList">getAssocList
</a></li>
657 <li data-name=
"LuCI.Network.WifiNetwork#getBitRate"><a href=
"LuCI.Network.WifiNetwork.html#getBitRate">getBitRate
</a></li>
659 <li data-name=
"LuCI.Network.WifiNetwork#getBSSID"><a href=
"LuCI.Network.WifiNetwork.html#getBSSID">getBSSID
</a></li>
661 <li data-name=
"LuCI.Network.WifiNetwork#getChannel"><a href=
"LuCI.Network.WifiNetwork.html#getChannel">getChannel
</a></li>
663 <li data-name=
"LuCI.Network.WifiNetwork#getCountryCode"><a href=
"LuCI.Network.WifiNetwork.html#getCountryCode">getCountryCode
</a></li>
665 <li data-name=
"LuCI.Network.WifiNetwork#getDevice"><a href=
"LuCI.Network.WifiNetwork.html#getDevice">getDevice
</a></li>
667 <li data-name=
"LuCI.Network.WifiNetwork#getFrequency"><a href=
"LuCI.Network.WifiNetwork.html#getFrequency">getFrequency
</a></li>
669 <li data-name=
"LuCI.Network.WifiNetwork#getI18n"><a href=
"LuCI.Network.WifiNetwork.html#getI18n">getI18n
</a></li>
671 <li data-name=
"LuCI.Network.WifiNetwork#getID"><a href=
"LuCI.Network.WifiNetwork.html#getID">getID
</a></li>
673 <li data-name=
"LuCI.Network.WifiNetwork#getIfname"><a href=
"LuCI.Network.WifiNetwork.html#getIfname">getIfname
</a></li>
675 <li data-name=
"LuCI.Network.WifiNetwork#getMeshID"><a href=
"LuCI.Network.WifiNetwork.html#getMeshID">getMeshID
</a></li>
677 <li data-name=
"LuCI.Network.WifiNetwork#getMode"><a href=
"LuCI.Network.WifiNetwork.html#getMode">getMode
</a></li>
679 <li data-name=
"LuCI.Network.WifiNetwork#getName"><a href=
"LuCI.Network.WifiNetwork.html#getName">getName
</a></li>
681 <li data-name=
"LuCI.Network.WifiNetwork#getNetwork"><a href=
"LuCI.Network.WifiNetwork.html#getNetwork">getNetwork
</a></li>
683 <li data-name=
"LuCI.Network.WifiNetwork#getNetworkNames"><a href=
"LuCI.Network.WifiNetwork.html#getNetworkNames">getNetworkNames
</a></li>
685 <li data-name=
"LuCI.Network.WifiNetwork#getNetworks"><a href=
"LuCI.Network.WifiNetwork.html#getNetworks">getNetworks
</a></li>
687 <li data-name=
"LuCI.Network.WifiNetwork#getNoise"><a href=
"LuCI.Network.WifiNetwork.html#getNoise">getNoise
</a></li>
689 <li data-name=
"LuCI.Network.WifiNetwork#getShortName"><a href=
"LuCI.Network.WifiNetwork.html#getShortName">getShortName
</a></li>
691 <li data-name=
"LuCI.Network.WifiNetwork#getSignal"><a href=
"LuCI.Network.WifiNetwork.html#getSignal">getSignal
</a></li>
693 <li data-name=
"LuCI.Network.WifiNetwork#getSignalLevel"><a href=
"LuCI.Network.WifiNetwork.html#getSignalLevel">getSignalLevel
</a></li>
695 <li data-name=
"LuCI.Network.WifiNetwork#getSignalPercent"><a href=
"LuCI.Network.WifiNetwork.html#getSignalPercent">getSignalPercent
</a></li>
697 <li data-name=
"LuCI.Network.WifiNetwork#getSSID"><a href=
"LuCI.Network.WifiNetwork.html#getSSID">getSSID
</a></li>
699 <li data-name=
"LuCI.Network.WifiNetwork#getTXPower"><a href=
"LuCI.Network.WifiNetwork.html#getTXPower">getTXPower
</a></li>
701 <li data-name=
"LuCI.Network.WifiNetwork#getTXPowerOffset"><a href=
"LuCI.Network.WifiNetwork.html#getTXPowerOffset">getTXPowerOffset
</a></li>
703 <li data-name=
"LuCI.Network.WifiNetwork#getWifiDevice"><a href=
"LuCI.Network.WifiNetwork.html#getWifiDevice">getWifiDevice
</a></li>
705 <li data-name=
"LuCI.Network.WifiNetwork#getWifiDeviceName"><a href=
"LuCI.Network.WifiNetwork.html#getWifiDeviceName">getWifiDeviceName
</a></li>
707 <li data-name=
"LuCI.Network.WifiNetwork#isClientDisconnectSupported"><a href=
"LuCI.Network.WifiNetwork.html#isClientDisconnectSupported">isClientDisconnectSupported
</a></li>
709 <li data-name=
"LuCI.Network.WifiNetwork#isDisabled"><a href=
"LuCI.Network.WifiNetwork.html#isDisabled">isDisabled
</a></li>
711 <li data-name=
"LuCI.Network.WifiNetwork#isUp"><a href=
"LuCI.Network.WifiNetwork.html#isUp">isUp
</a></li>
713 <li data-name=
"LuCI.Network.WifiNetwork#set"><a href=
"LuCI.Network.WifiNetwork.html#set">set
</a></li>
716 <ul class=
"events itemMembers">
721 <li class=
"item" data-name=
"LuCI.Poll">
723 <a href=
"LuCI.Poll.html">LuCI.Poll
</a>
726 <ul class=
"members itemMembers">
729 <ul class=
"typedefs itemMembers">
732 <ul class=
"typedefs itemMembers">
735 <ul class=
"methods itemMembers">
737 <span class=
"subtitle">Methods
</span>
739 <li data-name=
"LuCI.Poll#active"><a href=
"LuCI.Poll.html#active">active
</a></li>
741 <li data-name=
"LuCI.Poll#add"><a href=
"LuCI.Poll.html#add">add
</a></li>
743 <li data-name=
"LuCI.Poll#remove"><a href=
"LuCI.Poll.html#remove">remove
</a></li>
745 <li data-name=
"LuCI.Poll#start"><a href=
"LuCI.Poll.html#start">start
</a></li>
747 <li data-name=
"LuCI.Poll#stop"><a href=
"LuCI.Poll.html#stop">stop
</a></li>
750 <ul class=
"events itemMembers">
755 <li class=
"item" data-name=
"LuCI.Request">
757 <a href=
"LuCI.Request.html">LuCI.Request
</a>
760 <ul class=
"members itemMembers">
763 <ul class=
"typedefs itemMembers">
765 <span class=
"subtitle">Typedefs
</span>
767 <li data-name=
"LuCI.Request.interceptorFn"><a href=
"LuCI.Request.html#.interceptorFn">interceptorFn
</a></li>
769 <li data-name=
"LuCI.Request.RequestOptions"><a href=
"LuCI.Request.html#.RequestOptions">RequestOptions
</a></li>
772 <ul class=
"typedefs itemMembers">
775 <ul class=
"methods itemMembers">
777 <span class=
"subtitle">Methods
</span>
779 <li data-name=
"LuCI.Request#addInterceptor"><a href=
"LuCI.Request.html#addInterceptor">addInterceptor
</a></li>
781 <li data-name=
"LuCI.Request#expandURL"><a href=
"LuCI.Request.html#expandURL">expandURL
</a></li>
783 <li data-name=
"LuCI.Request#get"><a href=
"LuCI.Request.html#get">get
</a></li>
785 <li data-name=
"LuCI.Request#post"><a href=
"LuCI.Request.html#post">post
</a></li>
787 <li data-name=
"LuCI.Request#removeInterceptor"><a href=
"LuCI.Request.html#removeInterceptor">removeInterceptor
</a></li>
789 <li data-name=
"LuCI.Request#request"><a href=
"LuCI.Request.html#request">request
</a></li>
792 <ul class=
"events itemMembers">
797 <li class=
"item" data-name=
"LuCI.Request.poll">
799 <a href=
"LuCI.Request.poll.html">LuCI.Request.poll
</a>
802 <ul class=
"members itemMembers">
805 <ul class=
"typedefs itemMembers">
807 <span class=
"subtitle">Typedefs
</span>
809 <li data-name=
"LuCI.Request.poll~callbackFn"><a href=
"LuCI.Request.poll.html#~callbackFn">callbackFn
</a></li>
812 <ul class=
"typedefs itemMembers">
815 <ul class=
"methods itemMembers">
817 <span class=
"subtitle">Methods
</span>
819 <li data-name=
"LuCI.Request.poll#active"><a href=
"LuCI.Request.poll.html#active">active
</a></li>
821 <li data-name=
"LuCI.Request.poll#add"><a href=
"LuCI.Request.poll.html#add">add
</a></li>
823 <li data-name=
"LuCI.Request.poll#remove"><a href=
"LuCI.Request.poll.html#remove">remove
</a></li>
825 <li data-name=
"LuCI.Request.poll#start"><a href=
"LuCI.Request.poll.html#start">start
</a></li>
827 <li data-name=
"LuCI.Request.poll#stop"><a href=
"LuCI.Request.poll.html#stop">stop
</a></li>
830 <ul class=
"events itemMembers">
835 <li class=
"item" data-name=
"LuCI.Response">
837 <a href=
"LuCI.Response.html">LuCI.Response
</a>
840 <ul class=
"members itemMembers">
842 <span class=
"subtitle">Members
</span>
844 <li data-name=
"LuCI.Response#duration"><a href=
"LuCI.Response.html#duration">duration
</a></li>
846 <li data-name=
"LuCI.Response#headers"><a href=
"LuCI.Response.html#headers">headers
</a></li>
848 <li data-name=
"LuCI.Response#ok"><a href=
"LuCI.Response.html#ok">ok
</a></li>
850 <li data-name=
"LuCI.Response#status"><a href=
"LuCI.Response.html#status">status
</a></li>
852 <li data-name=
"LuCI.Response#statusText"><a href=
"LuCI.Response.html#statusText">statusText
</a></li>
854 <li data-name=
"LuCI.Response#url"><a href=
"LuCI.Response.html#url">url
</a></li>
857 <ul class=
"typedefs itemMembers">
860 <ul class=
"typedefs itemMembers">
863 <ul class=
"methods itemMembers">
865 <span class=
"subtitle">Methods
</span>
867 <li data-name=
"LuCI.Response#clone"><a href=
"LuCI.Response.html#clone">clone
</a></li>
869 <li data-name=
"LuCI.Response#json"><a href=
"LuCI.Response.html#json">json
</a></li>
871 <li data-name=
"LuCI.Response#text"><a href=
"LuCI.Response.html#text">text
</a></li>
874 <ul class=
"events itemMembers">
879 <li class=
"item" data-name=
"LuCI.rpc">
881 <a href=
"LuCI.rpc.html">LuCI.rpc
</a>
884 <ul class=
"members itemMembers">
887 <ul class=
"typedefs itemMembers">
889 <span class=
"subtitle">Typedefs
</span>
891 <li data-name=
"LuCI.rpc.DeclareOptions"><a href=
"LuCI.rpc.html#.DeclareOptions">DeclareOptions
</a></li>
893 <li data-name=
"LuCI.rpc~filterFn"><a href=
"LuCI.rpc.html#~filterFn">filterFn
</a></li>
895 <li data-name=
"LuCI.rpc~interceptorFn"><a href=
"LuCI.rpc.html#~interceptorFn">interceptorFn
</a></li>
897 <li data-name=
"LuCI.rpc~invokeFn"><a href=
"LuCI.rpc.html#~invokeFn">invokeFn
</a></li>
900 <ul class=
"typedefs itemMembers">
903 <ul class=
"methods itemMembers">
905 <span class=
"subtitle">Methods
</span>
907 <li data-name=
"LuCI.rpc#addInterceptor"><a href=
"LuCI.rpc.html#addInterceptor">addInterceptor
</a></li>
909 <li data-name=
"LuCI.rpc#declare"><a href=
"LuCI.rpc.html#declare">declare
</a></li>
911 <li data-name=
"LuCI.rpc#getBaseURL"><a href=
"LuCI.rpc.html#getBaseURL">getBaseURL
</a></li>
913 <li data-name=
"LuCI.rpc#getSessionID"><a href=
"LuCI.rpc.html#getSessionID">getSessionID
</a></li>
915 <li data-name=
"LuCI.rpc#getStatusText"><a href=
"LuCI.rpc.html#getStatusText">getStatusText
</a></li>
917 <li data-name=
"LuCI.rpc#list"><a href=
"LuCI.rpc.html#list">list
</a></li>
919 <li data-name=
"LuCI.rpc#removeInterceptor"><a href=
"LuCI.rpc.html#removeInterceptor">removeInterceptor
</a></li>
921 <li data-name=
"LuCI.rpc#setBaseURL"><a href=
"LuCI.rpc.html#setBaseURL">setBaseURL
</a></li>
923 <li data-name=
"LuCI.rpc#setSessionID"><a href=
"LuCI.rpc.html#setSessionID">setSessionID
</a></li>
926 <ul class=
"events itemMembers">
931 <li class=
"item" data-name=
"LuCI.uci">
933 <a href=
"LuCI.uci.html">LuCI.uci
</a>
936 <ul class=
"members itemMembers">
939 <ul class=
"typedefs itemMembers">
941 <span class=
"subtitle">Typedefs
</span>
943 <li data-name=
"LuCI.uci.ChangeRecord"><a href=
"LuCI.uci.html#.ChangeRecord">ChangeRecord
</a></li>
945 <li data-name=
"LuCI.uci.SectionObject"><a href=
"LuCI.uci.html#.SectionObject">SectionObject
</a></li>
947 <li data-name=
"LuCI.uci~sectionsFn"><a href=
"LuCI.uci.html#~sectionsFn">sectionsFn
</a></li>
950 <ul class=
"typedefs itemMembers">
953 <ul class=
"methods itemMembers">
955 <span class=
"subtitle">Methods
</span>
957 <li data-name=
"LuCI.uci#add"><a href=
"LuCI.uci.html#add">add
</a></li>
959 <li data-name=
"LuCI.uci#apply"><a href=
"LuCI.uci.html#apply">apply
</a></li>
961 <li data-name=
"LuCI.uci#changes"><a href=
"LuCI.uci.html#changes">changes
</a></li>
963 <li data-name=
"LuCI.uci#createSID"><a href=
"LuCI.uci.html#createSID">createSID
</a></li>
965 <li data-name=
"LuCI.uci#get"><a href=
"LuCI.uci.html#get">get
</a></li>
967 <li data-name=
"LuCI.uci#get_first"><a href=
"LuCI.uci.html#get_first">get_first
</a></li>
969 <li data-name=
"LuCI.uci#load"><a href=
"LuCI.uci.html#load">load
</a></li>
971 <li data-name=
"LuCI.uci#move"><a href=
"LuCI.uci.html#move">move
</a></li>
973 <li data-name=
"LuCI.uci#remove"><a href=
"LuCI.uci.html#remove">remove
</a></li>
975 <li data-name=
"LuCI.uci#resolveSID"><a href=
"LuCI.uci.html#resolveSID">resolveSID
</a></li>
977 <li data-name=
"LuCI.uci#save"><a href=
"LuCI.uci.html#save">save
</a></li>
979 <li data-name=
"LuCI.uci#sections"><a href=
"LuCI.uci.html#sections">sections
</a></li>
981 <li data-name=
"LuCI.uci#set"><a href=
"LuCI.uci.html#set">set
</a></li>
983 <li data-name=
"LuCI.uci#set_first"><a href=
"LuCI.uci.html#set_first">set_first
</a></li>
985 <li data-name=
"LuCI.uci#unload"><a href=
"LuCI.uci.html#unload">unload
</a></li>
987 <li data-name=
"LuCI.uci#unset"><a href=
"LuCI.uci.html#unset">unset
</a></li>
989 <li data-name=
"LuCI.uci#unset_first"><a href=
"LuCI.uci.html#unset_first">unset_first
</a></li>
992 <ul class=
"events itemMembers">
997 <li class=
"item" data-name=
"LuCI.view">
999 <a href=
"LuCI.view.html">LuCI.view
</a>
1002 <ul class=
"members itemMembers">
1005 <ul class=
"typedefs itemMembers">
1008 <ul class=
"typedefs itemMembers">
1011 <ul class=
"methods itemMembers">
1013 <span class=
"subtitle">Methods
</span>
1015 <li data-name=
"LuCI.view#addFooter"><a href=
"LuCI.view.html#addFooter">addFooter
</a></li>
1017 <li data-name=
"LuCI.view#handleReset"><a href=
"LuCI.view.html#handleReset">handleReset
</a></li>
1019 <li data-name=
"LuCI.view#handleSave"><a href=
"LuCI.view.html#handleSave">handleSave
</a></li>
1021 <li data-name=
"LuCI.view#handleSaveApply"><a href=
"LuCI.view.html#handleSaveApply">handleSaveApply
</a></li>
1023 <li data-name=
"LuCI.view#load"><a href=
"LuCI.view.html#load">load
</a></li>
1025 <li data-name=
"LuCI.view#render"><a href=
"LuCI.view.html#render">render
</a></li>
1028 <ul class=
"events itemMembers">
1033 <li class=
"item" data-name=
"LuCI.XHR">
1034 <span class=
"title">
1035 <a href=
"LuCI.XHR.html">LuCI.XHR
</a>
1038 <ul class=
"members itemMembers">
1041 <ul class=
"typedefs itemMembers">
1044 <ul class=
"typedefs itemMembers">
1047 <ul class=
"methods itemMembers">
1049 <span class=
"subtitle">Methods
</span>
1051 <li data-name=
"LuCI.XHR#abort"><a href=
"LuCI.XHR.html#abort">abort
</a></li>
1053 <li data-name=
"LuCI.XHR#busy"><a href=
"LuCI.XHR.html#busy">busy
</a></li>
1055 <li data-name=
"LuCI.XHR#cancel"><a href=
"LuCI.XHR.html#cancel">cancel
</a></li>
1057 <li data-name=
"LuCI.XHR#get"><a href=
"LuCI.XHR.html#get">get
</a></li>
1059 <li data-name=
"LuCI.XHR#post"><a href=
"LuCI.XHR.html#post">post
</a></li>
1061 <li data-name=
"LuCI.XHR#send_form"><a href=
"LuCI.XHR.html#send_form">send_form
</a></li>
1064 <ul class=
"events itemMembers">
1072 <h1 class=
"page-title" data-filename=
"luci.js.html">Source: luci.js
</h1>
1079 <pre id=
"source-code" class=
"prettyprint source "><code>/**
1083 * This is the LuCI base class. It is automatically instantiated and
1084 * accessible using the global `L` variable.
1086 * @param {Object} env
1087 * The environment settings to use for the LuCI runtime.
1090 (function(window, document, undefined) {
1093 /* Object.assign polyfill for IE */
1094 if (typeof Object.assign !== 'function') {
1095 Object.defineProperty(Object, 'assign', {
1096 value: function assign(target, varArgs) {
1098 throw new TypeError('Cannot convert undefined or null to object');
1100 var to = Object(target);
1102 for (var index =
1; index
< arguments.length; index++)
1103 if (arguments[index] != null)
1104 for (var nextKey in arguments[index])
1105 if (Object.prototype.hasOwnProperty.call(arguments[index], nextKey))
1106 to[nextKey] = arguments[index][nextKey];
1115 /* Promise.finally polyfill */
1116 if (typeof Promise.prototype.finally !== 'function') {
1117 Promise.prototype.finally = function(fn) {
1118 var onFinally = function(cb) {
1119 return Promise.resolve(fn.call(this)).then(cb);
1123 function(result) { return onFinally.call(this, function() { return result }) },
1124 function(reason) { return onFinally.call(this, function() { return Promise.reject(reason) }) }
1130 * Class declaration and inheritance helper
1133 var toCamelCase = function(s) {
1134 return s.replace(/(?:^|[\. -])(.)/g, function(m0, m1) { return m1.toUpperCase() });
1143 * `LuCI.Class` is the abstract base class all LuCI classes inherit from.
1145 * It provides simple means to create subclasses of given classes and
1146 * implements prototypal inheritance.
1148 var superContext = null, Class = Object.assign(function() {}, {
1150 * Extends this base class with the properties described in
1151 * `properties` and returns a new subclassed Class instance
1153 * @memberof LuCI.Class
1155 * @param {Object
<string, *
>} properties
1156 * An object describing the properties to add to the new
1159 * @returns {LuCI.Class}
1160 * Returns a new LuCI.Class sublassed from this class, extended
1161 * by the given properties and with its prototype set to this base
1162 * class to enable inheritance. The resulting value represents a
1163 * class constructor and can be instantiated with `new`.
1165 extend: function(properties) {
1167 __base__: { value: this.prototype },
1168 __name__: { value: properties.__name__ || 'anonymous' }
1171 var ClassConstructor = function() {
1172 if (!(this instanceof ClassConstructor))
1173 throw new TypeError('Constructor must not be called without
"new"');
1175 if (Object.getPrototypeOf(this).hasOwnProperty('__init__')) {
1176 if (typeof(this.__init__) != 'function')
1177 throw new TypeError('Class __init__ member is not a function');
1179 this.__init__.apply(this, arguments)
1182 this.super('__init__', arguments);
1186 for (var key in properties)
1187 if (!props[key]
&& properties.hasOwnProperty(key))
1188 props[key] = { value: properties[key], writable: true };
1190 ClassConstructor.prototype = Object.create(this.prototype, props);
1191 ClassConstructor.prototype.constructor = ClassConstructor;
1192 Object.assign(ClassConstructor, this);
1193 ClassConstructor.displayName = toCamelCase(props.__name__.value + 'Class');
1195 return ClassConstructor;
1199 * Extends this base class with the properties described in
1200 * `properties`, instantiates the resulting subclass using
1201 * the additional optional arguments passed to this function
1202 * and returns the resulting subclassed Class instance.
1204 * This function serves as a convenience shortcut for
1205 * {@link LuCI.Class.extend Class.extend()} and subsequent
1208 * @memberof LuCI.Class
1210 * @param {Object
<string, *
>} properties
1211 * An object describing the properties to add to the new
1214 * @param {...*} [new_args]
1215 * Specifies arguments to be passed to the subclass constructor
1216 * as-is in order to instantiate the new subclass.
1218 * @returns {LuCI.Class}
1219 * Returns a new LuCI.Class instance extended by the given
1220 * properties with its prototype set to this base class to
1221 * enable inheritance.
1223 singleton: function(properties /*, ... */) {
1224 return Class.extend(properties)
1225 .instantiate(Class.prototype.varargs(arguments,
1));
1229 * Calls the class constructor using `new` with the given argument
1230 * array being passed as variadic parameters to the constructor.
1232 * @memberof LuCI.Class
1234 * @param {Array
<*
>} params
1235 * An array of arbitrary values which will be passed as arguments
1236 * to the constructor function.
1238 * @param {...*} [new_args]
1239 * Specifies arguments to be passed to the subclass constructor
1240 * as-is in order to instantiate the new subclass.
1242 * @returns {LuCI.Class}
1243 * Returns a new LuCI.Class instance extended by the given
1244 * properties with its prototype set to this base class to
1245 * enable inheritance.
1247 instantiate: function(args) {
1248 return new (Function.prototype.bind.apply(this,
1249 Class.prototype.varargs(args,
0, null)))();
1253 call: function(self, method) {
1254 if (typeof(this.prototype[method]) != 'function')
1255 throw new ReferenceError(method + ' is not defined in class');
1257 return this.prototype[method].apply(self, self.varargs(arguments,
1));
1261 * Checks whether the given class value is a subclass of this class.
1263 * @memberof LuCI.Class
1265 * @param {LuCI.Class} classValue
1266 * The class object to test.
1268 * @returns {boolean}
1269 * Returns `true` when the given `classValue` is a subclass of this
1270 * class or `false` if the given value is not a valid class or not
1271 * a subclass of this class'.
1273 isSubclass: function(classValue) {
1274 return (classValue != null
&&
1275 typeof(classValue) == 'function'
&&
1276 classValue.prototype instanceof this);
1281 * Extract all values from the given argument array beginning from
1282 * `offset` and prepend any further given optional parameters to
1283 * the beginning of the resulting array copy.
1285 * @memberof LuCI.Class
1288 * @param {Array
<*
>} args
1289 * The array to extract the values from.
1291 * @param {number} offset
1292 * The offset from which to extract the values. An offset of `
0`
1293 * would copy all values till the end.
1295 * @param {...*} [extra_args]
1296 * Extra arguments to add to prepend to the resultung array.
1298 * @returns {Array
<*
>}
1299 * Returns a new array consisting of the optional extra arguments
1300 * and the values extracted from the `args` array beginning with
1303 varargs: function(args, offset /*, ... */) {
1304 return Array.prototype.slice.call(arguments,
2)
1305 .concat(Array.prototype.slice.call(args, offset));
1309 * Walks up the parent class chain and looks for a class member
1310 * called `key` in any of the parent classes this class inherits
1311 * from. Returns the member value of the superclass or calls the
1312 * member as function and returns its return value when the
1313 * optional `callArgs` array is given.
1315 * This function has two signatures and is sensitive to the
1316 * amount of arguments passed to it:
1317 * - `super('key')` -
1318 * Returns the value of `key` when found within one of the
1320 * - `super('key', ['arg1', 'arg2'])` -
1321 * Calls the `key()` method with parameters `arg1` and `arg2`
1322 * when found within one of the parent classes.
1324 * @memberof LuCI.Class
1327 * @param {string} key
1328 * The name of the superclass member to retrieve.
1330 * @param {Array
<*
>} [callArgs]
1331 * An optional array of function call parameters to use. When
1332 * this parameter is specified, the found member value is called
1333 * as function using the values of this array as arguments.
1335 * @throws {ReferenceError}
1336 * Throws a `ReferenceError` when `callArgs` are specified and
1337 * the found member named by `key` is not a function value.
1340 * Returns the value of the found member or the return value of
1341 * the call to the found method. Returns `null` when no member
1342 * was found in the parent class chain or when the call to the
1343 * superclass method returned `null`.
1345 super: function(key, callArgs) {
1346 for (superContext = Object.getPrototypeOf(superContext ||
1347 Object.getPrototypeOf(this));
1348 superContext
&& !superContext.hasOwnProperty(key);
1349 superContext = Object.getPrototypeOf(superContext)) { }
1354 var res = superContext[key];
1356 if (arguments.length
> 1) {
1357 if (typeof(res) != 'function')
1358 throw new ReferenceError(key + ' is not a function in base class');
1360 if (typeof(callArgs) != 'object')
1361 callArgs = this.varargs(arguments,
1);
1363 res = res.apply(this, callArgs);
1366 superContext = null;
1372 * Returns a string representation of this class.
1375 * Returns a string representation of this class containing the
1376 * constructor functions `displayName` and describing the class
1377 * members and their respective types.
1379 toString: function() {
1380 var s = '[' + this.constructor.displayName + ']', f = true;
1381 for (var k in this) {
1382 if (this.hasOwnProperty(k)) {
1383 s += (f ? ' {\n' : '') + ' ' + k + ': ' + typeof(this[k]) + '\n';
1387 return s + (f ? '' : '}');
1399 * The `Headers` class is an internal utility class exposed in HTTP
1400 * response objects using the `response.headers` property.
1402 var Headers = Class.extend(/** @lends LuCI.Headers.prototype */ {
1403 __name__: 'LuCI.XHR.Headers',
1404 __init__: function(xhr) {
1405 var hdrs = this.headers = {};
1406 xhr.getAllResponseHeaders().split(/\r\n/).forEach(function(line) {
1407 var m = /^([^:]+):(.*)$/.exec(line);
1409 hdrs[m[
1].trim().toLowerCase()] = m[
2].trim();
1414 * Checks whether the given header name is present.
1415 * Note: Header-Names are case-insensitive.
1418 * @memberof LuCI.Headers
1419 * @param {string} name
1420 * The header name to check
1422 * @returns {boolean}
1423 * Returns `true` if the header name is present, `false` otherwise
1425 has: function(name) {
1426 return this.headers.hasOwnProperty(String(name).toLowerCase());
1430 * Returns the value of the given header name.
1431 * Note: Header-Names are case-insensitive.
1434 * @memberof LuCI.Headers
1435 * @param {string} name
1436 * The header name to read
1438 * @returns {string|null}
1439 * The value of the given header name or `null` if the header isn't present.
1441 get: function(name) {
1442 var key = String(name).toLowerCase();
1443 return this.headers.hasOwnProperty(key) ? this.headers[key] : null;
1453 * The `Response` class is an internal utility class representing HTTP responses.
1455 var Response = Class.extend({
1456 __name__: 'LuCI.XHR.Response',
1457 __init__: function(xhr, url, duration, headers, content) {
1459 * Describes whether the response is successful (status codes `
200.
.299`) or not
1461 * @memberof LuCI.Response
1465 this.ok = (xhr.status
>=
200 && xhr.status
<=
299);
1468 * The numeric HTTP status code of the response
1470 * @memberof LuCI.Response
1474 this.status = xhr.status;
1477 * The HTTP status description message of the response
1479 * @memberof LuCI.Response
1483 this.statusText = xhr.statusText;
1486 * The HTTP headers of the response
1488 * @memberof LuCI.Response
1490 * @type {LuCI.Headers}
1492 this.headers = (headers != null) ? headers : new Headers(xhr);
1495 * The total duration of the HTTP request in milliseconds
1497 * @memberof LuCI.Response
1501 this.duration = duration;
1504 * The final URL of the request, i.e. after following redirects.
1506 * @memberof LuCI.Response
1515 if (content != null
&& typeof(content) == 'object') {
1516 this.responseJSON = content;
1517 this.responseText = null;
1519 else if (content != null) {
1520 this.responseJSON = null;
1521 this.responseText = String(content);
1524 this.responseJSON = null;
1525 this.responseText = xhr.responseText;
1530 * Clones the given response object, optionally overriding the content
1531 * of the cloned instance.
1534 * @memberof LuCI.Response
1535 * @param {*} [content]
1536 * Override the content of the cloned response. Object values will be
1537 * treated as JSON response data, all other types will be converted
1538 * using `String()` and treated as response text.
1540 * @returns {LuCI.Response}
1541 * The cloned `Response` instance.
1543 clone: function(content) {
1544 var copy = new Response(this.xhr, this.url, this.duration, this.headers, content);
1547 copy.status = this.status;
1548 copy.statusText = this.statusText;
1554 * Access the response content as JSON data.
1557 * @memberof LuCI.Response
1558 * @throws {SyntaxError}
1559 * Throws `SyntaxError` if the content isn't valid JSON.
1562 * The parsed JSON data.
1565 if (this.responseJSON == null)
1566 this.responseJSON = JSON.parse(this.responseText);
1568 return this.responseJSON;
1572 * Access the response content as string.
1575 * @memberof LuCI.Response
1577 * The response content.
1580 if (this.responseText == null
&& this.responseJSON != null)
1581 this.responseText = JSON.stringify(this.responseJSON);
1583 return this.responseText;
1588 var requestQueue = [];
1590 function isQueueableRequest(opt) {
1594 if (opt.method != 'POST' || typeof(opt.content) != 'object')
1597 if (opt.nobatch === true)
1600 var rpcBaseURL = Request.expandURL(classes.rpc.getBaseURL());
1602 return (rpcBaseURL != null
&& opt.url.indexOf(rpcBaseURL) ==
0);
1605 function flushRequestQueue() {
1606 if (!requestQueue.length)
1609 var reqopt = Object.assign({}, requestQueue[
0][
0], { content: [], nobatch: true }),
1612 for (var i =
0; i
< requestQueue.length; i++) {
1613 batch[i] = requestQueue[i];
1614 reqopt.content[i] = batch[i][
0].content;
1617 requestQueue.length =
0;
1619 Request.request(rpcBaseURL, reqopt).then(function(reply) {
1620 var json = null, req = null;
1622 try { json = reply.json() }
1625 while ((req = batch.shift()) != null)
1626 if (Array.isArray(json)
&& json.length)
1627 req[
2].call(reqopt, reply.clone(json.shift()));
1629 req[
1].call(reqopt, new Error('No related RPC reply'));
1630 }).catch(function(error) {
1633 while ((req = batch.shift()) != null)
1634 req[
1].call(reqopt, error);
1644 * The `Request` class allows initiating HTTP requests and provides utilities
1645 * for dealing with responses.
1647 var Request = Class.singleton(/** @lends LuCI.Request.prototype */ {
1648 __name__: 'LuCI.Request',
1653 * Turn the given relative URL into an absolute URL if necessary.
1656 * @memberof LuCI.Request
1657 * @param {string} url
1658 * The URL to convert.
1661 * The absolute URL derived from the given one, or the original URL
1662 * if it already was absolute.
1664 expandURL: function(url) {
1665 if (!/^(?:[^/]+:)?\/\//.test(url))
1666 url = location.protocol + '//' + location.host + url;
1672 * @typedef {Object} RequestOptions
1673 * @memberof LuCI.Request
1675 * @property {string} [method=GET]
1676 * The HTTP method to use, e.g. `GET` or `POST`.
1678 * @property {Object
<string, Object|string
>} [query]
1679 * Query string data to append to the URL. Non-string values of the
1680 * given object will be converted to JSON.
1682 * @property {boolean} [cache=false]
1683 * Specifies whether the HTTP response may be retrieved from cache.
1685 * @property {string} [username]
1686 * Provides a username for HTTP basic authentication.
1688 * @property {string} [password]
1689 * Provides a password for HTTP basic authentication.
1691 * @property {number} [timeout]
1692 * Specifies the request timeout in seconds.
1694 * @property {boolean} [credentials=false]
1695 * Whether to include credentials such as cookies in the request.
1697 * @property {*} [content]
1698 * Specifies the HTTP message body to send along with the request.
1699 * If the value is a function, it is invoked and the return value
1700 * used as content, if it is a FormData instance, it is used as-is,
1701 * if it is an object, it will be converted to JSON, in all other
1702 * cases it is converted to a string.
1704 * @property {Object
<string, string
>} [header]
1705 * Specifies HTTP headers to set for the request.
1707 * @property {function} [progress]
1708 * An optional request callback function which receives ProgressEvent
1709 * instances as sole argument during the HTTP request transfer.
1713 * Initiate an HTTP request to the given target.
1716 * @memberof LuCI.Request
1717 * @param {string} target
1718 * The URL to request.
1720 * @param {LuCI.Request.RequestOptions} [options]
1721 * Additional options to configure the request.
1723 * @returns {Promise
<LuCI.Response
>}
1724 * The resulting HTTP response.
1726 request: function(target, options) {
1727 var state = { xhr: new XMLHttpRequest(), url: this.expandURL(target), start: Date.now() },
1728 opt = Object.assign({}, options, state),
1731 callback = this.handleReadyStateChange;
1733 return new Promise(function(resolveFn, rejectFn) {
1734 opt.xhr.onreadystatechange = callback.bind(opt, resolveFn, rejectFn);
1735 opt.method = String(opt.method || 'GET').toUpperCase();
1737 if ('query' in opt) {
1738 var q = (opt.query != null) ? Object.keys(opt.query).map(function(k) {
1739 if (opt.query[k] != null) {
1740 var v = (typeof(opt.query[k]) == 'object')
1741 ? JSON.stringify(opt.query[k])
1742 : String(opt.query[k]);
1744 return '%s=%s'.format(encodeURIComponent(k), encodeURIComponent(v));
1747 return encodeURIComponent(k);
1749 }).join('
&') : '';
1752 switch (opt.method) {
1756 opt.url += ((/\?/).test(opt.url) ? '
&' : '?') + q;
1760 if (content == null) {
1762 contenttype = 'application/x-www-form-urlencoded';
1769 opt.url += ((/\?/).test(opt.url) ? '
&' : '?') + (new Date()).getTime();
1771 if (isQueueableRequest(opt)) {
1772 requestQueue.push([opt, rejectFn, resolveFn]);
1773 requestAnimationFrame(flushRequestQueue);
1777 if ('username' in opt
&& 'password' in opt)
1778 opt.xhr.open(opt.method, opt.url, true, opt.username, opt.password);
1780 opt.xhr.open(opt.method, opt.url, true);
1782 opt.xhr.responseType = 'text';
1784 if ('overrideMimeType' in opt.xhr)
1785 opt.xhr.overrideMimeType('application/octet-stream');
1787 if ('timeout' in opt)
1788 opt.xhr.timeout = +opt.timeout;
1790 if ('credentials' in opt)
1791 opt.xhr.withCredentials = !!opt.credentials;
1793 if (opt.content != null) {
1794 switch (typeof(opt.content)) {
1796 content = opt.content(xhr);
1800 if (!(opt.content instanceof FormData)) {
1801 content = JSON.stringify(opt.content);
1802 contenttype = 'application/json';
1805 content = opt.content;
1810 content = String(opt.content);
1814 if ('headers' in opt)
1815 for (var header in opt.headers)
1816 if (opt.headers.hasOwnProperty(header)) {
1817 if (header.toLowerCase() != 'content-type')
1818 opt.xhr.setRequestHeader(header, opt.headers[header]);
1820 contenttype = opt.headers[header];
1823 if ('progress' in opt
&& 'upload' in opt.xhr)
1824 opt.xhr.upload.addEventListener('progress', opt.progress);
1826 if (contenttype != null)
1827 opt.xhr.setRequestHeader('Content-Type', contenttype);
1830 opt.xhr.send(content);
1833 rejectFn.call(opt, e);
1838 handleReadyStateChange: function(resolveFn, rejectFn, ev) {
1840 duration = Date.now() - this.start;
1842 if (xhr.readyState !==
4)
1845 if (xhr.status ===
0 && xhr.statusText === '') {
1846 if (duration
>= this.timeout)
1847 rejectFn.call(this, new Error('XHR request timed out'));
1849 rejectFn.call(this, new Error('XHR request aborted by browser'));
1852 var response = new Response(
1853 xhr, xhr.responseURL || this.url, duration);
1855 Promise.all(Request.interceptors.map(function(fn) { return fn(response) }))
1856 .then(resolveFn.bind(this, response))
1857 .catch(rejectFn.bind(this));
1862 * Initiate an HTTP GET request to the given target.
1865 * @memberof LuCI.Request
1866 * @param {string} target
1867 * The URL to request.
1869 * @param {LuCI.Request.RequestOptions} [options]
1870 * Additional options to configure the request.
1872 * @returns {Promise
<LuCI.Response
>}
1873 * The resulting HTTP response.
1875 get: function(url, options) {
1876 return this.request(url, Object.assign({ method: 'GET' }, options));
1880 * Initiate an HTTP POST request to the given target.
1883 * @memberof LuCI.Request
1884 * @param {string} target
1885 * The URL to request.
1888 * The request data to send, see {@link LuCI.Request.RequestOptions} for details.
1890 * @param {LuCI.Request.RequestOptions} [options]
1891 * Additional options to configure the request.
1893 * @returns {Promise
<LuCI.Response
>}
1894 * The resulting HTTP response.
1896 post: function(url, data, options) {
1897 return this.request(url, Object.assign({ method: 'POST', content: data }, options));
1901 * Interceptor functions are invoked whenever an HTTP reply is received, in the order
1902 * these functions have been registered.
1903 * @callback LuCI.Request.interceptorFn
1904 * @param {LuCI.Response} res
1905 * The HTTP response object
1909 * Register an HTTP response interceptor function. Interceptor
1910 * functions are useful to perform default actions on incoming HTTP
1911 * responses, such as checking for expired authentication or for
1912 * implementing request retries before returning a failure.
1915 * @memberof LuCI.Request
1916 * @param {LuCI.Request.interceptorFn} interceptorFn
1917 * The interceptor function to register.
1919 * @returns {LuCI.Request.interceptorFn}
1920 * The registered function.
1922 addInterceptor: function(interceptorFn) {
1923 if (typeof(interceptorFn) == 'function')
1924 this.interceptors.push(interceptorFn);
1925 return interceptorFn;
1929 * Remove an HTTP response interceptor function. The passed function
1930 * value must be the very same value that was used to register the
1934 * @memberof LuCI.Request
1935 * @param {LuCI.Request.interceptorFn} interceptorFn
1936 * The interceptor function to remove.
1938 * @returns {boolean}
1939 * Returns `true` if any function has been removed, else `false`.
1941 removeInterceptor: function(interceptorFn) {
1942 var oldlen = this.interceptors.length, i = oldlen;
1944 if (this.interceptors[i] === interceptorFn)
1945 this.interceptors.splice(i,
1);
1946 return (this.interceptors.length
< oldlen);
1951 * @memberof LuCI.Request
1955 * The `Request.poll` class provides some convience wrappers around
1956 * {@link LuCI.Poll} mainly to simplify registering repeating HTTP
1957 * request calls as polling functions.
1961 * The callback function is invoked whenever an HTTP reply to a
1962 * polled request is received or when the polled request timed
1965 * @callback LuCI.Request.poll~callbackFn
1966 * @param {LuCI.Response} res
1967 * The HTTP response object.
1970 * The response JSON if the response could be parsed as such,
1973 * @param {number} duration
1974 * The total duration of the request in milliseconds.
1978 * Register a repeating HTTP request with an optional callback
1979 * to invoke whenever a response for the request is received.
1982 * @memberof LuCI.Request.poll
1983 * @param {number} interval
1984 * The poll interval in seconds.
1986 * @param {string} url
1987 * The URL to request on each poll.
1989 * @param {LuCI.Request.RequestOptions} [options]
1990 * Additional options to configure the request.
1992 * @param {LuCI.Request.poll~callbackFn} [callback]
1993 * {@link LuCI.Request.poll~callbackFn Callback} function to
1994 * invoke for each HTTP reply.
1996 * @throws {TypeError}
1997 * Throws `TypeError` when an invalid interval was passed.
1999 * @returns {function}
2000 * Returns the internally created poll function.
2002 add: function(interval, url, options, callback) {
2003 if (isNaN(interval) || interval
<=
0)
2004 throw new TypeError('Invalid poll interval');
2006 var ival = interval
>>> 0,
2007 opts = Object.assign({}, options, { timeout: ival *
1000 -
5 });
2009 var fn = function() {
2010 return Request.request(url, options).then(function(res) {
2015 callback(res, res.json(), res.duration);
2018 callback(res, null, res.duration);
2023 return (Poll.add(fn, ival) ? fn : null);
2027 * Remove a polling request that has been previously added using `add()`.
2028 * This function is essentially a wrapper around
2029 * {@link LuCI.Poll.remove LuCI.Poll.remove()}.
2032 * @memberof LuCI.Request.poll
2033 * @param {function} entry
2034 * The poll function returned by {@link LuCI.Request.poll#add add()}.
2036 * @returns {boolean}
2037 * Returns `true` if any function has been removed, else `false`.
2039 remove: function(entry) { return Poll.remove(entry) },
2042 * Alias for {@link LuCI.Poll.start LuCI.Poll.start()}.
2045 * @memberof LuCI.Request.poll
2047 start: function() { return Poll.start() },
2050 * Alias for {@link LuCI.Poll.stop LuCI.Poll.stop()}.
2053 * @memberof LuCI.Request.poll
2055 stop: function() { return Poll.stop() },
2058 * Alias for {@link LuCI.Poll.active LuCI.Poll.active()}.
2061 * @memberof LuCI.Request.poll
2063 active: function() { return Poll.active() }
2073 * The `Poll` class allows registering and unregistering poll actions,
2074 * as well as starting, stopping and querying the state of the polling
2077 var Poll = Class.singleton(/** @lends LuCI.Poll.prototype */ {
2078 __name__: 'LuCI.Poll',
2083 * Add a new operation to the polling loop. If the polling loop is not
2084 * already started at this point, it will be implicitely started.
2087 * @memberof LuCI.Poll
2088 * @param {function} fn
2089 * The function to invoke on each poll interval.
2091 * @param {number} interval
2092 * The poll interval in seconds.
2094 * @throws {TypeError}
2095 * Throws `TypeError` when an invalid interval was passed.
2097 * @returns {boolean}
2098 * Returns `true` if the function has been added or `false` if it
2099 * already is registered.
2101 add: function(fn, interval) {
2102 if (interval == null || interval
<=
0)
2103 interval = window.L ? window.L.env.pollinterval : null;
2105 if (isNaN(interval) || typeof(fn) != 'function')
2106 throw new TypeError('Invalid argument to LuCI.Poll.add()');
2108 for (var i =
0; i
< this.queue.length; i++)
2109 if (this.queue[i].fn === fn)
2120 if (this.tick != null
&& !this.active())
2127 * Remove an operation from the polling loop. If no further operatons
2128 * are registered, the polling loop is implicitely stopped.
2131 * @memberof LuCI.Poll
2132 * @param {function} fn
2133 * The function to remove.
2135 * @throws {TypeError}
2136 * Throws `TypeError` when the given argument isn't a function.
2138 * @returns {boolean}
2139 * Returns `true` if the function has been removed or `false` if it
2142 remove: function(fn) {
2143 if (typeof(fn) != 'function')
2144 throw new TypeError('Invalid argument to LuCI.Poll.remove()');
2146 var len = this.queue.length;
2148 for (var i = len; i
> 0; i--)
2149 if (this.queue[i-
1].fn === fn)
2150 this.queue.splice(i-
1,
1);
2152 if (!this.queue.length
&& this.stop())
2155 return (this.queue.length != len);
2159 * (Re)start the polling loop. Dispatches a custom `poll-start` event
2160 * to the `document` object upon successful start.
2163 * @memberof LuCI.Poll
2164 * @returns {boolean}
2165 * Returns `true` if polling has been started (or if no functions
2166 * where registered) or `false` when the polling loop already runs.
2174 if (this.queue.length) {
2175 this.timer = window.setInterval(this.step,
1000);
2177 document.dispatchEvent(new CustomEvent('poll-start'));
2184 * Stop the polling loop. Dispatches a custom `poll-stop` event
2185 * to the `document` object upon successful stop.
2188 * @memberof LuCI.Poll
2189 * @returns {boolean}
2190 * Returns `true` if polling has been stopped or `false` if it din't
2191 * run to begin with.
2197 document.dispatchEvent(new CustomEvent('poll-stop'));
2198 window.clearInterval(this.timer);
2206 for (var i =
0, e = null; (e = Poll.queue[i]) != null; i++) {
2207 if ((Poll.tick % e.i) !=
0)
2215 Promise.resolve(e.fn()).finally((function() { this.r = true }).bind(e));
2218 Poll.tick = (Poll.tick +
1) % Math.pow(
2,
32);
2222 * Test whether the polling loop is running.
2225 * @memberof LuCI.Poll
2226 * @returns {boolean} - Returns `true` if polling is active, else `false`.
2228 active: function() {
2229 return (this.timer != null);
2234 var dummyElem = null,
2236 originalCBIInit = null,
2241 var LuCI = Class.extend(/** @lends LuCI.prototype */ {
2243 __init__: function(env) {
2245 document.querySelectorAll('script[src*=
"/luci.js"]').forEach(function(s) {
2246 if (env.base_url == null || env.base_url == '') {
2247 var m = (s.getAttribute('src') || '').match(/^(.*)\/luci\.js(?:\?v=([^?]+))?$/);
2249 env.base_url = m[
1];
2250 env.resource_version = m[
2];
2255 if (env.base_url == null)
2256 this.error('InternalError', 'Cannot find url of luci.js');
2258 Object.assign(this.env, env);
2260 document.addEventListener('poll-start', function(ev) {
2261 document.querySelectorAll('[id^=
"xhr_poll_status"]').forEach(function(e) {
2262 e.style.display = (e.id == 'xhr_poll_status_off') ? 'none' : '';
2266 document.addEventListener('poll-stop', function(ev) {
2267 document.querySelectorAll('[id^=
"xhr_poll_status"]').forEach(function(e) {
2268 e.style.display = (e.id == 'xhr_poll_status_on') ? 'none' : '';
2272 var domReady = new Promise(function(resolveFn, rejectFn) {
2273 document.addEventListener('DOMContentLoaded', resolveFn);
2279 this.require('rpc'),
2280 this.require('form'),
2281 this.probeRPCBaseURL()
2282 ]).then(this.setupDOM.bind(this)).catch(this.error);
2284 originalCBIInit = window.cbi_init;
2285 window.cbi_init = function() {};
2289 * Captures the current stack trace and throws an error of the
2290 * specified type as a new exception. Also logs the exception as
2291 * error to the debug console if it is available.
2296 * @param {Error|string} [type=Error]
2297 * Either a string specifying the type of the error to throw or an
2298 * existing `Error` instance to copy.
2300 * @param {string} [fmt=Unspecified error]
2301 * A format string which is used to form the error message, together
2302 * with all subsequent optional arguments.
2304 * @param {...*} [args]
2305 * Zero or more variable arguments to the supplied format string.
2308 * Throws the created error object with the captured stack trace
2309 * appended to the message and the type set to the given type
2310 * argument or copied from the given error instance.
2312 raise: function(type, fmt /*, ...*/) {
2314 msg = fmt ? String.prototype.format.apply(fmt, this.varargs(arguments,
2)) : null,
2317 if (type instanceof Error) {
2321 e.message = msg + ': ' + e.message;
2324 try { throw new Error('stacktrace') }
2325 catch (e2) { stack = (e2.stack || '').split(/\n/) }
2327 e = new (window[type || 'Error'] || Error)(msg || 'Unspecified error');
2328 e.name = type || 'Error';
2331 stack = (stack || []).map(function(frame) {
2332 frame = frame.replace(/(.*?)@(.+):(\d+):(\d+)/g, 'at $
1 ($
2:$
3:$
4)').trim();
2333 return frame ? ' ' + frame : '';
2336 if (!/^ at /.test(stack[
0]))
2339 if (/\braise /.test(stack[
0]))
2342 if (/\berror /.test(stack[
0]))
2346 e.message += '\n' + stack.join('\n');
2348 if (window.console
&& console.debug)
2355 * A wrapper around {@link LuCI#raise raise()} which also renders
2356 * the error either as modal overlay when `ui.js` is already loaed
2357 * or directly into the view body.
2362 * @param {Error|string} [type=Error]
2363 * Either a string specifying the type of the error to throw or an
2364 * existing `Error` instance to copy.
2366 * @param {string} [fmt=Unspecified error]
2367 * A format string which is used to form the error message, together
2368 * with all subsequent optional arguments.
2370 * @param {...*} [args]
2371 * Zero or more variable arguments to the supplied format string.
2374 * Throws the created error object with the captured stack trace
2375 * appended to the message and the type set to the given type
2376 * argument or copied from the given error instance.
2378 error: function(type, fmt /*, ...*/) {
2380 L.raise.apply(L, Array.prototype.slice.call(arguments));
2385 L.ui.addNotification(e.name || _('Runtime error'),
2386 E('pre', {}, e.message), 'danger');
2388 L.dom.content(document.querySelector('#maincontent'),
2389 E('pre', { 'class': 'alert-message error' }, e.message));
2399 * Return a bound function using the given `self` as `this` context
2400 * and any further arguments as parameters to the bound function.
2405 * @param {function} fn
2406 * The function to bind.
2409 * The value to bind as `this` context to the specified function.
2411 * @param {...*} [args]
2412 * Zero or more variable arguments which are bound to the function
2415 * @returns {function}
2416 * Returns the bound function.
2418 bind: function(fn, self /*, ... */) {
2419 return Function.prototype.bind.apply(fn, this.varargs(arguments,
2, self));
2423 * Load an additional LuCI JavaScript class and its dependencies,
2424 * instantiate it and return the resulting class instance. Each
2425 * class is only loaded once. Subsequent attempts to load the same
2426 * class will return the already instantiated class.
2431 * @param {string} name
2432 * The name of the class to load in dotted notation. Dots will
2433 * be replaced by spaces and joined with the runtime-determined
2434 * base URL of LuCI.js to form an absolute URL to load the class
2437 * @throws {DependencyError}
2438 * Throws a `DependencyError` when the class to load includes
2439 * circular dependencies.
2441 * @throws {NetworkError}
2442 * Throws `NetworkError` when the underlying {@link LuCI.Request}
2445 * @throws {SyntaxError}
2446 * Throws `SyntaxError` when the loaded class file code cannot
2447 * be interpreted by `eval`.
2449 * @throws {TypeError}
2450 * Throws `TypeError` when the class file could be loaded and
2451 * interpreted, but when invoking its code did not yield a valid
2454 * @returns {Promise
<LuCI#Class
>}
2455 * Returns the instantiated class.
2457 require: function(name, from) {
2458 var L = this, url = null, from = from || [];
2460 /* Class already loaded */
2461 if (classes[name] != null) {
2462 /* Circular dependency */
2463 if (from.indexOf(name) != -
1)
2464 L.raise('DependencyError',
2465 'Circular dependency: class
"%s" depends on
"%s"',
2466 name, from.join('
" which depends on "'));
2468 return Promise.resolve(classes[name]);
2471 url = '%s/%s.js%s'.format(L.env.base_url, name.replace(/\./g, '/'), (L.env.resource_version ? '?v=' + L.env.resource_version : ''));
2472 from = [ name ].concat(from);
2474 var compileClass = function(res) {
2476 L.raise('NetworkError',
2477 'HTTP error %d while loading class file
"%s"', res.status, url);
2479 var source = res.text(),
2480 requirematch = /^require[ \t]+(\S+)(?:[ \t]+as[ \t]+([a-zA-Z_]\S*))?$/,
2481 strictmatch = /^use[ \t]+strict$/,
2485 /* find require statements in source */
2486 for (var i =
0, off = -
1, quote = -
1, esc = false; i
< source.length; i++) {
2487 var chr = source.charCodeAt(i);
2492 else if (chr ==
92) {
2495 else if (chr == quote) {
2496 var s = source.substring(off, i),
2497 m = requirematch.exec(s);
2500 var dep = m[
1], as = m[
2] || dep.replace(/[^a-zA-Z0-
9_]/g, '_');
2501 depends.push(L.require(dep, from));
2504 else if (!strictmatch.exec(s)) {
2511 else if (quote == -
1 && (chr ==
34 || chr ==
39)) {
2517 /* load dependencies and instantiate class */
2518 return Promise.all(depends).then(function(instances) {
2519 var _factory, _class;
2523 '(function(window, document, L%s) { %s })\n\n//# sourceURL=%s\n'
2524 .format(args, source, res.url));
2527 L.raise('SyntaxError', '%s\n in %s:%s',
2528 error.message, res.url, error.lineNumber || '?');
2531 _factory.displayName = toCamelCase(name + 'ClassFactory');
2532 _class = _factory.apply(_factory, [window, document, L].concat(instances));
2534 if (!Class.isSubclass(_class))
2535 L.error('TypeError', '
"%s" factory yields invalid constructor', name);
2537 if (_class.displayName == 'AnonymousClass')
2538 _class.displayName = toCamelCase(name + 'Class');
2540 var ptr = Object.getPrototypeOf(L),
2541 parts = name.split(/\./),
2542 instance = new _class();
2544 for (var i =
0; ptr
&& i
< parts.length -
1; i++)
2545 ptr = ptr[parts[i]];
2548 ptr[parts[i]] = instance;
2550 classes[name] = instance;
2556 /* Request class file */
2557 classes[name] = Request.get(url, { cache: true }).then(compileClass);
2559 return classes[name];
2563 probeRPCBaseURL: function() {
2564 if (rpcBaseURL == null) {
2566 rpcBaseURL = window.sessionStorage.getItem('rpcBaseURL');
2571 if (rpcBaseURL == null) {
2572 var rpcFallbackURL = this.url('admin/ubus');
2574 rpcBaseURL = Request.get('/ubus/').then(function(res) {
2575 return (rpcBaseURL = (res.status ==
400) ? '/ubus/' : rpcFallbackURL);
2577 return (rpcBaseURL = rpcFallbackURL);
2578 }).then(function(url) {
2580 window.sessionStorage.setItem('rpcBaseURL', url);
2588 return Promise.resolve(rpcBaseURL);
2591 probeSystemFeatures: function() {
2592 var sessionid = classes.rpc.getSessionID();
2594 if (sysFeatures == null) {
2596 var data = JSON.parse(window.sessionStorage.getItem('sysFeatures'));
2598 if (this.isObject(data)
&& this.isObject(data[sessionid]))
2599 sysFeatures = data[sessionid];
2604 if (!this.isObject(sysFeatures)) {
2605 sysFeatures = classes.rpc.declare({
2607 method: 'getFeatures',
2609 })().then(function(features) {
2612 data[sessionid] = features;
2614 window.sessionStorage.setItem('sysFeatures', JSON.stringify(data));
2618 sysFeatures = features;
2624 return Promise.resolve(sysFeatures);
2628 * Test whether a particular system feature is available, such as
2629 * hostapd SAE support or an installed firewall. The features are
2630 * queried once at the beginning of the LuCI session and cached in
2631 * `SessionStorage` throughout the lifetime of the associated tab or
2637 * @param {string} feature
2638 * The feature to test. For detailed list of known feature flags,
2639 * see `/modules/luci-base/root/usr/libexec/rpcd/luci`.
2641 * @param {string} [subfeature]
2642 * Some feature classes like `hostapd` provide sub-feature flags,
2643 * such as `sae` or `
11w` support. The `subfeature` argument can
2644 * be used to query these.
2646 * @return {boolean|null}
2647 * Return `true` if the queried feature (and sub-feature) is available
2648 * or `false` if the requested feature isn't present or known.
2649 * Return `null` when a sub-feature was queried for a feature which
2650 * has no sub-features.
2652 hasSystemFeature: function() {
2653 var ft = sysFeatures[arguments[
0]];
2655 if (arguments.length ==
2)
2656 return this.isObject(ft) ? ft[arguments[
1]] : null;
2658 return (ft != null
&& ft != false);
2662 notifySessionExpiry: function() {
2665 L.ui.showModal(_('Session expired'), [
2666 E('div', { class: 'alert-message warning' },
2667 _('A new login is required since the authentication session expired.')),
2668 E('div', { class: 'right' },
2670 class: 'btn primary',
2672 var loc = window.location;
2673 window.location = loc.protocol + '//' + loc.host + loc.pathname + loc.search;
2675 }, _('To login…')))
2678 L.raise('SessionError', 'Login session is expired');
2682 setupDOM: function(res) {
2687 rpcBaseURL = res[
4];
2689 rpcClass.setBaseURL(rpcBaseURL);
2691 rpcClass.addInterceptor(function(msg, req) {
2692 if (!L.isObject(msg) || !L.isObject(msg.error) || msg.error.code != -
32002)
2695 if (!L.isObject(req) || (req.object == 'session'
&& req.method == 'access'))
2698 return rpcClass.declare({
2699 'object': 'session',
2701 'params': [ 'scope', 'object', 'function' ],
2702 'expect': { access: true }
2703 })('uci', 'luci', 'read').catch(L.notifySessionExpiry);
2706 Request.addInterceptor(function(res) {
2707 var isDenied = false;
2709 if (res.status ==
403 && res.headers.get('X-LuCI-Login-Required') == 'yes')
2715 L.notifySessionExpiry();
2718 return this.probeSystemFeatures().finally(this.initDOM);
2722 initDOM: function() {
2725 document.dispatchEvent(new CustomEvent('luci-loaded'));
2729 * The `env` object holds environment settings used by LuCI, such
2730 * as request timeouts, base URLs etc.
2738 * Construct a relative URL path from the given prefix and parts.
2739 * The resulting URL is guaranteed to only contain the characters
2740 * `a-z`, `A-Z`, `
0-
9`, `_`, `.`, `%`, `,`, `;`, and `-` as well
2741 * as `/` for the path separator.
2746 * @param {string} [prefix]
2747 * The prefix to join the given parts with. If the `prefix` is
2748 * omitted, it defaults to an empty string.
2750 * @param {string[]} [parts]
2751 * An array of parts to join into an URL path. Parts may contain
2752 * slashes and any of the other characters mentioned above.
2755 * Return the joined URL path.
2757 path: function(prefix, parts) {
2758 var url = [ prefix || '' ];
2760 for (var i =
0; i
< parts.length; i++)
2761 if (/^(?:[a-zA-Z0-
9_.%,;-]+\/)*[a-zA-Z0-
9_.%,;-]+$/.test(parts[i]))
2762 url.push('/', parts[i]);
2764 if (url.length ===
1)
2767 return url.join('');
2771 * Construct an URL pathrelative to the script path of the server
2772 * side LuCI application (usually `/cgi-bin/luci`).
2774 * The resulting URL is guaranteed to only contain the characters
2775 * `a-z`, `A-Z`, `
0-
9`, `_`, `.`, `%`, `,`, `;`, and `-` as well
2776 * as `/` for the path separator.
2781 * @param {string[]} [parts]
2782 * An array of parts to join into an URL path. Parts may contain
2783 * slashes and any of the other characters mentioned above.
2786 * Returns the resulting URL path.
2789 return this.path(this.env.scriptname, arguments);
2793 * Construct an URL path relative to the global static resource path
2794 * of the LuCI ui (usually `/luci-static/resources`).
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[]} [parts]
2804 * An array of parts to join into an URL path. Parts may contain
2805 * slashes and any of the other characters mentioned above.
2808 * Returns the resulting URL path.
2810 resource: function() {
2811 return this.path(this.env.resource, arguments);
2815 * Return the complete URL path to the current view.
2821 * Returns the URL path to the current view.
2823 location: function() {
2824 return this.path(this.env.scriptname, this.env.requestpath);
2829 * Tests whether the passed argument is a JavaScript object.
2830 * This function is meant to be an object counterpart to the
2831 * standard `Array.isArray()` function.
2840 * Returns `true` if the given value is of type object and
2841 * not `null`, else returns `false`.
2843 isObject: function(val) {
2844 return (val != null
&& typeof(val) == 'object');
2848 * Return an array of sorted object keys, optionally sorted by
2849 * a different key or a different sorting mode.
2854 * @param {object} obj
2855 * The object to extract the keys from. If the given value is
2856 * not an object, the function will return an empty array.
2858 * @param {string} [key]
2859 * Specifies the key to order by. This is mainly useful for
2860 * nested objects of objects or objects of arrays when sorting
2861 * shall not be performed by the primary object keys but by
2862 * some other key pointing to a value within the nested values.
2864 * @param {string} [sortmode]
2865 * May be either `addr` or `num` to override the natural
2866 * lexicographic sorting with a sorting suitable for IP/MAC style
2867 * addresses or numeric values respectively.
2869 * @return {string[]}
2870 * Returns an array containing the sorted keys of the given object.
2872 sortedKeys: function(obj, key, sortmode) {
2873 if (obj == null || typeof(obj) != 'object')
2876 return Object.keys(obj).map(function(e) {
2877 var v = (key != null) ? obj[e][key] : e;
2881 v = (v != null) ? v.replace(/(?:^|[.:])([
0-
9a-fA-F]{
1,
4})/g,
2882 function(m0, m1) { return ('
000' + m1.toLowerCase()).substr(-
4) }) : null;
2886 v = (v != null) ? +v : null;
2891 }).filter(function(e) {
2892 return (e[
1] != null);
2893 }).sort(function(a, b) {
2894 return (a[
1]
> b[
1]);
2895 }).map(function(e) {
2901 * Converts the given value to an array. If the given value is of
2902 * type array, it is returned as-is, values of type object are
2903 * returned as one-element array containing the object, empty
2904 * strings and `null` values are returned as empty array, all other
2905 * values are converted using `String()`, trimmed, split on white
2906 * space and returned as array.
2912 * The value to convert into an array.
2914 * @return {Array
<*
>}
2915 * Returns the resulting array.
2917 toArray: function(val) {
2920 else if (Array.isArray(val))
2922 else if (typeof(val) == 'object')
2925 var s = String(val).trim();
2930 return s.split(/\s+/);
2934 * Returns a promise resolving with either the given value or or with
2935 * the given default in case the input value is a rejecting promise.
2941 * The value to resolve the promise with.
2943 * @param {*} defvalue
2944 * The default value to resolve the promise with in case the given
2945 * input value is a rejecting promise.
2947 * @returns {Promise
<*
>}
2948 * Returns a new promise resolving either to the given input value or
2949 * to the given default value on error.
2951 resolveDefault: function(value, defvalue) {
2952 return Promise.resolve(value).catch(function() { return defvalue });
2956 * The request callback function is invoked whenever an HTTP
2957 * reply to a request made using the `L.get()`, `L.post()` or
2958 * `L.poll()` function is timed out or received successfully.
2963 * @callback LuCI.requestCallbackFn
2964 * @param {XMLHTTPRequest} xhr
2965 * The XMLHTTPRequest instance used to make the request.
2968 * The response JSON if the response could be parsed as such,
2971 * @param {number} duration
2972 * The total duration of the request in milliseconds.
2976 * Issues a GET request to the given url and invokes the specified
2977 * callback function. The function is a wrapper around
2978 * {@link LuCI.Request#request Request.request()}.
2984 * @param {string} url
2985 * The URL to request.
2987 * @param {Object
<string, string
>} [args]
2988 * Additional query string arguments to append to the URL.
2990 * @param {LuCI.requestCallbackFn} cb
2991 * The callback function to invoke when the request finishes.
2993 * @return {Promise
<null
>}
2994 * Returns a promise resolving to `null` when concluded.
2996 get: function(url, args, cb) {
2997 return this.poll(null, url, args, cb, false);
3001 * Issues a POST request to the given url and invokes the specified
3002 * callback function. The function is a wrapper around
3003 * {@link LuCI.Request#request Request.request()}. The request is
3004 * sent using `application/x-www-form-urlencoded` encoding and will
3005 * contain a field `token` with the current value of `LuCI.env.token`
3012 * @param {string} url
3013 * The URL to request.
3015 * @param {Object
<string, string
>} [args]
3016 * Additional post arguments to append to the request body.
3018 * @param {LuCI.requestCallbackFn} cb
3019 * The callback function to invoke when the request finishes.
3021 * @return {Promise
<null
>}
3022 * Returns a promise resolving to `null` when concluded.
3024 post: function(url, args, cb) {
3025 return this.poll(null, url, args, cb, true);
3029 * Register a polling HTTP request that invokes the specified
3030 * callback function. The function is a wrapper around
3031 * {@link LuCI.Request.poll#add Request.poll.add()}.
3037 * @param {number} interval
3038 * The poll interval to use. If set to a value less than or equal
3039 * to `
0`, it will default to the global poll interval configured
3040 * in `LuCI.env.pollinterval`.
3042 * @param {string} url
3043 * The URL to request.
3045 * @param {Object
<string, string
>} [args]
3046 * Specifies additional arguments for the request. For GET requests,
3047 * the arguments are appended to the URL as query string, for POST
3048 * requests, they'll be added to the request body.
3050 * @param {LuCI.requestCallbackFn} cb
3051 * The callback function to invoke whenever a request finishes.
3053 * @param {boolean} [post=false]
3054 * When set to `false` or not specified, poll requests will be made
3055 * using the GET method. When set to `true`, POST requests will be
3056 * issued. In case of POST requests, the request body will contain
3057 * an argument `token` with the current value of `LuCI.env.token` by
3058 * default, regardless of the parameters specified with `args`.
3060 * @return {function}
3061 * Returns the internally created function that has been passed to
3062 * {@link LuCI.Request.poll#add Request.poll.add()}. This value can
3063 * be passed to {@link LuCI.Poll.remove Poll.remove()} to remove the
3066 poll: function(interval, url, args, cb, post) {
3067 if (interval !== null
&& interval
<=
0)
3068 interval = this.env.pollinterval;
3070 var data = post ? { token: this.env.token } : null,
3071 method = post ? 'POST' : 'GET';
3073 if (!/^(?:\/|\S+:\/\/)/.test(url))
3074 url = this.url(url);
3077 data = Object.assign(data || {}, args);
3079 if (interval !== null)
3080 return Request.poll.add(interval, url, { method: method, query: data }, cb);
3082 return Request.request(url, { method: method, query: data })
3083 .then(function(res) {
3085 if (/^application\/json\b/.test(res.headers.get('Content-Type')))
3086 try { json = res.json() } catch(e) {}
3087 cb(res.xhr, json, res.duration);
3092 * Deprecated wrapper around {@link LuCI.Poll.remove Poll.remove()}.
3098 * @param {function} entry
3099 * The polling function to remove.
3102 * Returns `true` when the function has been removed or `false` if
3103 * it could not be found.
3105 stop: function(entry) { return Poll.remove(entry) },
3108 * Deprecated wrapper around {@link LuCI.Poll.stop Poll.stop()}.
3115 * Returns `true` when the polling loop has been stopped or `false`
3116 * when it didn't run to begin with.
3118 halt: function() { return Poll.stop() },
3121 * Deprecated wrapper around {@link LuCI.Poll.start Poll.start()}.
3128 * Returns `true` when the polling loop has been started or `false`
3129 * when it was already running.
3131 run: function() { return Poll.start() },
3140 * The `dom` class provides convenience method for creating and
3141 * manipulating DOM elements.
3143 dom: Class.singleton(/* @lends LuCI.dom.prototype */ {
3144 __name__: 'LuCI.DOM',
3147 * Tests whether the given argument is a valid DOM `Node`.
3150 * @memberof LuCI.dom
3152 * The value to test.
3154 * @returns {boolean}
3155 * Returns `true` if the value is a DOM `Node`, else `false`.
3158 return (e != null
&& typeof(e) == 'object'
&& 'nodeType' in e);
3162 * Parses a given string as HTML and returns the first child node.
3165 * @memberof LuCI.dom
3167 * A string containing an HTML fragment to parse. Note that only
3168 * the first result of the resulting structure is returned, so an
3169 * input value of `
<div
>foo
</div
> <div
>bar
</div
>` will only return
3170 * the first `div` element node.
3173 * Returns the first DOM `Node` extracted from the HTML fragment or
3174 * `null` on parsing failures or if no element could be found.
3176 parse: function(s) {
3180 domParser = domParser || new DOMParser();
3181 elem = domParser.parseFromString(s, 'text/html').body.firstChild;
3187 dummyElem = dummyElem || document.createElement('div');
3188 dummyElem.innerHTML = s;
3189 elem = dummyElem.firstChild;
3194 return elem || null;
3198 * Tests whether a given `Node` matches the given query selector.
3200 * This function is a convenience wrapper around the standard
3201 * `Node.matches(
"selector")` function with the added benefit that
3202 * the `node` argument may be a non-`Node` value, in which case
3203 * this function simply returns `false`.
3206 * @memberof LuCI.dom
3208 * The `Node` argument to test the selector against.
3210 * @param {string} [selector]
3211 * The query selector expression to test against the given node.
3213 * @returns {boolean}
3214 * Returns `true` if the given node matches the specified selector
3215 * or `false` when the node argument is no valid DOM `Node` or the
3216 * selector didn't match.
3218 matches: function(node, selector) {
3219 var m = this.elem(node) ? node.matches || node.msMatchesSelector : null;
3220 return m ? m.call(node, selector) : false;
3224 * Returns the closest parent node that matches the given query
3225 * selector expression.
3227 * This function is a convenience wrapper around the standard
3228 * `Node.closest(
"selector")` function with the added benefit that
3229 * the `node` argument may be a non-`Node` value, in which case
3230 * this function simply returns `null`.
3233 * @memberof LuCI.dom
3235 * The `Node` argument to find the closest parent for.
3237 * @param {string} [selector]
3238 * The query selector expression to test against each parent.
3240 * @returns {Node|null}
3241 * Returns the closest parent node matching the selector or
3242 * `null` when the node argument is no valid DOM `Node` or the
3243 * selector didn't match any parent.
3245 parent: function(node, selector) {
3246 if (this.elem(node)
&& node.closest)
3247 return node.closest(selector);
3249 while (this.elem(node))
3250 if (this.matches(node, selector))
3253 node = node.parentNode;
3259 * Appends the given children data to the given node.
3262 * @memberof LuCI.dom
3264 * The `Node` argument to append the children to.
3266 * @param {*} [children]
3267 * The childrens to append to the given node.
3269 * When `children` is an array, then each item of the array
3270 * will be either appended as child element or text node,
3271 * depending on whether the item is a DOM `Node` instance or
3272 * some other non-`null` value. Non-`Node`, non-`null` values
3273 * will be converted to strings first before being passed as
3274 * argument to `createTextNode()`.
3276 * When `children` is a function, it will be invoked with
3277 * the passed `node` argument as sole parameter and the `append`
3278 * function will be invoked again, with the given `node` argument
3279 * as first and the return value of the `children` function as
3282 * When `children` is is a DOM `Node` instance, it will be
3283 * appended to the given `node`.
3285 * When `children` is any other non-`null` value, it will be
3286 * converted to a string and appened to the `innerHTML` property
3287 * of the given `node`.
3289 * @returns {Node|null}
3290 * Returns the last children `Node` appended to the node or `null`
3291 * if either the `node` argument was no valid DOM `node` or if the
3292 * `children` was `null` or didn't result in further DOM nodes.
3294 append: function(node, children) {
3295 if (!this.elem(node))
3298 if (Array.isArray(children)) {
3299 for (var i =
0; i
< children.length; i++)
3300 if (this.elem(children[i]))
3301 node.appendChild(children[i]);
3302 else if (children !== null
&& children !== undefined)
3303 node.appendChild(document.createTextNode('' + children[i]));
3305 return node.lastChild;
3307 else if (typeof(children) === 'function') {
3308 return this.append(node, children(node));
3310 else if (this.elem(children)) {
3311 return node.appendChild(children);
3313 else if (children !== null
&& children !== undefined) {
3314 node.innerHTML = '' + children;
3315 return node.lastChild;
3322 * Replaces the content of the given node with the given children.
3324 * This function first removes any children of the given DOM
3325 * `Node` and then adds the given given children following the
3326 * rules outlined below.
3329 * @memberof LuCI.dom
3331 * The `Node` argument to replace the children of.
3333 * @param {*} [children]
3334 * The childrens to replace into the given node.
3336 * When `children` is an array, then each item of the array
3337 * will be either appended as child element or text node,
3338 * depending on whether the item is a DOM `Node` instance or
3339 * some other non-`null` value. Non-`Node`, non-`null` values
3340 * will be converted to strings first before being passed as
3341 * argument to `createTextNode()`.
3343 * When `children` is a function, it will be invoked with
3344 * the passed `node` argument as sole parameter and the `append`
3345 * function will be invoked again, with the given `node` argument
3346 * as first and the return value of the `children` function as
3349 * When `children` is is a DOM `Node` instance, it will be
3350 * appended to the given `node`.
3352 * When `children` is any other non-`null` value, it will be
3353 * converted to a string and appened to the `innerHTML` property
3354 * of the given `node`.
3356 * @returns {Node|null}
3357 * Returns the last children `Node` appended to the node or `null`
3358 * if either the `node` argument was no valid DOM `node` or if the
3359 * `children` was `null` or didn't result in further DOM nodes.
3361 content: function(node, children) {
3362 if (!this.elem(node))
3365 var dataNodes = node.querySelectorAll('[data-idref]');
3367 for (var i =
0; i
< dataNodes.length; i++)
3368 delete this.registry[dataNodes[i].getAttribute('data-idref')];
3370 while (node.firstChild)
3371 node.removeChild(node.firstChild);
3373 return this.append(node, children);
3377 * Sets attributes or registers event listeners on element nodes.
3380 * @memberof LuCI.dom
3382 * The `Node` argument to set the attributes or add the event
3383 * listeners for. When the given `node` value is not a valid
3384 * DOM `Node`, the function returns and does nothing.
3386 * @param {string|Object
<string, *
>} key
3387 * Specifies either the attribute or event handler name to use,
3388 * or an object containing multiple key, value pairs which are
3389 * each added to the node as either attribute or event handler,
3390 * depending on the respective value.
3393 * Specifies the attribute value or event handler function to add.
3394 * If the `key` parameter is an `Object`, this parameter will be
3397 * When `val` is of type function, it will be registered as event
3398 * handler on the given `node` with the `key` parameter being the
3401 * When `val` is of type object, it will be serialized as JSON and
3402 * added as attribute to the given `node`, using the given `key`
3403 * as attribute name.
3405 * When `val` is of any other type, it will be added as attribute
3406 * to the given `node` as-is, with the underlying `setAttribute()`
3407 * call implicitely turning it into a string.
3409 attr: function(node, key, val) {
3410 if (!this.elem(node))
3415 if (typeof(key) === 'object'
&& key !== null)
3417 else if (typeof(key) === 'string')
3418 attr = {}, attr[key] = val;
3421 if (!attr.hasOwnProperty(key) || attr[key] == null)
3424 switch (typeof(attr[key])) {
3426 node.addEventListener(key, attr[key]);
3430 node.setAttribute(key, JSON.stringify(attr[key]));
3434 node.setAttribute(key, attr[key]);
3440 * Creates a new DOM `Node` from the given `html`, `attr` and
3441 * `data` parameters.
3443 * This function has multiple signatures, it can be either invoked
3444 * in the form `create(html[, attr[, data]])` or in the form
3445 * `create(html[, data])`. The used variant is determined from the
3446 * type of the second argument.
3449 * @memberof LuCI.dom
3451 * Describes the node to create.
3453 * When the value of `html` is of type array, a `DocumentFragment`
3454 * node is created and each item of the array is first converted
3455 * to a DOM `Node` by passing it through `create()` and then added
3456 * as child to the fragment.
3458 * When the value of `html` is a DOM `Node` instance, no new
3459 * element will be created but the node will be used as-is.
3461 * When the value of `html` is a string starting with `
<`, it will
3462 * be passed to `dom.parse()` and the resulting value is used.
3464 * When the value of `html` is any other string, it will be passed
3465 * to `document.createElement()` for creating a new DOM `Node` of
3468 * @param {Object
<string, *
>} [attr]
3469 * Specifies an Object of key, value pairs to set as attributes
3470 * or event handlers on the created node. Refer to
3471 * {@link LuCI.dom#attr dom.attr()} for details.
3474 * Specifies children to append to the newly created element.
3475 * Refer to {@link LuCI.dom#append dom.append()} for details.
3477 * @throws {InvalidCharacterError}
3478 * Throws an `InvalidCharacterError` when the given `html`
3479 * argument contained malformed markup (such as not escaped
3480 * `
&` characters in XHTML mode) or when the given node name
3481 * in `html` contains characters which are not legal in DOM
3482 * element names, such as spaces.
3485 * Returns the newly created `Node`.
3487 create: function() {
3488 var html = arguments[
0],
3489 attr = arguments[
1],
3490 data = arguments[
2],
3493 if (!(attr instanceof Object) || Array.isArray(attr))
3494 data = attr, attr = null;
3496 if (Array.isArray(html)) {
3497 elem = document.createDocumentFragment();
3498 for (var i =
0; i
< html.length; i++)
3499 elem.appendChild(this.create(html[i]));
3501 else if (this.elem(html)) {
3504 else if (html.charCodeAt(
0) ===
60) {
3505 elem = this.parse(html);
3508 elem = document.createElement(html);
3514 this.attr(elem, attr);
3515 this.append(elem, data);
3523 * Attaches or detaches arbitrary data to and from a DOM `Node`.
3525 * This function is useful to attach non-string values or runtime
3526 * data that is not serializable to DOM nodes. To decouple data
3527 * from the DOM, values are not added directly to nodes, but
3528 * inserted into a registry instead which is then referenced by a
3529 * string key stored as `data-idref` attribute in the node.
3531 * This function has multiple signatures and is sensitive to the
3532 * number of arguments passed to it.
3534 * - `dom.data(node)` -
3535 * Fetches all data associated with the given node.
3536 * - `dom.data(node, key)` -
3537 * Fetches a specific key associated with the given node.
3538 * - `dom.data(node, key, val)` -
3539 * Sets a specific key to the given value associated with the
3541 * - `dom.data(node, null)` -
3542 * Clears any data associated with the node.
3543 * - `dom.data(node, key, null)` -
3544 * Clears the given key associated with the node.
3547 * @memberof LuCI.dom
3548 * @param {Node} node
3549 * The DOM `Node` instance to set or retrieve the data for.
3551 * @param {string|null} [key]
3552 * This is either a string specifying the key to retrieve, or
3553 * `null` to unset the entire node data.
3555 * @param {*|null} [val]
3556 * This is either a non-`null` value to set for a given key or
3557 * `null` to remove the given `key` from the specified node.
3560 * Returns the get or set value, or `null` when no value could
3563 data: function(node, key, val) {
3564 var id = node.getAttribute('data-idref');
3566 /* clear all data */
3567 if (arguments.length
> 1 && key == null) {
3569 node.removeAttribute('data-idref');
3570 val = this.registry[id]
3571 delete this.registry[id];
3579 else if (arguments.length
> 2 && key != null
&& val == null) {
3581 val = this.registry[id][key];
3582 delete this.registry[id][key];
3590 else if (arguments.length
> 2 && key != null
&& val != null) {
3592 do { id = Math.floor(Math.random() *
0xffffffff).toString(
16) }
3593 while (this.registry.hasOwnProperty(id));
3595 node.setAttribute('data-idref', id);
3596 this.registry[id] = {};
3599 return (this.registry[id][key] = val);
3603 else if (arguments.length ==
1) {
3605 return this.registry[id];
3611 else if (arguments.length ==
2) {
3613 return this.registry[id][key];
3620 * Binds the given class instance ot the specified DOM `Node`.
3622 * This function uses the `dom.data()` facility to attach the
3623 * passed instance of a Class to a node. This is needed for
3624 * complex widget elements or similar where the corresponding
3625 * class instance responsible for the element must be retrieved
3626 * from DOM nodes obtained by `querySelector()` or similar means.
3629 * @memberof LuCI.dom
3630 * @param {Node} node
3631 * The DOM `Node` instance to bind the class to.
3633 * @param {Class} inst
3634 * The Class instance to bind to the node.
3636 * @throws {TypeError}
3637 * Throws a `TypeError` when the given instance argument isn't
3638 * a valid Class instance.
3641 * Returns the bound class instance.
3643 bindClassInstance: function(node, inst) {
3644 if (!(inst instanceof Class))
3645 L.error('TypeError', 'Argument must be a class instance');
3647 return this.data(node, '_class', inst);
3651 * Finds a bound class instance on the given node itself or the
3652 * first bound instance on its closest parent node.
3655 * @memberof LuCI.dom
3656 * @param {Node} node
3657 * The DOM `Node` instance to start from.
3659 * @returns {Class|null}
3660 * Returns the founds class instance if any or `null` if no bound
3661 * class could be found on the node itself or any of its parents.
3663 findClassInstance: function(node) {
3667 inst = this.data(node, '_class');
3668 node = node.parentNode;
3670 while (!(inst instanceof Class)
&& node != null);
3676 * Finds a bound class instance on the given node itself or the
3677 * first bound instance on its closest parent node and invokes
3678 * the specified method name on the found class instance.
3681 * @memberof LuCI.dom
3682 * @param {Node} node
3683 * The DOM `Node` instance to start from.
3685 * @param {string} method
3686 * The name of the method to invoke on the found class instance.
3688 * @param {...*} params
3689 * Additional arguments to pass to the invoked method as-is.
3692 * Returns the return value of the invoked method if a class
3693 * instance and method has been found. Returns `null` if either
3694 * no bound class instance could be found, or if the found
3695 * instance didn't have the requested `method`.
3697 callClassMethod: function(node, method /*, ... */) {
3698 var inst = this.findClassInstance(node);
3700 if (inst == null || typeof(inst[method]) != 'function')
3703 return inst[method].apply(inst, inst.varargs(arguments,
2));
3707 * The ignore callback function is invoked by `isEmpty()` for each
3708 * child node to decide whether to ignore a child node or not.
3710 * When this function returns `false`, the node passed to it is
3711 * ignored, else not.
3713 * @callback LuCI.dom~ignoreCallbackFn
3714 * @param {Node} node
3715 * The child node to test.
3717 * @returns {boolean}
3718 * Boolean indicating whether to ignore the node or not.
3722 * Tests whether a given DOM `Node` instance is empty or appears
3725 * Any element child nodes which have the CSS class `hidden` set
3726 * or for which the optionally passed `ignoreFn` callback function
3727 * returns `false` are ignored.
3730 * @memberof LuCI.dom
3731 * @param {Node} node
3732 * The DOM `Node` instance to test.
3734 * @param {LuCI.dom~ignoreCallbackFn} [ignoreFn]
3735 * Specifies an optional function which is invoked for each child
3736 * node to decide whether the child node should be ignored or not.
3738 * @returns {boolean}
3739 * Returns `true` if the node does not have any children or if
3740 * any children node either has a `hidden` CSS class or a `false`
3741 * result when testing it using the given `ignoreFn`.
3743 isEmpty: function(node, ignoreFn) {
3744 for (var child = node.firstElementChild; child != null; child = child.nextElementSibling)
3745 if (!child.classList.contains('hidden')
&& (!ignoreFn || !ignoreFn(child)))
3762 * The `view` class forms the basis of views and provides a standard
3763 * set of methods to inherit from.
3765 view: Class.extend(/* @lends LuCI.view.prototype */ {
3766 __name__: 'LuCI.View',
3768 __init__: function() {
3769 var vp = document.getElementById('view');
3771 L.dom.content(vp, E('div', { 'class': 'spinning' }, _('Loading view…')));
3773 return Promise.resolve(this.load())
3774 .then(L.bind(this.render, this))
3775 .then(L.bind(function(nodes) {
3776 var vp = document.getElementById('view');
3778 L.dom.content(vp, nodes);
3779 L.dom.append(vp, this.addFooter());
3780 }, this)).catch(L.error);
3784 * The load function is invoked before the view is rendered.
3786 * The invocation of this function is wrapped by
3787 * `Promise.resolve()` so it may return Promises if needed.
3789 * The return value of the function (or the resolved values
3790 * of the promise returned by it) will be passed as first
3791 * argument to `render()`.
3793 * This function is supposed to be overwritten by subclasses,
3794 * the default implementation does nothing.
3798 * @memberof LuCI.view
3800 * @returns {*|Promise
<*
>}
3801 * May return any value or a Promise resolving to any value.
3803 load: function() {},
3806 * The render function is invoked after the
3807 * {@link LuCI.view#load load()} function and responsible
3808 * for setting up the view contents. It must return a DOM
3809 * `Node` or `DocumentFragment` holding the contents to
3810 * insert into the view area.
3812 * The invocation of this function is wrapped by
3813 * `Promise.resolve()` so it may return Promises if needed.
3815 * The return value of the function (or the resolved values
3816 * of the promise returned by it) will be inserted into the
3817 * main content area using
3818 * {@link LuCI.dom#append dom.append()}.
3820 * This function is supposed to be overwritten by subclasses,
3821 * the default implementation does nothing.
3825 * @memberof LuCI.view
3826 * @param {*|null} load_results
3827 * This function will receive the return value of the
3828 * {@link LuCI.view#load view.load()} function as first
3831 * @returns {Node|Promise
<Node
>}
3832 * Should return a DOM `Node` value or a `Promise` resolving
3833 * to a `Node` value.
3835 render: function() {},
3838 * The handleSave function is invoked when the user clicks
3839 * the `Save` button in the page action footer.
3841 * The default implementation should be sufficient for most
3842 * views using {@link form#Map form.Map()} based forms - it
3843 * will iterate all forms present in the view and invoke
3844 * the {@link form#Map#save Map.save()} method on each form.
3846 * Views not using `Map` instances or requiring other special
3847 * logic should overwrite `handleSave()` with a custom
3850 * To disable the `Save` page footer button, views extending
3851 * this base class should overwrite the `handleSave` function
3854 * The invocation of this function is wrapped by
3855 * `Promise.resolve()` so it may return Promises if needed.
3858 * @memberof LuCI.view
3860 * The DOM event that triggered the function.
3862 * @returns {*|Promise
<*
>}
3863 * Any return values of this function are discarded, but
3864 * passed through `Promise.resolve()` to ensure that any
3865 * returned promise runs to completion before the button
3868 handleSave: function(ev) {
3871 document.getElementById('maincontent')
3872 .querySelectorAll('.cbi-map').forEach(function(map) {
3873 tasks.push(L.dom.callClassMethod(map, 'save'));
3876 return Promise.all(tasks);
3880 * The handleSaveApply function is invoked when the user clicks
3881 * the `Save
& Apply` button in the page action footer.
3883 * The default implementation should be sufficient for most
3884 * views using {@link form#Map form.Map()} based forms - it
3886 * {@link LuCI.view.handleSave view.handleSave()} and then
3887 * call {@link ui#changes#apply ui.changes.apply()} to start the
3888 * modal config apply and page reload flow.
3890 * Views not using `Map` instances or requiring other special
3891 * logic should overwrite `handleSaveApply()` with a custom
3894 * To disable the `Save
& Apply` page footer button, views
3895 * extending this base class should overwrite the
3896 * `handleSaveApply` function with `null`.
3898 * The invocation of this function is wrapped by
3899 * `Promise.resolve()` so it may return Promises if needed.
3902 * @memberof LuCI.view
3904 * The DOM event that triggered the function.
3906 * @returns {*|Promise
<*
>}
3907 * Any return values of this function are discarded, but
3908 * passed through `Promise.resolve()` to ensure that any
3909 * returned promise runs to completion before the button
3912 handleSaveApply: function(ev) {
3913 return this.handleSave(ev).then(function() {
3914 L.ui.changes.apply(true);
3919 * The handleReset function is invoked when the user clicks
3920 * the `Reset` button in the page action footer.
3922 * The default implementation should be sufficient for most
3923 * views using {@link form#Map form.Map()} based forms - it
3924 * will iterate all forms present in the view and invoke
3925 * the {@link form#Map#save Map.reset()} method on each form.
3927 * Views not using `Map` instances or requiring other special
3928 * logic should overwrite `handleReset()` with a custom
3931 * To disable the `Reset` page footer button, views extending
3932 * this base class should overwrite the `handleReset` function
3935 * The invocation of this function is wrapped by
3936 * `Promise.resolve()` so it may return Promises if needed.
3939 * @memberof LuCI.view
3941 * The DOM event that triggered the function.
3943 * @returns {*|Promise
<*
>}
3944 * Any return values of this function are discarded, but
3945 * passed through `Promise.resolve()` to ensure that any
3946 * returned promise runs to completion before the button
3949 handleReset: function(ev) {
3952 document.getElementById('maincontent')
3953 .querySelectorAll('.cbi-map').forEach(function(map) {
3954 tasks.push(L.dom.callClassMethod(map, 'reset'));
3957 return Promise.all(tasks);
3961 * Renders a standard page action footer if any of the
3962 * `handleSave()`, `handleSaveApply()` or `handleReset()`
3963 * functions are defined.
3965 * The default implementation should be sufficient for most
3966 * views - it will render a standard page footer with action
3967 * buttons labeled `Save`, `Save
& Apply` and `Reset`
3968 * triggering the `handleSave()`, `handleSaveApply()` and
3969 * `handleReset()` functions respectively.
3971 * When any of these `handle*()` functions is overwritten
3972 * with `null` by a view extending this class, the
3973 * corresponding button will not be rendered.
3976 * @memberof LuCI.view
3977 * @returns {DocumentFragment}
3978 * Returns a `DocumentFragment` containing the footer bar
3979 * with buttons for each corresponding `handle*()` action
3980 * or an empty `DocumentFragment` if all three `handle*()`
3981 * methods are overwritten with `null`.
3983 addFooter: function() {
3986 if (this.handleSaveApply || this.handleSave || this.handleReset) {
3987 footer.appendChild(E('div', { 'class': 'cbi-page-actions' }, [
3988 this.handleSaveApply ? E('button', {
3989 'class': 'cbi-button cbi-button-apply',
3990 'click': L.ui.createHandlerFn(this, 'handleSaveApply')
3991 }, [ _('Save
& Apply') ]) : '', ' ',
3992 this.handleSave ? E('button', {
3993 'class': 'cbi-button cbi-button-save',
3994 'click': L.ui.createHandlerFn(this, 'handleSave')
3995 }, [ _('Save') ]) : '', ' ',
3996 this.handleReset ? E('button', {
3997 'class': 'cbi-button cbi-button-reset',
3998 'click': L.ui.createHandlerFn(this, 'handleReset')
3999 }, [ _('Reset') ]) : ''
4014 * The `LuCI.XHR` class is a legacy compatibility shim for the
4015 * functionality formerly provided by `xhr.js`. It is registered as global
4016 * `window.XHR` symbol for compatibility with legacy code.
4018 * New code should use {@link LuCI.Request} instead to implement HTTP
4021 var XHR = Class.extend(/** @lends LuCI.XHR.prototype */ {
4022 __name__: 'LuCI.XHR',
4023 __init__: function() {
4024 if (window.console
&& console.debug)
4025 console.debug('Direct use XHR() is deprecated, please use L.Request instead');
4028 _response: function(cb, res, json, duration) {
4030 cb(res, json, duration);
4035 * This function is a legacy wrapper around
4036 * {@link LuCI#get LuCI.get()}.
4040 * @memberof LuCI.XHR
4042 * @param {string} url
4043 * The URL to request
4045 * @param {Object} [data]
4046 * Additional query string data
4048 * @param {LuCI.requestCallbackFn} [callback]
4049 * Callback function to invoke on completion
4051 * @param {number} [timeout]
4052 * Request timeout to use
4054 * @return {Promise
<null
>}
4056 get: function(url, data, callback, timeout) {
4058 L.get(url, data, this._response.bind(this, callback), timeout);
4062 * This function is a legacy wrapper around
4063 * {@link LuCI#post LuCI.post()}.
4067 * @memberof LuCI.XHR
4069 * @param {string} url
4070 * The URL to request
4072 * @param {Object} [data]
4073 * Additional data to append to the request body.
4075 * @param {LuCI.requestCallbackFn} [callback]
4076 * Callback function to invoke on completion
4078 * @param {number} [timeout]
4079 * Request timeout to use
4081 * @return {Promise
<null
>}
4083 post: function(url, data, callback, timeout) {
4085 L.post(url, data, this._response.bind(this, callback), timeout);
4089 * Cancels a running request.
4091 * This function does not actually cancel the underlying
4092 * `XMLHTTPRequest` request but it sets a flag which prevents the
4093 * invocation of the callback function when the request eventually
4094 * finishes or timed out.
4098 * @memberof LuCI.XHR
4100 cancel: function() { delete this.active },
4103 * Checks the running state of the request.
4107 * @memberof LuCI.XHR
4109 * @returns {boolean}
4110 * Returns `true` if the request is still running or `false` if it
4111 * already completed.
4113 busy: function() { return (this.active === true) },
4116 * Ignored for backwards compatibility.
4118 * This function does nothing.
4122 * @memberof LuCI.XHR
4124 abort: function() {},
4127 * Existing for backwards compatibility.
4129 * This function simply throws an `InternalError` when invoked.
4133 * @memberof LuCI.XHR
4135 * @throws {InternalError}
4136 * Throws an `InternalError` with the message `Not implemented`
4139 send_form: function() { L.error('InternalError', 'Not implemented') },
4142 XHR.get = function() { return window.L.get.apply(window.L, arguments) };
4143 XHR.post = function() { return window.L.post.apply(window.L, arguments) };
4144 XHR.poll = function() { return window.L.poll.apply(window.L, arguments) };
4145 XHR.stop = Request.poll.remove.bind(Request.poll);
4146 XHR.halt = Request.poll.stop.bind(Request.poll);
4147 XHR.run = Request.poll.start.bind(Request.poll);
4148 XHR.running = Request.poll.active.bind(Request.poll);
4152 })(window, document);
4165 Documentation generated by
<a href=
"https://github.com/jsdoc3/jsdoc">JSDoc
3.6.3</a> on Thu Nov
07 2019 12:
36:
05 GMT+
0100 (Central European Standard Time)
4169 <script>prettyPrint();
</script>
4170 <script src=
"scripts/jaguar.js"></script>