From: Jo-Philipp Wich Date: Thu, 2 Apr 2020 19:50:07 +0000 (+0200) Subject: docs: update js api docs X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=89a50c2f8f45a4d5a1bfbc2eb8e29e5836feeccb;p=oweals%2Fluci.git docs: update js api docs Signed-off-by: Jo-Philipp Wich --- diff --git a/docs/jsapi/LuCI.Class.html b/docs/jsapi/LuCI.Class.html deleted file mode 100644 index cc34d3319..000000000 --- a/docs/jsapi/LuCI.Class.html +++ /dev/null @@ -1,2944 +0,0 @@ - - - - - Class: Class - - - - - - - - - - - - - - - - - -
- - -
-

Class: Class

- - - - -
- -
-

- LuCI. - - Class -

- -

LuCI.Class is the abstract base class all LuCI classes inherit from.

-

It provides simple means to create subclasses of given classes and -implements prototypal inheritance.

- -
- -
-
- - - - -
-
-

- - new LuCI.Class() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - -

Methods

- -
- -
-
-

- - staticLuCI.Class.extend(properties){LuCI.Class} -

- - - - -
- - -
-
- - -
-

Extends this base class with the properties described in -properties and returns a new subclassed Class instance

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
properties - - -Object.<string, *> - - - - - -

An object describing the properties to add to the new -subclass.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - LuCI.Class - - - Returns a new LuCI.Class sublassed from this class, extended -by the given properties and with its prototype set to this base -class to enable inheritance. The resulting value represents a -class constructor and can be instantiated with new.
- - - - -
- - - -
-
-

- - staticLuCI.Class.instantiate(params, new_args){LuCI.Class} -

- - - - -
- - -
-
- - -
-

Calls the class constructor using new with the given argument -array being passed as variadic parameters to the constructor.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
params - - -Array.<*> - - - - - - - - - - -

An array of arbitrary values which will be passed as arguments -to the constructor function.

new_args - - -* - - - - - - - optional - - - - - repeatable - - -

Specifies arguments to be passed to the subclass constructor -as-is in order to instantiate the new subclass.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - LuCI.Class - - - Returns a new LuCI.Class instance extended by the given -properties with its prototype set to this base class to -enable inheritance.
- - - - -
- - - -
-
-

- - staticLuCI.Class.isSubclass(classValue){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether the given class value is a subclass of this class.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
classValue - - -LuCI.Class - - - - - -

The class object to test.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when the given classValue is a subclass of this -class or false if the given value is not a valid class or not -a subclass of this class'.
- - - - -
- - - -
-
-

- - staticLuCI.Class.singleton(properties, new_args){LuCI.Class} -

- - - - -
- - -
-
- - -
-

Extends this base class with the properties described in -properties, instantiates the resulting subclass using -the additional optional arguments passed to this function -and returns the resulting subclassed Class instance.

-

This function serves as a convenience shortcut for -Class.extend() and subsequent -new.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
properties - - -Object.<string, *> - - - - - - - - - - -

An object describing the properties to add to the new -subclass.

new_args - - -* - - - - - - - optional - - - - - repeatable - - -

Specifies arguments to be passed to the subclass constructor -as-is in order to instantiate the new subclass.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - LuCI.Class - - - Returns a new LuCI.Class instance extended by the given -properties with its prototype set to this base class to -enable inheritance.
- - - - -
- - - -
-
-

- - super(key, callArgs){*|null} -

- - - - -
- - -
-
- - -
-

Walks up the parent class chain and looks for a class member -called key in any of the parent classes this class inherits -from. Returns the member value of the superclass or calls the -member as function and returns its return value when the -optional callArgs array is given.

-

This function has two signatures and is sensitive to the -amount of arguments passed to it:

-
    -
  • super('key') - -Returns the value of key when found within one of the -parent classes.
  • -
  • super('key', ['arg1', 'arg2']) - -Calls the key() method with parameters arg1 and arg2 -when found within one of the parent classes.
  • -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
key - - -string - - - - - - - - - - -

The name of the superclass member to retrieve.

callArgs - - -Array.<*> - - - - - - - optional - - - - - -

An optional array of function call parameters to use. When -this parameter is specified, the found member value is called -as function using the values of this array as arguments.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
Throws:
- - - -
-
-
-

Throws a ReferenceError when callArgs are specified and -the found member named by key is not a function value.

-
-
-
-
-
- Type -
-
- -ReferenceError - - -
-
-
-
- - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - * - | - - null - - - Returns the value of the found member or the return value of -the call to the found method. Returns null when no member -was found in the parent class chain or when the call to the -superclass method returned null.
- - - - -
- - - -
-
-

- - varargs(args, offset, extra_args){Array.<*>} -

- - - - -
- - -
-
- - -
-

Extract all values from the given argument array beginning from -offset and prepend any further given optional parameters to -the beginning of the resulting array copy.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
args - - -Array.<*> - - - - - - - - - - -

The array to extract the values from.

offset - - -number - - - - - - - - - - -

The offset from which to extract the values. An offset of 0 -would copy all values till the end.

extra_args - - -* - - - - - - - optional - - - - - repeatable - - -

Extra arguments to add to prepend to the resultung array.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<*> - - - Returns a new array consisting of the optional extra arguments -and the values extracted from the args array beginning with -offset.
- - - - -
- -
- - - - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Headers.html b/docs/jsapi/LuCI.Headers.html deleted file mode 100644 index b86cc17b0..000000000 --- a/docs/jsapi/LuCI.Headers.html +++ /dev/null @@ -1,2117 +0,0 @@ - - - - - Class: Headers - - - - - - - - - - - - - - - - - -
- - -
-

Class: Headers

- - - - -
- -
-

- LuCI. - - Headers -

- -

The Headers class is an internal utility class exposed in HTTP -response objects using the response.headers property.

- -
- -
-
- - - - -
-
-

- - new LuCI.Headers() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - -

Methods

- -
- -
-
-

- - get(name){string|null} -

- - - - -
- - -
-
- - -
-

Returns the value of the given header name. -Note: Header-Names are case-insensitive.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -string - - - - - -

The header name to read

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - | - - null - - - The value of the given header name or null if the header isn't present.
- - - - -
- - - -
-
-

- - has(name){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether the given header name is present. -Note: Header-Names are case-insensitive.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -string - - - - - -

The header name to check

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if the header name is present, false otherwise
- - - - -
- -
- - - - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.Device.html b/docs/jsapi/LuCI.Network.Device.html deleted file mode 100644 index 3ce2664cc..000000000 --- a/docs/jsapi/LuCI.Network.Device.html +++ /dev/null @@ -1,4062 +0,0 @@ - - - - - Class: Device - - - - - - - - - - - - - - - - - -
- - -
-

Class: Device

- - - - -
- -
-

- LuCI.Network. - - Device -

- -

A Network.Device class instance represents an underlying Linux network -device and allows querying device details such as packet statistics or MTU.

- -
- -
-
- - - - -
-
-

- - new LuCI.Network.Device() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - -

Methods

- -
- -
-
-

- - getBridgeID(){null|string} -

- - - - -
- - -
-
- - -
-

Get the bridge ID

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the ID of this network bridge or null if this network -device is not a Linux bridge.
- - - - -
- - - -
-
-

- - getBridgeSTP(){boolean} -

- - - - -
- - -
-
- - -
-

Get the bridge STP setting

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when this device is a Linux bridge and has stp -enabled, else false.
- - - - -
- - - -
-
-

- - getI18n(){string} -

- - - - -
- - -
-
- - -
-

Get a long description string for the device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns a string containing the type description and device name -for non-wifi devices or operation mode and ssid for wifi ones.
- - - - -
- - - -
-
-

- - getIP6Addrs(){Array.<string>} -

- - - - -
- - -
-
- - -
-

Get the IPv6 addresses configured on the device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<string> - - - Returns an array of IPv6 address strings.
- - - - -
- - - -
-
-

- - getIPAddrs(){Array.<string>} -

- - - - -
- - -
-
- - -
-

Get the IPv4 addresses configured on the device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<string> - - - Returns an array of IPv4 address strings.
- - - - -
- - - -
-
-

- - getMAC(){null|string} -

- - - - -
- - -
-
- - -
-

Get the MAC address of the device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the MAC address of the device or null if not applicable, -e.g. for non-ethernet tunnel devices.
- - - - -
- - - -
-
-

- - getMTU(){number} -

- - - - -
- - -
-
- - -
-

Get the MTU of the device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the MTU of the device.
- - - - -
- - - -
-
-

- - getName(){string} -

- - - - -
- - -
-
- - -
-

Get the name of the network device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the name of the device, e.g. eth0 or wlan0.
- - - - -
- - - -
-
-

- - getNetwork(){null|LuCI.Network.Protocol} -

- - - - -
- - -
-
- - -
-

Get the primary logical interface this device is assigned to.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - LuCI.Network.Protocol - - - Returns a Network.Protocol instance representing the logical -interface this device is attached to or null if it is not -assigned to any logical interface.
- - - - -
- - - -
-
-

- - getNetworks(){Array.<LuCI.Network.Protocol>} -

- - - - -
- - -
-
- - -
-

Get the logical interfaces this device is assigned to.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<LuCI.Network.Protocol> - - - Returns an array of Network.Protocol instances representing the -logical interfaces this device is assigned to.
- - - - -
- - - -
-
-

- - getPorts(){null|Array.<LuCI.Network.Device>} -

- - - - -
- - -
-
- - -
-

Get the associated bridge ports of the device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - Array.<LuCI.Network.Device> - - - Returns an array of Network.Device instances representing the ports -(slave interfaces) of the bridge or null when this device isn't -a Linux bridge.
- - - - -
- - - -
-
-

- - getRXBytes(){number} -

- - - - -
- - -
-
- - -
-

Get the amount of received bytes.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the amount of bytes received by the network device.
- - - - -
- - - -
-
-

- - getRXPackets(){number} -

- - - - -
- - -
-
- - -
-

Get the amount of received packets.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the amount of packets received by the network device.
- - - - -
- - - -
-
-

- - getShortName(){string} -

- - - - -
- - -
-
- - -
-

Get a short description string for the device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the device name for non-wifi devices or a string containing -the operation mode and SSID for wifi devices.
- - - - -
- - - -
-
-

- - getTXBytes(){number} -

- - - - -
- - -
-
- - -
-

Get the amount of transmitted bytes.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the amount of bytes transmitted by the network device.
- - - - -
- - - -
-
-

- - getTXPackets(){number} -

- - - - -
- - -
-
- - -
-

Get the amount of transmitted packets.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the amount of packets transmitted by the network device.
- - - - -
- - - -
-
-

- - getType(){string} -

- - - - -
- - -
-
- - -
-

Get the type of the device..

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns a string describing the type of the network device: -
    -
  • alias if it is an abstract alias device (@ notation)
  • -
  • wifi if it is a wireless interface (e.g. wlan0)
  • -
  • bridge if it is a bridge device (e.g. br-lan)
  • -
  • tunnel if it is a tun or tap device (e.g. tun0)
  • -
  • vlan if it is a vlan device (e.g. eth0.1)
  • -
  • switch if it is a switch device (e.g.eth1 connected to switch0)
  • -
  • ethernet for all other device types
  • -
- - - - -
- - - -
-
-

- - getTypeI18n(){string} -

- - - - -
- - -
-
- - -
-

Get a string describing the device type.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns a string describing the type, e.g. "Wireless Adapter" or -"Bridge".
- - - - -
- - - -
-
-

- - getWifiNetwork(){null|LuCI.Network.WifiNetwork} -

- - - - -
- - -
-
- - -
-

Get the related wireless network this device is related to.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - LuCI.Network.WifiNetwork - - - Returns a Network.WifiNetwork instance representing the wireless -network corresponding to this network device or null if this device -is not a wireless device.
- - - - -
- - - -
-
-

- - isBridge(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this device is a Linux bridge.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when the network device is present and a Linux bridge, -else false.
- - - - -
- - - -
-
-

- - isBridgePort(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this device is part of a Linux bridge.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when this network device is part of a bridge, -else false.
- - - - -
- - - -
-
-

- - isUp(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this device is up.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when the associated device is running pr false -when it is down or absent.
- - - - -
- -
- - - - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.Hosts.html b/docs/jsapi/LuCI.Network.Hosts.html deleted file mode 100644 index b6138acc7..000000000 --- a/docs/jsapi/LuCI.Network.Hosts.html +++ /dev/null @@ -1,3043 +0,0 @@ - - - - - Class: Hosts - - - - - - - - - - - - - - - - - -
- - -
-

Class: Hosts

- - - - -
- -
-

- LuCI.Network. - - Hosts -

- -

The LuCI.Network.Hosts class encapsulates host information aggregated -from multiple sources and provides convenience functions to access the -host information by different criteria.

- -
- -
-
- - - - -
-
-

- - new LuCI.Network.Hosts() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - -

Methods

- -
- -
-
-

- - getHostnameByIP6Addr(ipaddr){null|string} -

- - - - -
- - -
-
- - -
-

Lookup the hostname associated with the given IPv6 address.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
ipaddr - - -string - - - - - -

The IPv6 address to lookup.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the hostname associated with the given IPv6 or null if -no matching host could be found or if no hostname is known for -the corresponding host.
- - - - -
- - - -
-
-

- - getHostnameByIPAddr(ipaddr){null|string} -

- - - - -
- - -
-
- - -
-

Lookup the hostname associated with the given IPv4 address.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
ipaddr - - -string - - - - - -

The IPv4 address to lookup.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the hostname associated with the given IPv4 or null if -no matching host could be found or if no hostname is known for -the corresponding host.
- - - - -
- - - -
-
-

- - getHostnameByMACAddr(mac){null|string} -

- - - - -
- - -
-
- - -
-

Lookup the hostname associated with the given MAC address.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
mac - - -string - - - - - -

The MAC address to lookup.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the hostname associated with the given MAC or null if -no matching host could be found or if no hostname is known for -the corresponding host.
- - - - -
- - - -
-
-

- - getIP6AddrByMACAddr(mac){null|string} -

- - - - -
- - -
-
- - -
-

Lookup the IPv6 address associated with the given MAC address.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
mac - - -string - - - - - -

The MAC address to lookup.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the IPv6 address associated with the given MAC or null if -no matching host could be found or if no IPv6 address is known for -the corresponding host.
- - - - -
- - - -
-
-

- - getIPAddrByMACAddr(mac){null|string} -

- - - - -
- - -
-
- - -
-

Lookup the IPv4 address associated with the given MAC address.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
mac - - -string - - - - - -

The MAC address to lookup.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the IPv4 address associated with the given MAC or null if -no matching host could be found or if no IPv4 address is known for -the corresponding host.
- - - - -
- - - -
-
-

- - getMACAddrByIP6Addr(ipaddr){null|string} -

- - - - -
- - -
-
- - -
-

Lookup the MAC address associated with the given IPv6 address.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
ipaddr - - -string - - - - - -

The IPv6 address to lookup.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the MAC address associated with the given IPv6 or null if -no matching host could be found or if no MAC address is known for -the corresponding host.
- - - - -
- - - -
-
-

- - getMACAddrByIPAddr(ipaddr){null|string} -

- - - - -
- - -
-
- - -
-

Lookup the MAC address associated with the given IPv4 address.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
ipaddr - - -string - - - - - -

The IPv4 address to lookup.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the MAC address associated with the given IPv4 or null if -no matching host could be found or if no MAC address is known for -the corresponding host.
- - - - -
- - - -
-
-

- - getMACHints(preferIp6){Array.<Array.<string>>} -

- - - - -
- - -
-
- - -
-

Return an array of (MAC address, name hint) tuples sorted by -MAC address.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
preferIp6 - - -boolean - - - - - - false - - - - - optional - - - - - -

Whether to prefer IPv6 addresses (true) or IPv4 addresses (false) -as name hint when no hostname is known for a specific MAC address.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<Array.<string>> - - - Returns an array of arrays containing a name hint for each found -MAC address on the system. The array is sorted ascending by MAC. -Each item of the resulting array is a two element array with the -MAC being the first element and the name hint being the second -element. The name hint is either the hostname, an IPv4 or an IPv6 -address related to the MAC address. -If no hostname but both IPv4 and IPv6 addresses are known, the -preferIP6 flag specifies whether the IPv6 or the IPv4 address -is used as hint.
- - - - -
- -
- - - - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.Protocol.html b/docs/jsapi/LuCI.Network.Protocol.html deleted file mode 100644 index c104314ec..000000000 --- a/docs/jsapi/LuCI.Network.Protocol.html +++ /dev/null @@ -1,6272 +0,0 @@ - - - - - Class: Protocol - - - - - - - - - - - - - - - - - -
- - -
-

Class: Protocol

- - - - -
- -
-

- LuCI.Network. - - Protocol -

- -

The Network.Protocol class serves as base for protocol specific -subclasses which describe logical UCI networks defined by config interface sections in /etc/config/network.

- -
- -
-
- - - - -
-
-

- - new LuCI.Network.Protocol() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - -

Methods

- -
- -
-
-

- - addDevice(device){boolean} -

- - - - -
- - -
-
- - -
-

Add the given network device to the logical interface.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
device - - -LuCI.Network.Protocol -| - -LuCI.Network.Device -| - -LuCI.Network.WifiDevice -| - -LuCI.Network.WifiNetwork -| - -string - - - - - -

The object or device name to add to the logical interface. In case the -given argument is not a string, it is resolved though the -Network.getIfnameOf() function.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if the device name has been added or false if any -argument was invalid, if the device was already part of the logical -interface or if the logical interface is virtual.
- - - - -
- - - -
-
-

- - containsDevice(device){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this logical interface contains the given device -object.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
device - - -LuCI.Network.Protocol -| - -LuCI.Network.Device -| - -LuCI.Network.WifiDevice -| - -LuCI.Network.WifiNetwork -| - -string - - - - - -

The object or device name to check. In case the given argument is not -a string, it is resolved though the -Network.getIfnameOf() function.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when this logical interface contains the given network -device or false if not.
- - - - -
- - - -
-
-

- - abstractdeleteConfiguration(){*|Promise.<*>} -

- - - - -
- - -
-
- - -
-

Cleanup related configuration entries.

-

This function will be invoked if an interface is about to be removed -from the configuration and is responsible for performing any required -cleanup tasks, such as unsetting uci entries in related configurations.

-

It should be overwritten by protocol specific subclasses.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - * - | - - Promise.<*> - - - This function may return a promise which is awaited before the rest of -the configuration is removed. Any non-promise return value and any -resolved promise value is ignored. If the returned promise is rejected, -the interface removal will be aborted.
- - - - -
- - - -
-
-

- - deleteDevice(device){boolean} -

- - - - -
- - -
-
- - -
-

Remove the given network device from the logical interface.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
device - - -LuCI.Network.Protocol -| - -LuCI.Network.Device -| - -LuCI.Network.WifiDevice -| - -LuCI.Network.WifiNetwork -| - -string - - - - - -

The object or device name to remove from the logical interface. In case -the given argument is not a string, it is resolved though the -Network.getIfnameOf() function.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if the device name has been added or false if any -argument was invalid, if the device was already part of the logical -interface or if the logical interface is virtual.
- - - - -
- - - -
-
-

- - get(opt){null|string|Array.<string>} -

- - - - -
- - -
-
- - -
-

Read the given UCI option value of this network.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
opt - - -string - - - - - -

The UCI option name to read.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - | - - Array.<string> - - - Returns the UCI option value or null if the requested option is -not found.
- - - - -
- - - -
-
-

- - getDevice(){LuCI.Network.Device} -

- - - - -
- - -
-
- - -
-

Returns the Linux network device associated with this logical -interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - LuCI.Network.Device - - - Returns a Network.Device class instance representing the -expected Linux network device according to the configuration.
- - - - -
- - - -
-
-

- - getDevices(){null|Array.<LuCI.Network.Device>} -

- - - - -
- - -
-
- - -
-

Returns a list of network sub-devices associated with this logical -interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - Array.<LuCI.Network.Device> - - - Returns an array of of Network.Device class instances representing -the sub-devices attached to this logical interface or null if the -logical interface does not support sub-devices, e.g. because it is -virtual and not a bridge.
- - - - -
- - - -
-
-

- - getDNS6Addrs(){Array.<string>} -

- - - - -
- - -
-
- - -
-

Query the IPv6 DNS servers associated with the logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<string> - - - Returns an array of IPv6 DNS servers registered by the remote -protocol backend.
- - - - -
- - - -
-
-

- - getDNSAddrs(){Array.<string>} -

- - - - -
- - -
-
- - -
-

Query the IPv4 DNS servers associated with the logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<string> - - - Returns an array of IPv4 DNS servers registered by the remote -protocol backend.
- - - - -
- - - -
-
-

- - getErrors(){Array.<string>} -

- - - - -
- - -
-
- - -
-

Query interface error messages published in ubus runtime state.

-

Interface errors are emitted by remote protocol handlers if the setup -of the underlying logical interface failed, e.g. due to bad -configuration or network connectivity issues.

-

This function will translate the found error codes to human readable -messages using the descriptions registered by -Network.registerErrorCode() -and fall back to "Unknown error (%s)" where %s is replaced by the -error code in case no translation can be found.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<string> - - - Returns an array of translated interface error messages.
- - - - -
- - - -
-
-

- - getExpiry(){number} -

- - - - -
- - -
-
- - -
-

Get the logical interface expiry time in seconds.

-

For protocols that have a concept of a lease, such as DHCP or -DHCPv6, this function returns the remaining time in seconds -until the lease expires.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the amount of seconds until the lease expires or -1 -if it isn't applicable to the associated protocol.
- - - - -
- - - -
-
-

- - getGateway6Addr(){string} -

- - - - -
- - -
-
- - -
-

Query the gateway (nexthop) of the IPv6 default route associated with -this logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns a string containing the IPv6 nexthop address of the associated -default route or null if no default route was found.
- - - - -
- - - -
-
-

- - getGatewayAddr(){string} -

- - - - -
- - -
-
- - -
-

Query the gateway (nexthop) of the default route associated with -this logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns a string containing the IPv4 nexthop address of the associated -default route or null if no default route was found.
- - - - -
- - - -
-
-

- - abstractgetI18n(){string} -

- - - - -
- - -
-
- - -
-

Return a human readable description for the protcol, such as -Static address or DHCP client.

-

This function should be overwritten by subclasses.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the description string.
- - - - -
- - - -
-
-

- - getIfname(){null|string} -

- - - - -
- - -
-
- - -
-

Get the associared Linux network device of this network.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the name of the associated network device or null if -it could not be determined.
- - - - -
- - - -
-
-

- - getIP6Addr(){null|string} -

- - - - -
- - -
-
- - -
-

Query the first (primary) IPv6 address of the logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the primary IPv6 address registered by the protocol handler -in CIDR notation or null if no IPv6 addresses were set.
- - - - -
- - - -
-
-

- - getIP6Addrs(){Array.<string>} -

- - - - -
- - -
-
- - -
-

Query all IPv6 addresses of the logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<string> - - - Returns an array of IPv6 addresses in CIDR notation which have been -registered by the protocol handler. The order of the resulting array -follows the order of the addresses in ubus runtime information.
- - - - -
- - - -
-
-

- - getIP6Prefix(){null|string} -

- - - - -
- - -
-
- - -
-

Query the routed IPv6 prefix associated with the logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the routed IPv6 prefix registered by the remote protocol -handler or null if no prefix is present.
- - - - -
- - - -
-
-

- - getIPAddr(){null|string} -

- - - - -
- - -
-
- - -
-

Query the first (primary) IPv4 address of the logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the primary IPv4 address registered by the protocol handler -or null if no IPv4 addresses were set.
- - - - -
- - - -
-
-

- - getIPAddrs(){Array.<string>} -

- - - - -
- - -
-
- - -
-

Query all IPv4 addresses of the logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<string> - - - Returns an array of IPv4 addresses in CIDR notation which have been -registered by the protocol handler. The order of the resulting array -follows the order of the addresses in ubus runtime information.
- - - - -
- - - -
-
-

- - getL2Device(){LuCI.Network.Device} -

- - - - -
- - -
-
- - -
-

Returns the layer 2 linux network device currently associated -with this logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - LuCI.Network.Device - - - Returns a Network.Device class instance representing the Linux -network device currently associated with the logical interface.
- - - - -
- - - -
-
-

- - getL3Device(){LuCI.Network.Device} -

- - - - -
- - -
-
- - -
-

Returns the layer 3 linux network device currently associated -with this logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - LuCI.Network.Device - - - Returns a Network.Device class instance representing the Linux -network device currently associated with the logical interface.
- - - - -
- - - -
-
-

- - getMetric(){number} -

- - - - -
- - -
-
- - -
-

Get the metric value of the logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the current metric value used for device and network -routes spawned by the associated logical interface.
- - - - -
- - - -
-
-

- - getName(){string} -

- - - - -
- - -
-
- - -
-

Get the name of the associated logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the logical interface name, such as lan or wan.
- - - - -
- - - -
-
-

- - getNetmask(){null|string} -

- - - - -
- - -
-
- - -
-

Query the first (primary) IPv4 netmask of the logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the netmask of the primary IPv4 address registered by the -protocol handler or null if no IPv4 addresses were set.
- - - - -
- - - -
-
-

- - abstractgetOpkgPackage(){string} -

- - - - -
- - -
-
- - -
-

Get the name of the opkg package providing the protocol functionality.

-

This function should be overwritten by protocol specific subclasses.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the name of the opkg package required for the protocol to -function, e.g. odhcp6c for the dhcpv6 prototocol.
- - - - -
- - - -
-
-

- - abstractgetProtocol(){string} -

- - - - -
- - -
-
- - -
-

Get the name of this network protocol class.

-

This function will be overwritten by subclasses created by -Network.registerProtocol().

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the name of the network protocol implementation, e.g. -static or dhcp.
- - - - -
- - - -
-
-

- - getType(){null|string} -

- - - - -
- - -
-
- - -
-

Get the type of the underlying interface.

-

This function actually is a convenience wrapper around -proto.get("type") and is mainly used by other LuCI.Network code -to check whether the interface is declared as bridge in UCI.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the value of the type option of the associated logical -interface or null if no type option is set.
- - - - -
- - - -
-
-

- - getUptime(){number} -

- - - - -
- - -
-
- - -
-

Get the uptime of the logical interface.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the uptime of the associated interface in seconds.
- - - - -
- - - -
-
-

- - getZoneName(){null|string} -

- - - - -
- - -
-
- - -
-

Get the requested firewall zone name of the logical interface.

-

Some protocol implementations request a specific firewall zone -to trigger inclusion of their resulting network devices into the -firewall rule set.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the requested firewall zone name as published in the -ubus runtime information or null if the remote protocol -handler didn't request a zone.
- - - - -
- - - -
-
-

- - isAlias(){null|string} -

- - - - -
- - -
-
- - -
-

Checks whether this interface is an alias interface.

-

Alias interfaces are interfaces layering on top of another interface -and are denoted by a special @interfacename notation in the -underlying ifname option.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the name of the parent interface if this logical interface -is an alias or null if it is not an alias interface.
- - - - -
- - - -
-
-

- - isBridge(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether the underlying logical interface is declared as bridge.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when the interface is declared with option type bridge -and when the associated protocol implementation is not marked virtual -or false when the logical interface is no bridge.
- - - - -
- - - -
-
-

- - abstractisCreateable(ifname){Promise.<(null|string)>} -

- - - - -
- - -
-
- - -
-

Check function for the protocol handler if a new interface is createable.

-

This function should be overwritten by protocol specific subclasses.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
ifname - - -string - - - - - -

The name of the interface to be created.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<(null|string)> - - - Returns null if new interface is createable, else returns (error) message.
- - - - -
- - - -
-
-

- - isDynamic(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this logical interface is dynamic.

-

A dynamic interface is an interface which has been created at runtime, -e.g. as sub-interface of another interface, but which is not backed by -any user configuration. Such dynamic interfaces cannot be edited but -only brought down or restarted.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns a boolean indicating whether this interface is dynamic (true) -or not (false).
- - - - -
- - - -
-
-

- - isEmpty(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this logical interface is "empty", meaning that ut -has no network devices attached.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if this logical interface is empty, else false.
- - - - -
- - - -
-
-

- - isFloating(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this protocol is "floating".

-

A "floating" protocol is a protocol which spawns its own interfaces -on demand, like a virtual one but which relies on an existinf lower -level interface to initiate the connection.

-

An example for such a protocol is "pppoe".

-

This function exists for backwards compatibility with older code -but should not be used anymore.

-
- - - - - - - - - -
- - - - - - - -
Deprecated
  • Yes
- - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns a boolean indicating whether this protocol is floating (true) -or not (false).
- - - - -
- - - -
-
-

- - abstractisInstalled(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether the protocol functionality is installed.

-

This function exists for compatibility with old code, it always -returns true.

-
- - - - - - - - - -
- - - - - - - -
Deprecated
  • Yes
- - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if the protocol support is installed, else false.
- - - - -
- - - -
-
-

- - isUp(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this logical interface is configured and running.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when the interface is active or false when it is not.
- - - - -
- - - -
-
-

- - isVirtual(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this protocol is "virtual".

-

A "virtual" protocol is a protocol which spawns its own interfaces -on demand instead of using existing physical interfaces.

-

Examples for virtual protocols are 6in4 which gre spawn tunnel -network device on startup, examples for non-virtual protcols are -dhcp or static which apply IP configuration to existing interfaces.

-

This function should be overwritten by subclasses.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns a boolean indicating whether the underlying protocol spawns -dynamic interfaces (true) or not (false).
- - - - -
- - - -
-
-

- - set(opt, val) -

- - - - -
- - -
-
- - -
-

Set the given UCI option of this network to the given value.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
opt - - -string - - - - - -

The name of the UCI option to set.

val - - -null -| - -string -| - -Array.<string> - - - - - -

The value to set or null to remove the given option from the -configuration.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- -
- - - - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.WifiDevice.html b/docs/jsapi/LuCI.Network.WifiDevice.html deleted file mode 100644 index 5bde32805..000000000 --- a/docs/jsapi/LuCI.Network.WifiDevice.html +++ /dev/null @@ -1,3409 +0,0 @@ - - - - - Class: WifiDevice - - - - - - - - - - - - - - - - - -
- - -
-

Class: WifiDevice

- - - - -
- -
-

- LuCI.Network. - - WifiDevice -

- -

A Network.WifiDevice class instance represents a wireless radio device -present on the system and provides wireless capability information as -well as methods for enumerating related wireless networks.

- -
- -
-
- - - - -
-
-

- - new LuCI.Network.WifiDevice() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - -

Methods

- -
- -
-
-

- - addWifiNetwork(options){Promise.<(null|LuCI.Network.WifiNetwork)>} -

- - - - -
- - -
-
- - -
-

Adds a new wireless network associated with this radio device to the -configuration and sets its options to the provided values.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object.<string, (string|Array.<string>)> - - - - - - - optional - - - - - -

The options to set for the newly added wireless network.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<(null|LuCI.Network.WifiNetwork)> - - - Returns a promise resolving to a WifiNetwork instance describing -the newly added wireless network or null if the given options -were invalid.
- - - - -
- - - -
-
-

- - deleteWifiNetwork(network){Promise.<boolean>} -

- - - - -
- - -
-
- - -
-

Deletes the wireless network with the given name associated with this -radio device.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
network - - -string - - - - - -

The name of the wireless network to lookup. This may be either an uci -configuration section ID, a network ID in the form radio#.network# -or a Linux network device name like wlan0 which is resolved to the -corresponding configuration section through ubus runtime information.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<boolean> - - - Returns a promise resolving to true when the wireless network was -successfully deleted from the configuration or false when the given -network could not be found or if the found network was not associated -with this wireless radio device.
- - - - -
- - - -
-
-

- - get(opt){null|string|Array.<string>} -

- - - - -
- - -
-
- - -
-

Read the given UCI option value of this wireless device.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
opt - - -string - - - - - -

The UCI option name to read.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - | - - Array.<string> - - - Returns the UCI option value or null if the requested option is -not found.
- - - - -
- - - -
-
-

- - getHTModes(){Array.<string>} -

- - - - -
- - -
-
- - -
-

Gets a list of supported htmodes.

-

The htmode values describe the wide-frequency options supported by -the wireless phy.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<string> - - - Returns an array of valid htmode values for this radio. Currently -known mode values are: -
    -
  • HT20 - applicable to IEEE 802.11n, 20 MHz wide channels
  • -
  • HT40 - applicable to IEEE 802.11n, 40 MHz wide channels
  • -
  • VHT20 - applicable to IEEE 802.11ac, 20 MHz wide channels
  • -
  • VHT40 - applicable to IEEE 802.11ac, 40 MHz wide channels
  • -
  • VHT80 - applicable to IEEE 802.11ac, 80 MHz wide channels
  • -
  • VHT160 - applicable to IEEE 802.11ac, 160 MHz wide channels
  • -
- - - - -
- - - -
-
-

- - getHWModes(){Array.<string>} -

- - - - -
- - -
-
- - -
-

Gets a list of supported hwmodes.

-

The hwmode values describe the frequency band and wireless standard -versions supported by the wireless phy.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<string> - - - Returns an array of valid hwmode values for this radio. Currently -known mode values are: -
    -
  • a - Legacy 802.11a mode, 5 GHz, up to 54 Mbit/s
  • -
  • b - Legacy 802.11b mode, 2.4 GHz, up to 11 Mbit/s
  • -
  • g - Legacy 802.11g mode, 2.4 GHz, up to 54 Mbit/s
  • -
  • n - IEEE 802.11n mode, 2.4 or 5 GHz, up to 600 Mbit/s
  • -
  • ac - IEEE 802.11ac mode, 5 GHz, up to 6770 Mbit/s
  • -
- - - - -
- - - -
-
-

- - getI18n(){string} -

- - - - -
- - -
-
- - -
-

Get a string describing the wireless radio hardware.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the description string.
- - - - -
- - - -
-
-

- - getName(){string} -

- - - - -
- - -
-
- - -
-

Get the configuration name of this wireless radio.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the UCI section name (e.g. radio0) of the corresponding -radio configuration which also serves as unique logical identifier -for the wireless phy.
- - - - -
- - - -
-
-

- - getScanList(){Promise.<Array.<LuCI.Network.WifiScanResult>>} -

- - - - -
- - -
-
- - -
-

Trigger a wireless scan on this radio device and obtain a list of -nearby networks.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Array.<LuCI.Network.WifiScanResult>> - - - Returns a promise resolving to an array of scan result objects -describing the networks found in the vincinity.
- - - - -
- - - -
-
-

- - getWifiNetwork(network){Promise.<LuCI.Network.WifiNetwork>} -

- - - - -
- - -
-
- - -
-

Get the wifi network of the given name belonging to this radio device

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
network - - -string - - - - - -

The name of the wireless network to lookup. This may be either an uci -configuration section ID, a network ID in the form radio#.network# -or a Linux network device name like wlan0 which is resolved to the -corresponding configuration section through ubus runtime information.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<LuCI.Network.WifiNetwork> - - - Returns a promise resolving to a Network.WifiNetwork instance -representing the wireless network and rejecting with null if -the given network could not be found or is not associated with -this radio device.
- - - - -
- - - -
-
-

- - getWifiNetworks(){Promise.<Array.<LuCI.Network.WifiNetwork>>} -

- - - - -
- - -
-
- - -
-

Get all wireless networks associated with this wireless radio device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Array.<LuCI.Network.WifiNetwork>> - - - Returns a promise resolving to an array of Network.WifiNetwork -instances respresenting the wireless networks associated with this -radio device.
- - - - -
- - - -
-
-

- - isDisabled(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this wireless radio is disabled.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when the wireless radio is marked as disabled in ubus -runtime state or when the disabled option is set in the corresponding -UCI configuration.
- - - - -
- - - -
-
-

- - isUp(){boolean} -

- - - - -
- - -
-
- - -
-

Check whether the wireless radio is marked as up in the ubus -runtime state.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when the radio device is up, else false.
- - - - -
- - - -
-
-

- - set(opt, val) -

- - - - -
- - -
-
- - -
-

Set the given UCI option of this network to the given value.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
opt - - -string - - - - - -

The name of the UCI option to set.

val - - -null -| - -string -| - -Array.<string> - - - - - -

The value to set or null to remove the given option from the -configuration.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- -
- - - - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.WifiNetwork.html b/docs/jsapi/LuCI.Network.WifiNetwork.html deleted file mode 100644 index e43432ba7..000000000 --- a/docs/jsapi/LuCI.Network.WifiNetwork.html +++ /dev/null @@ -1,5902 +0,0 @@ - - - - - Class: WifiNetwork - - - - - - - - - - - - - - - - - -
- - -
-

Class: WifiNetwork

- - - - -
- -
-

- LuCI.Network. - - WifiNetwork -

- -

A Network.WifiNetwork instance represents a wireless network (vif) -configured on top of a radio device and provides functions for querying -the runtime state of the network. Most radio devices support multiple -such networks in parallel.

- -
- -
-
- - - - -
-
-

- - new LuCI.Network.WifiNetwork() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - -

Methods

- -
- -
-
-

- - disconnectClient(mac, deauth, reason, ban_time){Promise.<number>} -

- - - - -
- - -
-
- - -
-

Forcibly disconnect the given client from the wireless network.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
mac - - -string - - - - - - - - - - - - -

The MAC address of the client to disconnect.

deauth - - -boolean - - - - - - false - - - - - optional - - - - - -

Specifies whether to deauthenticate (true) or disassociate (false) -the client.

reason - - -number - - - - - - 1 - - - - - optional - - - - - -

Specifies the IEEE 802.11 reason code to disassoc/deauth the client -with. Default is 1 which corresponds to Unspecified reason.

ban_time - - -number - - - - - - 0 - - - - - optional - - - - - -

Specifies the amount of milliseconds to ban the client from -reconnecting. By default, no ban time is set which allows the client -to reassociate / reauthenticate immediately.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<number> - - - Returns a promise resolving to the underlying ubus call result code -which is typically 0, even for not existing MAC addresses. -The promise might reject with an error in case invalid arguments -are passed.
- - - - -
- - - -
-
-

- - get(opt){null|string|Array.<string>} -

- - - - -
- - -
-
- - -
-

Read the given UCI option value of this wireless network.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
opt - - -string - - - - - -

The UCI option name to read.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - | - - Array.<string> - - - Returns the UCI option value or null if the requested option is -not found.
- - - - -
- - - -
-
-

- - getActiveBSSID(){string} -

- - - - -
- - -
-
- - -
-

Query the current BSSID from runtime information.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the current BSSID or Mesh ID as reported by ubus runtime -information.
- - - - -
- - - -
-
-

- - getActiveEncryption(){string} -

- - - - -
- - -
-
- - -
-

Query the current encryption settings from runtime information.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns a string describing the current encryption or - if the the -encryption state could not be found in ubus runtime information.
- - - - -
- - - -
-
-

- - getActiveMode(){string} -

- - - - -
- - -
-
- - -
-

Query the current operation mode from runtime information.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the human readable mode name as reported by ubus runtime -state. Possible returned values are: -
    -
  • Master
  • -
  • Ad-Hoc
  • -
  • Client
  • -
  • Monitor
  • -
  • Master (VLAN)
  • -
  • WDS
  • -
  • Mesh Point
  • -
  • P2P Client
  • -
  • P2P Go
  • -
  • Unknown
  • -
- - - - -
- - - -
-
-

- - getActiveModeI18n(){string} -

- - - - -
- - -
-
- - -
-

Query the current operation mode from runtime information as -translated string.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the translated, human readable mode name as reported by -ubus runtime state.
- - - - -
- - - -
-
-

- - getActiveSSID(){string} -

- - - - -
- - -
-
- - -
-

Query the current SSID from runtime information.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the current SSID or Mesh ID as reported by ubus runtime -information.
- - - - -
- - - -
-
-

- - getAssocList(){Promise.<Array.<LuCI.Network.WifiPeerEntry>>} -

- - - - -
- - -
-
- - -
-

Fetch the list of associated peers.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Array.<LuCI.Network.WifiPeerEntry>> - - - Returns a promise resolving to an array of wireless peers associated -with this network.
- - - - -
- - - -
-
-

- - getBitRate(){null|number} -

- - - - -
- - -
-
- - -
-

Query the current average bitrate of all peers associated to this -wireless network.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - number - - - Returns the average bit rate among all peers associated to the network -as reported by ubus runtime information or null if the information -is not available.
- - - - -
- - - -
-
-

- - getBSSID(){null|string} -

- - - - -
- - -
-
- - -
-

Get the configured BSSID of the wireless network.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the BSSID value or null if none has been specified.
- - - - -
- - - -
-
-

- - getChannel(){null|number} -

- - - - -
- - -
-
- - -
-

Query the current wireless channel.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - number - - - Returns the wireless channel as reported by ubus runtime information -or null if it cannot be determined.
- - - - -
- - - -
-
-

- - getCountryCode(){string} -

- - - - -
- - -
-
- - -
-

Query the current country code.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the wireless country code as reported by ubus runtime -information or 00 if it cannot be determined.
- - - - -
- - - -
-
-

- - getDevice(){LuCI.Network.Device} -

- - - - -
- - -
-
- - -
-

Get the associated Linux network device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - LuCI.Network.Device - - - Returns a Network.Device instance representing the Linux network -device associted with this wireless network.
- - - - -
- - - -
-
-

- - getFrequency(){null|string} -

- - - - -
- - -
-
- - -
-

Query the current operating frequency of the wireless network.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the current operating frequency of the network from ubus -runtime information in GHz or null if the information is not -available.
- - - - -
- - - -
-
-

- - getI18n(){string} -

- - - - -
- - -
-
- - -
-

Get a description string for this wireless network.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns a string describing this network, consisting of the -term Wireless Network, followed by the active operation mode, -the SSID, BSSID or internal network ID and the Linux network device -name, depending on which information is available.
- - - - -
- - - -
-
-

- - getID(){string} -

- - - - -
- - -
-
- - -
-

Get the internal network ID of this wireless network.

-

The network ID is a LuCI specific identifer in the form -radio#.network# to identify wireless networks by their corresponding -radio and network index numbers.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the LuCI specific network ID.
- - - - -
- - - -
-
-

- - getIfname(){null|string} -

- - - - -
- - -
-
- - -
-

Get the Linux network device name.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the current Linux network device name as resolved from -ubus runtime information or null if this network has no -associated network device, e.g. when not configured or up.
- - - - -
- - - -
-
-

- - getMeshID(){null|string} -

- - - - -
- - -
-
- - -
-

Get the configured Mesh ID of the wireless network.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the configured mesh ID value or null when this network -is not in mesh mode.
- - - - -
- - - -
-
-

- - getMode(){string} -

- - - - -
- - -
-
- - -
-

Get the configured operation mode of the wireless network.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the configured operation mode. Possible values are: -
    -
  • ap - Master (Access Point) mode
  • -
  • sta - Station (client) mode
  • -
  • adhoc - Ad-Hoc (IBSS) mode
  • -
  • mesh - Mesh (IEEE 802.11s) mode
  • -
  • monitor - Monitor mode
  • -
- - - - -
- - - -
-
-

- - getName(){string} -

- - - - -
- - -
-
- - -
-

Get the configuration ID of this wireless network.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns the corresponding UCI section ID of the network.
- - - - -
- - - -
-
-

- - getNetwork(){null|LuCI.Network.Protocol} -

- - - - -
- - -
-
- - -
-

Get the primary logical interface this wireless network is attached to.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - LuCI.Network.Protocol - - - Returns a Network.Protocol instance representing the logical -interface or null if this network is not attached to any logical -interface.
- - - - -
- - - -
-
-

- - getNetworkNames(){Array.<string>} -

- - - - -
- - -
-
- - -
-

Get the names of the logical interfaces this wireless network is -attached to.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<string> - - - Returns an array of logical interface names.
- - - - -
- - - -
-
-

- - getNetworks(){Array.<LuCI.Network.Protocol>} -

- - - - -
- - -
-
- - -
-

Get the logical interfaces this wireless network is attached to.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<LuCI.Network.Protocol> - - - Returns an array of Network.Protocol instances representing the -logical interfaces this wireless network is attached to.
- - - - -
- - - -
-
-

- - getNoise(){number} -

- - - - -
- - -
-
- - -
-

Query the current radio noise floor.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the radio noise floor in dBm as reported by ubus runtime -information or 0 if it cannot be determined.
- - - - -
- - - -
-
-

- - getShortName(){string} -

- - - - -
- - -
-
- - -
-

Get a short description string for this wireless network.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - Returns a string describing this network, consisting of the -active operation mode, followed by either the SSID, BSSID or -internal network ID, depending on which information is available.
- - - - -
- - - -
-
-

- - getSignal(){null|number} -

- - - - -
- - -
-
- - -
-

Query the current wireless signal.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - number - - - Returns the wireless signal in dBm as reported by ubus runtime -information or null if it cannot be determined.
- - - - -
- - - -
-
-

- - getSignalLevel(){number} -

- - - - -
- - -
-
- - -
-

Calculate the current signal.

-
- - - - - - - - - -
- - - - - - - -
Deprecated
  • Yes
- - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the calculated signal level, which is the difference between -noise and signal (SNR), divided by 5.
- - - - -
- - - -
-
-

- - getSignalPercent(){number} -

- - - - -
- - -
-
- - -
-

Calculate the current signal quality percentage.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the calculated signal quality in percent. The value is -calculated from the quality and quality_max indicators reported -by ubus runtime state.
- - - - -
- - - -
-
-

- - getSSID(){null|string} -

- - - - -
- - -
-
- - -
-

Get the configured SSID of the wireless network.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the configured SSID value or null when this network is -in mesh mode.
- - - - -
- - - -
-
-

- - getTXPower(){null|number} -

- - - - -
- - -
-
- - -
-

Query the current radio TX power.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - number - - - Returns the wireless network transmit power in dBm as reported by -ubus runtime information or null if it cannot be determined.
- - - - -
- - - -
-
-

- - getTXPowerOffset(){number} -

- - - - -
- - -
-
- - -
-

Query the radio TX power offset.

-

Some wireless radios have a fixed power offset, e.g. due to the -use of external amplifiers.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - number - - - Returns the wireless network transmit power offset in dBm as reported -by ubus runtime information or 0 if there is no offset, or if it -cannot be determined.
- - - - -
- - - -
-
-

- - getWifiDevice(){null|LuCI.Network.WifiDevice} -

- - - - -
- - -
-
- - -
-

Get the corresponding wifi radio device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - LuCI.Network.WifiDevice - - - Returns a Network.WifiDevice instance representing the corresponding -wifi radio device or null if the related radio device could not be -found.
- - - - -
- - - -
-
-

- - getWifiDeviceName(){null|string} -

- - - - -
- - -
-
- - -
-

Get the name of the corresponding wifi radio device.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the name of the radio device this network is configured on -or null if it cannot be determined.
- - - - -
- - - -
-
-

- - isClientDisconnectSupported(){boolean} -

- - - - -
- - -
-
- - -
-

Check whether this wifi network supports deauthenticating clients.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when this wifi network instance supports forcibly -deauthenticating clients, otherwise false.
- - - - -
- - - -
-
-

- - isDisabled(){boolean} -

- - - - -
- - -
-
- - -
-

Checks whether this wireless network is disabled.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when the wireless radio is marked as disabled in ubus -runtime state or when the disabled option is set in the corresponding -UCI configuration.
- - - - -
- - - -
-
-

- - isUp(){boolean} -

- - - - -
- - -
-
- - -
-

Check whether the radio network is up.

-

This function actually queries the up state of the related radio -device and assumes this network to be up as well when the parent -radio is up. This is due to the fact that OpenWrt does not control -virtual interfaces individually but within one common hostapd -instance.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true when the network is up, else false.
- - - - -
- - - -
-
-

- - set(opt, val) -

- - - - -
- - -
-
- - -
-

Set the given UCI option of this network to the given value.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
opt - - -string - - - - - -

The name of the UCI option to set.

val - - -null -| - -string -| - -Array.<string> - - - - - -

The value to set or null to remove the given option from the -configuration.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- -
- - - - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Network.html b/docs/jsapi/LuCI.Network.html deleted file mode 100644 index 67a6d1b98..000000000 --- a/docs/jsapi/LuCI.Network.html +++ /dev/null @@ -1,7757 +0,0 @@ - - - - - Class: Network - - - - - - - - - - - - - - - - - -
- - -
-

Class: Network

- - - - -
- -
-

- LuCI. - - Network -

- -

The LuCI.Network class combines data from multiple ubus apis to -provide an abstraction of the current network configuration state.

-

It provides methods to enumerate interfaces and devices, to query -current configuration details and to manipulate settings.

- -
- -
-
- - - - -
-
-

- - new LuCI.Network() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - -

Classes

- -
-
Device
-
- -
Hosts
-
- -
Protocol
-
- -
WifiDevice
-
- -
WifiNetwork
-
-
- - - - - - - -

Methods

- -
- -
-
-

- - addNetwork(name, options){Promise.<(null|LuCI.Network.Protocol)>} -

- - - - -
- - -
-
- - -
-

Adds a new network of the given name and update it with the given -uci option values.

-

If a network with the given name already exist but is empty, then -this function will update its option, otherwise it will do nothing.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -string - - - - - - - - - - -

The name of the network to add. Must be in the format [a-zA-Z0-9_]+.

options - - -Object.<string, (string|Array.<string>)> - - - - - - - optional - - - - - -

An object of uci option values to set on the new network or to -update in an existing, empty network.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<(null|LuCI.Network.Protocol)> - - - Returns a promise resolving to the Protocol subclass instance -describing the added network or resolving to null if the name -was invalid or if a non-empty network of the given name already -existed.
- - - - -
- - - -
-
-

- - addWifiNetwork(options){Promise.<(null|LuCI.Network.WifiNetwork)>} -

- - - - -
- - -
-
- - -
-

Adds a new wireless network to the configuration and sets its options -to the provided values.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object.<string, (string|Array.<string>)> - - - - - -

The options to set for the newly added wireless network. This object -must at least contain a device property which is set to the radio -name the new network belongs to.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<(null|LuCI.Network.WifiNetwork)> - - - Returns a promise resolving to a WifiNetwork instance describing -the newly added wireless network or null if the given options -were invalid or if the associated radio device could not be found.
- - - - -
- - - -
-
-

- - deleteNetwork(name){Promise.<boolean>} -

- - - - -
- - -
-
- - -
-

Deletes the given network and its references from the network and -firewall configuration.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -string - - - - - -

The name of the network to delete.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<boolean> - - - Returns a promise resolving to either true if the network and -references to it were successfully deleted from the configuration or -false if the given network could not be found.
- - - - -
- - - -
-
-

- - deleteWifiNetwork(netname){Promise.<boolean>} -

- - - - -
- - -
-
- - -
-

Deletes the given wireless network from the configuration.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
netname - - -string - - - - - -

The name of the network to remove. This may be either a -network ID in the form radio#.network# or a Linux network device -name like wlan0 which is resolved to the corresponding configuration -section through ubus runtime information.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<boolean> - - - Returns a promise resolving to true if the wireless network has been -successfully deleted from the configuration or false if it could not -be found.
- - - - -
- - - -
-
-

- - flushCache(){Promise.<Object>} -

- - - - -
- - -
-
- - -
-

Flushes the local network state cache and fetches updated information -from the remote ubus apis.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Object> - - - Returns a promise resolving to the internal network state object.
- - - - -
- - - -
-
-

- - formatWifiEncryption(encryption){null|string} -

- - - - -
- - -
-
- - -
-

Converts a given encryption entry -into a human readable string such as mixed WPA/WPA2 PSK (TKIP, CCMP) -or WPA3 SAE (CCMP).

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
encryption - - -LuCI.Network.WifiEncryption - - - - - -

The wireless encryption entry to convert.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns the description string for the given encryption entry or -null if the given entry was invalid.
- - - - -
- - - -
-
-

- - getDevice(name){Promise.<(null|LuCI.Network.Device)>} -

- - - - -
- - -
-
- - -
-

Get a Device instance describing the -given network device.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -string - - - - - -

The name of the network device to get, e.g. eth0 or br-lan.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<(null|LuCI.Network.Device)> - - - Returns a promise resolving to the Device instance describing -the network device or null if the given device name could not -be found.
- - - - -
- - - -
-
-

- - getDevices(){Promise.<Array.<LuCI.Network.Device>>} -

- - - - -
- - -
-
- - -
-

Get a sorted list of all found network devices.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Array.<LuCI.Network.Device>> - - - Returns a promise resolving to a sorted array of Device class -instances describing the network devices found on the system.
- - - - -
- - - -
-
-

- - getDSLModemType(){Promise.<(null|string)>} -

- - - - -
- - -
-
- - -
-

Queries the internal DSL modem type from board information.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<(null|string)> - - - Returns a promise resolving to the type of the internal modem -(e.g. vdsl) or to null if no internal modem is present.
- - - - -
- - - -
-
-

- - getHostHints(){Promise.<LuCI.Network.Hosts>} -

- - - - -
- - -
-
- - -
-

Queries aggregated information about known hosts.

-

This function aggregates information from various sources such as -DHCP lease databases, ARP and IPv6 neighbour entries, wireless -association list etc. and returns a Hosts -class instance describing the found hosts.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<LuCI.Network.Hosts> - - - Returns a Hosts instance describing host known on the system.
- - - - -
- - - -
-
-

- - getIfnameOf(obj){null|string} -

- - - - -
- - -
-
- - -
-

Obtains the the network device name of the given object.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
obj - - -LuCI.Network.Protocol -| - -LuCI.Network.Device -| - -LuCI.Network.WifiDevice -| - -LuCI.Network.WifiNetwork -| - -string - - - - - -

The object to get the device name from.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns a string containing the device name or null if the given -object could not be converted to a name.
- - - - -
- - - -
-
-

- - getNetwork(name){Promise.<(null|LuCI.Network.Protocol)>} -

- - - - -
- - -
-
- - -
-

Get a Protocol instance describing -the network with the given name.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -string - - - - - -

The logical interface name of the network get, e.g. lan or wan.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<(null|LuCI.Network.Protocol)> - - - Returns a promise resolving to a -Protocol subclass instance describing -the network or null if the network did not exist.
- - - - -
- - - -
-
-

- - getNetworks(){Promise.<Array.<LuCI.Network.Protocol>>} -

- - - - -
- - -
-
- - -
-

Gets an array containing all known networks.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Array.<LuCI.Network.Protocol>> - - - Returns a promise resolving to a name-sorted array of -Protocol subclass instances -describing all known networks.
- - - - -
- - - -
-
-

- - getProtocol(protoname, netname){null|LuCI.Network.Protocol} -

- - - - -
- - -
-
- - -
-

Instantiates the given Protocol backend, -optionally using the given network name.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
protoname - - -string - - - - - - - - - - - - -

The protocol backend to use, e.g. static or dhcp.

netname - - -string - - - - - - __dummy__ - - - - - optional - - - - - -

The network name to use for the instantiated protocol. This should be -usually set to one of the interfaces described in /etc/config/network -but it is allowed to omit it, e.g. to query protocol capabilities -without the need for an existing interface.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - LuCI.Network.Protocol - - - Returns the instantiated protocol backend class or null if the given -protocol isn't known.
- - - - -
- - - -
-
-

- - getProtocols(){Array.<LuCI.Network.Protocol>} -

- - - - -
- - -
-
- - -
-

Obtains instances of all known Protocol -backend classes.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Array.<LuCI.Network.Protocol> - - - Returns an array of protocol class instances.
- - - - -
- - - -
-
-

- - getSwitchTopologies(){Promise.<Object.<string, LuCI.Network.SwitchTopology>>} -

- - - - -
- - -
-
- - -
-

Returns the topologies of all swconfig switches found on the system.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Object.<string, LuCI.Network.SwitchTopology>> - - - Returns a promise resolving to an object containing the topologies -of each switch. The object keys correspond to the name of the switches -such as switch0, the values are -SwitchTopology objects describing -the layout.
- - - - -
- - - -
-
-

- - getWAN6Networks(){Promise.<Array.<LuCI.Network.Protocol>>} -

- - - - -
- - -
-
- - -
-

Get IPv6 wan networks.

-

This function looks up all networks having a default ::/0 route -and returns them as array.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Array.<LuCI.Network.Protocol>> - - - Returns a promise resolving to an array of Protocol subclass -instances describing the found IPv6 default route interfaces.
- - - - -
- - - -
-
-

- - getWANNetworks(){Promise.<Array.<LuCI.Network.Protocol>>} -

- - - - -
- - -
-
- - -
-

Get IPv4 wan networks.

-

This function looks up all networks having a default 0.0.0.0/0 route -and returns them as array.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Array.<LuCI.Network.Protocol>> - - - Returns a promise resolving to an array of Protocol subclass -instances describing the found default route interfaces.
- - - - -
- - - -
-
-

- - getWifiDevice(devname){Promise.<(null|LuCI.Network.WifiDevice)>} -

- - - - -
- - -
-
- - -
-

Get a WifiDevice instance describing -the given wireless radio.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
devname - - -string - - - - - -

The configuration name of the wireless radio to lookup, e.g. radio0 -for the first mac80211 phy on the system.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<(null|LuCI.Network.WifiDevice)> - - - Returns a promise resolving to the WifiDevice instance describing -the underlying radio device or null if the wireless radio could not -be found.
- - - - -
- - - -
-
-

- - getWifiDevices(){Promise.<Array.<LuCI.Network.WifiDevice>>} -

- - - - -
- - -
-
- - -
-

Obtain a list of all configured radio devices.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Array.<LuCI.Network.WifiDevice>> - - - Returns a promise resolving to an array of WifiDevice instances -describing the wireless radios configured in the system. -The order of the array corresponds to the order of the radios in -the configuration.
- - - - -
- - - -
-
-

- - getWifiNetwork(netname){Promise.<(null|LuCI.Network.WifiNetwork)>} -

- - - - -
- - -
-
- - -
-

Get a WifiNetwork instance describing -the given wireless network.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
netname - - -string - - - - - -

The name of the wireless network to lookup. This may be either an uci -configuration section ID, a network ID in the form radio#.network# -or a Linux network device name like wlan0 which is resolved to the -corresponding configuration section through ubus runtime information.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<(null|LuCI.Network.WifiNetwork)> - - - Returns a promise resolving to the WifiNetwork instance describing -the wireless network or null if the corresponding network could not -be found.
- - - - -
- - - -
-
-

- - getWifiNetworks(){Promise.<Array.<LuCI.Network.WifiNetwork>>} -

- - - - -
- - -
-
- - -
-

Get an array of all WifiNetwork -instances describing the wireless networks present on the system.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<Array.<LuCI.Network.WifiNetwork>> - - - Returns a promise resolving to an array of WifiNetwork instances -describing the wireless networks. The array will be empty if no networks -are found.
- - - - -
- - - -
-
-

- - isIgnoredDevice(name){boolean} -

- - - - -
- - -
-
- - -
-

Test if a given network device name is in the list of patterns for -device names to ignore.

-

Ignored device names are usually Linux network devices which are -spawned implicitly by kernel modules such as tunl0 or hwsim0 -and which are unsuitable for use in network configuration.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -string - - - - - -

The device name to test.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if the given name is in the ignore pattern list, -else returns false.
- - - - -
- - - -
-
-

- - maskToPrefix(netmask, v6){null|number} -

- - - - -
- - -
-
- - -
-

Converts the given netmask to a prefix size in bits.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
netmask - - -string - - - - - - - - - - - - -

The netmask to convert into a bit count.

v6 - - -boolean - - - - - - false - - - - - optional - - - - - -

Whether to parse the given netmask as IPv4 (false) or IPv6 (true) -address.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - number - - - Returns the number of prefix bits contained in the netmask or null -if the given netmask value was invalid.
- - - - -
- - - -
-
-

- - prefixToMask(bits, v6){null|string} -

- - - - -
- - -
-
- - -
-

Converts the given prefix size in bits to a netmask.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
bits - - -number - - - - - - - - - - - - -

The prefix size in bits.

v6 - - -boolean - - - - - - false - - - - - optional - - - - - -

Whether to convert the bits value into an IPv4 netmask (false) or -an IPv6 netmask (true).

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - null - | - - string - - - Returns a string containing the netmask corresponding to the bit count -or null when the given amount of bits exceeds the maximum possible -value of 32 for IPv4 or 128 for IPv6.
- - - - -
- - - -
-
-

- - registerErrorCode(code, message){boolean} -

- - - - -
- - -
-
- - -
-

Registers a new human readable translation string for a Protocol -error code.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
code - - -string - - - - - -

The ubus protocol error code to register a translation for, e.g. -NO_DEVICE.

message - - -string - - - - - -

The message to use as translation for the given protocol error code.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if the error code description has been added or false -if either the arguments were invalid or if there already was a -description for the given code.
- - - - -
- - - -
-
-

- - registerPatternVirtual(pat) -

- - - - -
- - -
-
- - -
-

Registers a new regular expression pattern to recognize -virtual interfaces.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
pat - - -RegExp - - - - - -

A RegExp instance to match a virtual interface name -such as 6in4-wan or tun0.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - -
-
-

- - registerProtocol(protoname, methods){LuCI.Network.Protocol} -

- - - - -
- - -
-
- - -
-

Registers a new Protocol subclass -with the given methods and returns the resulting subclass value.

-

This functions internally calls -Class.extend() on the Network.Protocol -base class.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
protoname - - -string - - - - - -

The name of the new protocol to register.

methods - - -Object.<string, *> - - - - - -

The member methods and values of the new Protocol subclass to -be passed to Class.extend().

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - LuCI.Network.Protocol - - - Returns the new Protocol subclass.
- - - - -
- - - -
-
-

- - renameNetwork(oldName, newName){Promise.<boolean>} -

- - - - -
- - -
-
- - -
-

Rename the given network and its references to a new name.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
oldName - - -string - - - - - -

The current name of the network.

newName - - -string - - - - - -

The name to rename the network to, must be in the format -[a-z-A-Z0-9_]+.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<boolean> - - - Returns a promise resolving to either true if the network was -successfully renamed or false if the new name was invalid, if -a network with the new name already exists or if the network to -rename could not be found.
- - - - -
- -
- - - -

Type Definitions

- -
- -
-
-

LuCI.Network.SwitchTopologyObject.<string, (Object|Array)>

-
- - -
-
- -
-

Describes an swconfig switch topology by specifying the CPU -connections and external port labels of a switch.

-
- - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
netdevs - - -Object.<number, string> - - - -

The netdevs property points to an object describing the CPU port -connections of the switch. The numeric key of the enclosed object is -the port number, the value contains the Linux network device name the -port is hardwired to.

ports - - -Array.<Object.<string, (boolean|number|string)>> - - - -

The ports property points to an array describing the populated -ports of the switch in the external label order. Each array item is -an object containg the following keys:

-
    -
  • num - the internal switch port number
  • -
  • label - the label of the port, e.g. LAN 1 or CPU (eth0)
  • -
  • device - the connected Linux network device name (CPU ports only)
  • -
  • tagged - a boolean indicating whether the port must be tagged to -function (CPU ports only)
  • -
- - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
-
-

LuCI.Network.WifiEncryptionObject.<string, (boolean|Array.<(number|string)>)>

-
- - -
-
- -
-

An encryption entry describes active wireless encryption settings -such as the used key management protocols, active ciphers and -protocol versions.

-
- - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
enabled - - -boolean - - - - - - - -

Specifies whether any kind of encryption, such as WEP or WPA is -enabled. If set to false, then no encryption is active and the -corresponding network is open.

wep - - -Array.<string> - - - - - - <optional>
- - - -

When the wep property exists, the network uses WEP encryption. -In this case, the property is set to an array of active WEP modes -which might be either open, shared or both.

wpa - - -Array.<number> - - - - - - <optional>
- - - -

When the wpa property exists, the network uses WPA security. -In this case, the property is set to an array containing the WPA -protocol versions used, e.g. [ 1, 2 ] for WPA/WPA2 mixed mode or -[ 3 ] for WPA3-SAE.

authentication - - -Array.<string> - - - - - - <optional>
- - - -

The authentication property only applies to WPA encryption and -is defined when the wpa property is set as well. It points to -an array of active authentication suites used by the network, e.g. -[ "psk" ] for a WPA(2)-PSK network or [ "psk", "sae" ] for -mixed WPA2-PSK/WPA3-SAE encryption.

ciphers - - -Array.<string> - - - - - - <optional>
- - - -

If either WEP or WPA encryption is active, then the ciphers -property will be set to an array describing the active encryption -ciphers used by the network, e.g. [ "tkip", "ccmp" ] for a -WPA/WPA2-PSK mixed network or [ "wep-40", "wep-104" ] for an -WEP network.

- - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
-
-

LuCI.Network.WifiPeerEntryObject.<string, (boolean|number|string|LuCI.Network.WifiRateEntry)>

-
- - -
-
- -
-

A wireless peer entry describes the properties of a remote wireless -peer associated with a local network.

-
- - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
mac - - -string - - - - - - - -

The MAC address (BSSID).

signal - - -number - - - - - - - -

The received signal strength.

signal_avg - - -number - - - - - - <optional>
- - - -

The average signal strength if supported by the driver.

noise - - -number - - - - - - <optional>
- - - -

The current noise floor of the radio. May be 0 or absent if not -supported by the driver.

inactive - - -number - - - - - - - -

The amount of milliseconds the peer has been inactive, e.g. due -to powersave.

connected_time - - -number - - - - - - - -

The amount of milliseconds the peer is associated to this network.

thr - - -number - - - - - - <optional>
- - - -

The estimated throughput of the peer, May be 0 or absent if not -supported by the driver.

authorized - - -boolean - - - - - - - -

Specifies whether the peer is authorized to associate to this network.

authenticated - - -boolean - - - - - - - -

Specifies whether the peer completed authentication to this network.

preamble - - -string - - - - - - - -

The preamble mode used by the peer. May be long or short.

wme - - -boolean - - - - - - - -

Specifies whether the peer supports WME/WMM capabilities.

mfp - - -boolean - - - - - - - -

Specifies whether management frame protection is active.

tdls - - -boolean - - - - - - - -

Specifies whether TDLS is active.

mesh llid - - -number - - - - - - <optional>
- - - -

The mesh LLID, may be 0 or absent if not applicable or supported -by the driver.

mesh plid - - -number - - - - - - <optional>
- - - -

The mesh PLID, may be 0 or absent if not applicable or supported -by the driver.

mesh plink - - -string - - - - - - <optional>
- - - -

The mesh peer link state description, may be an empty string ('') -or absent if not applicable or supported by the driver.

-

The following states are known:

-
    -
  • LISTEN
  • -
  • OPN_SNT
  • -
  • OPN_RCVD
  • -
  • CNF_RCVD
  • -
  • ESTAB
  • -
  • HOLDING
  • -
  • BLOCKED
  • -
  • UNKNOWN
  • -
mesh local PS - - -number - - - - - - <optional>
- - - -

The local powersafe mode for the peer link, may be an empty -string ('') or absent if not applicable or supported by -the driver.

-

The following modes are known:

-
    -
  • ACTIVE (no power save)
  • -
  • LIGHT SLEEP
  • -
  • DEEP SLEEP
  • -
  • UNKNOWN
  • -
mesh peer PS - - -number - - - - - - <optional>
- - - -

The remote powersafe mode for the peer link, may be an empty -string ('') or absent if not applicable or supported by -the driver.

-

The following modes are known:

-
    -
  • ACTIVE (no power save)
  • -
  • LIGHT SLEEP
  • -
  • DEEP SLEEP
  • -
  • UNKNOWN
  • -
mesh non-peer PS - - -number - - - - - - <optional>
- - - -

The powersafe mode for all non-peer neigbours, may be an empty -string ('') or absent if not applicable or supported by the driver.

-

The following modes are known:

-
    -
  • ACTIVE (no power save)
  • -
  • LIGHT SLEEP
  • -
  • DEEP SLEEP
  • -
  • UNKNOWN
  • -
rx - - -LuCI.Network.WifiRateEntry - - - - - - - -

Describes the receiving wireless rate from the peer.

tx - - -LuCI.Network.WifiRateEntry - - - - - - - -

Describes the transmitting wireless rate to the peer.

- - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
-
-

LuCI.Network.WifiRateEntryObject.<string, (boolean|number)>

-
- - -
-
- -
-

A wireless rate entry describes the properties of a wireless -transmission rate to or from a peer.

-
- - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
drop_misc - - -number - - - - - - <optional>
- - - -

The amount of received misc. packages that have been dropped, e.g. -due to corruption or missing authentication. Only applicable to -receiving rates.

packets - - -number - - - - - - - -

The amount of packets that have been received or sent.

bytes - - -number - - - - - - - -

The amount of bytes that have been received or sent.

failed - - -number - - - - - - <optional>
- - - -

The amount of failed tranmission attempts. Only applicable to -transmit rates.

retries - - -number - - - - - - <optional>
- - - -

The amount of retried transmissions. Only applicable to transmit -rates.

is_ht - - -boolean - - - - - - - -

Specifies whether this rate is an HT (IEEE 802.11n) rate.

is_vht - - -boolean - - - - - - - -

Specifies whether this rate is an VHT (IEEE 802.11ac) rate.

mhz - - -number - - - - - - - -

The channel width in MHz used for the transmission.

rate - - -number - - - - - - - -

The bitrate in bit/s of the transmission.

mcs - - -number - - - - - - <optional>
- - - -

The MCS index of the used transmission rate. Only applicable to -HT or VHT rates.

40mhz - - -number - - - - - - <optional>
- - - -

Specifies whether the tranmission rate used 40MHz wide channel. -Only applicable to HT or VHT rates.

-

Note: this option exists for backwards compatibility only and its -use is discouraged. The mhz field should be used instead to -determine the channel width.

short_gi - - -boolean - - - - - - <optional>
- - - -

Specifies whether a short guard interval is used for the transmission. -Only applicable to HT or VHT rates.

nss - - -number - - - - - - <optional>
- - - -

Specifies the number of spatial streams used by the transmission. -Only applicable to VHT rates.

- - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
-
-

LuCI.Network.WifiScanResultObject.<string, (number|string|LuCI.Network.WifiEncryption)>

-
- - -
-
- -
-

A wireless scan result object describes a neighbouring wireless -network found in the vincinity.

-
- - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
ssid - - -string - - - -

The SSID / Mesh ID of the network.

bssid - - -string - - - -

The BSSID if the network.

mode - - -string - - - -

The operation mode of the network (Master, Ad-Hoc, Mesh Point).

channel - - -number - - - -

The wireless channel of the network.

signal - - -number - - - -

The received signal strength of the network in dBm.

quality - - -number - - - -

The numeric quality level of the signal, can be used in conjunction -with quality_max to calculate a quality percentage.

quality_max - - -number - - - -

The maximum possible quality level of the signal, can be used in -conjunction with quality to calculate a quality percentage.

encryption - - -LuCI.Network.WifiEncryption - - - -

The encryption used by the wireless network.

- - - - - - - - - - - - - - - - - - - - - - -
- - - -
- -
- - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Poll.html b/docs/jsapi/LuCI.Poll.html deleted file mode 100644 index 0952abd55..000000000 --- a/docs/jsapi/LuCI.Poll.html +++ /dev/null @@ -1,2500 +0,0 @@ - - - - - Class: Poll - - - - - - - - - - - - - - - - - -
- - -
-

Class: Poll

- - - - -
- -
-

- LuCI. - - Poll -

- -

The Poll class allows registering and unregistering poll actions, -as well as starting, stopping and querying the state of the polling -loop.

- -
- -
-
- - - - -
-
-

- - new LuCI.Poll() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - -

Methods

- -
- -
-
-

- - active(){boolean} -

- - - - -
- - -
-
- - -
-

Test whether the polling loop is running.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - -
    -
  • Returns true if polling is active, else false.
  • -
- - - - -
- - - -
-
-

- - add(fn, interval){boolean} -

- - - - -
- - -
-
- - -
-

Add a new operation to the polling loop. If the polling loop is not -already started at this point, it will be implicitely started.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
fn - - -function - - - - - -

The function to invoke on each poll interval.

interval - - -number - - - - - -

The poll interval in seconds.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
Throws:
- - - -
-
-
-

Throws TypeError when an invalid interval was passed.

-
-
-
-
-
- Type -
-
- -TypeError - - -
-
-
-
- - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if the function has been added or false if it -already is registered.
- - - - -
- - - -
-
-

- - remove(fn){boolean} -

- - - - -
- - -
-
- - -
-

Remove an operation from the polling loop. If no further operatons -are registered, the polling loop is implicitely stopped.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
fn - - -function - - - - - -

The function to remove.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
Throws:
- - - -
-
-
-

Throws TypeError when the given argument isn't a function.

-
-
-
-
-
- Type -
-
- -TypeError - - -
-
-
-
- - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if the function has been removed or false if it -wasn't found.
- - - - -
- - - -
-
-

- - start(){boolean} -

- - - - -
- - -
-
- - -
-

(Re)start the polling loop. Dispatches a custom poll-start event -to the document object upon successful start.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if polling has been started (or if no functions -where registered) or false when the polling loop already runs.
- - - - -
- - - -
-
-

- - stop(){boolean} -

- - - - -
- - -
-
- - -
-

Stop the polling loop. Dispatches a custom poll-stop event -to the document object upon successful stop.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if polling has been stopped or false if it din't -run to begin with.
- - - - -
- -
- - - - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Request.html b/docs/jsapi/LuCI.Request.html deleted file mode 100644 index b3cbe7cbf..000000000 --- a/docs/jsapi/LuCI.Request.html +++ /dev/null @@ -1,3435 +0,0 @@ - - - - - Class: Request - - - - - - - - - - - - - - - - - -
- - -
-

Class: Request

- - - - -
- -
-

- LuCI. - - Request -

- -

The Request class allows initiating HTTP requests and provides utilities -for dealing with responses.

- -
- -
-
- - - - -
-
-

- - new LuCI.Request() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - -

Classes

- -
-
poll
-
-
- - - - - - - -

Methods

- -
- -
-
-

- - addInterceptor(interceptorFn){LuCI.Request.interceptorFn} -

- - - - -
- - -
-
- - -
-

Register an HTTP response interceptor function. Interceptor -functions are useful to perform default actions on incoming HTTP -responses, such as checking for expired authentication or for -implementing request retries before returning a failure.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
interceptorFn - - -LuCI.Request.interceptorFn - - - - - -

The interceptor function to register.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - LuCI.Request.interceptorFn - - - The registered function.
- - - - -
- - - -
-
-

- - expandURL(url){string} -

- - - - -
- - -
-
- - -
-

Turn the given relative URL into an absolute URL if necessary.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
url - - -string - - - - - -

The URL to convert.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - The absolute URL derived from the given one, or the original URL -if it already was absolute.
- - - - -
- - - -
-
-

- - get(target, options){Promise.<LuCI.Response>} -

- - - - -
- - -
-
- - -
-

Initiate an HTTP GET request to the given target.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
target - - -string - - - - - - - - - - -

The URL to request.

options - - -LuCI.Request.RequestOptions - - - - - - - optional - - - - - -

Additional options to configure the request.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<LuCI.Response> - - - The resulting HTTP response.
- - - - -
- - - -
-
-

- - post(target, data, options){Promise.<LuCI.Response>} -

- - - - -
- - -
-
- - -
-

Initiate an HTTP POST request to the given target.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
target - - -string - - - - - - - - - - -

The URL to request.

data - - -* - - - - - - - optional - - - - - -

The request data to send, see LuCI.Request.RequestOptions for details.

options - - -LuCI.Request.RequestOptions - - - - - - - optional - - - - - -

Additional options to configure the request.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<LuCI.Response> - - - The resulting HTTP response.
- - - - -
- - - -
-
-

- - removeInterceptor(interceptorFn){boolean} -

- - - - -
- - -
-
- - -
-

Remove an HTTP response interceptor function. The passed function -value must be the very same value that was used to register the -function.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
interceptorFn - - -LuCI.Request.interceptorFn - - - - - -

The interceptor function to remove.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if any function has been removed, else false.
- - - - -
- - - -
-
-

- - request(target, options){Promise.<LuCI.Response>} -

- - - - -
- - -
-
- - -
-

Initiate an HTTP request to the given target.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
target - - -string - - - - - - - - - - -

The URL to request.

options - - -LuCI.Request.RequestOptions - - - - - - - optional - - - - - -

Additional options to configure the request.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<LuCI.Response> - - - The resulting HTTP response.
- - - - -
- -
- - - -

Type Definitions

- -
- -
-
-

- - LuCI.Request.interceptorFn(res) -

- - - - -
- - -
-
- - -
-

Interceptor functions are invoked whenever an HTTP reply is received, in the order -these functions have been registered.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
res - - -LuCI.Response - - - - - -

The HTTP response object

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - -
-
-

LuCI.Request.RequestOptionsObject

-
- - -
-
- - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDefaultDescription
method - - -string - - - - - - <optional>
- - - -
- - GET - -

The HTTP method to use, e.g. GET or POST.

query - - -Object.<string, (Object|string)> - - - - - - <optional>
- - - -
- -

Query string data to append to the URL. Non-string values of the -given object will be converted to JSON.

cache - - -boolean - - - - - - <optional>
- - - -
- - false - -

Specifies whether the HTTP response may be retrieved from cache.

username - - -string - - - - - - <optional>
- - - -
- -

Provides a username for HTTP basic authentication.

password - - -string - - - - - - <optional>
- - - -
- -

Provides a password for HTTP basic authentication.

timeout - - -number - - - - - - <optional>
- - - -
- -

Specifies the request timeout in seconds.

credentials - - -boolean - - - - - - <optional>
- - - -
- - false - -

Whether to include credentials such as cookies in the request.

responseType - - -string - - - - - - <optional>
- - - -
- - text - -

Overrides the request response type. Valid values or text to -interpret the response as UTF-8 string or blob to handle the -response as binary Blob data.

content - - -* - - - - - - <optional>
- - - -
- -

Specifies the HTTP message body to send along with the request. -If the value is a function, it is invoked and the return value -used as content, if it is a FormData instance, it is used as-is, -if it is an object, it will be converted to JSON, in all other -cases it is converted to a string.

header - - -Object.<string, string> - - - - - - <optional>
- - - -
- -

Specifies HTTP headers to set for the request.

progress - - -function - - - - - - <optional>
- - - -
- -

An optional request callback function which receives ProgressEvent -instances as sole argument during the HTTP request transfer.

- - - - - - - - - - - - - - - - - - - - - - -
- - - -
- -
- - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Request.poll.html b/docs/jsapi/LuCI.Request.poll.html deleted file mode 100644 index 7a993ab57..000000000 --- a/docs/jsapi/LuCI.Request.poll.html +++ /dev/null @@ -1,2619 +0,0 @@ - - - - - Class: poll - - - - - - - - - - - - - - - - - -
- - -
-

Class: poll

- - - - -
- -
-

- LuCI.Request. - - poll -

- -

The Request.poll class provides some convience wrappers around -LuCI.Poll mainly to simplify registering repeating HTTP -request calls as polling functions.

- -
- -
-
- - - - -
-
-

- - new LuCI.Request.poll() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - -

Methods

- -
- -
-
-

- - active() -

- - - - -
- - -
-
- - -
-

Alias for LuCI.Poll.active().

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - -
-
-

- - add(interval, url, options, callback){function} -

- - - - -
- - -
-
- - -
-

Register a repeating HTTP request with an optional callback -to invoke whenever a response for the request is received.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
interval - - -number - - - - - - - - - - -

The poll interval in seconds.

url - - -string - - - - - - - - - - -

The URL to request on each poll.

options - - -LuCI.Request.RequestOptions - - - - - - - optional - - - - - -

Additional options to configure the request.

callback - - -LuCI.Request.poll~callbackFn - - - - - - - optional - - - - - -

Callback function to -invoke for each HTTP reply.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
Throws:
- - - -
-
-
-

Throws TypeError when an invalid interval was passed.

-
-
-
-
-
- Type -
-
- -TypeError - - -
-
-
-
- - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - function - - - Returns the internally created poll function.
- - - - -
- - - -
-
-

- - remove(entry){boolean} -

- - - - -
- - -
-
- - -
-

Remove a polling request that has been previously added using add(). -This function is essentially a wrapper around -LuCI.Poll.remove().

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
entry - - -function - - - - - -

The poll function returned by add().

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if any function has been removed, else false.
- - - - -
- - - -
-
-

- - start() -

- - - - -
- - -
-
- - -
-

Alias for LuCI.Poll.start().

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - -
-
-

- - stop() -

- - - - -
- - -
-
- - -
-

Alias for LuCI.Poll.stop().

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- -
- - - -

Type Definitions

- -
- -
-
-

- - callbackFn(res, data, duration) -

- - - - -
- - -
-
- - -
-

The callback function is invoked whenever an HTTP reply to a -polled request is received or when the polled request timed -out.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
res - - -LuCI.Response - - - - - -

The HTTP response object.

data - - -* - - - - - -

The response JSON if the response could be parsed as such, -else null.

duration - - -number - - - - - -

The total duration of the request in milliseconds.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- -
- - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.Response.html b/docs/jsapi/LuCI.Response.html deleted file mode 100644 index a861348b3..000000000 --- a/docs/jsapi/LuCI.Response.html +++ /dev/null @@ -1,2577 +0,0 @@ - - - - - Class: Response - - - - - - - - - - - - - - - - - -
- - -
-

Class: Response

- - - - -
- -
-

- LuCI. - - Response -

- -

The Response class is an internal utility class representing HTTP responses.

- -
- -
-
- - - - -
-
-

- - new LuCI.Response() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - -

Members

- -
- -
-
-

durationnumber

-
- - -
-
- -
-

The total duration of the HTTP request in milliseconds

-
- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
-
-

headersLuCI.Headers

-
- - -
-
- -
-

The HTTP headers of the response

-
- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
-
-

okboolean

-
- - -
-
- -
-

Describes whether the response is successful (status codes 200..299) or not

-
- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
-
-

statusnumber

-
- - -
-
- -
-

The numeric HTTP status code of the response

-
- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
-
-

statusTextstring

-
- - -
-
- -
-

The HTTP status description message of the response

-
- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
-
-

urlstring

-
- - -
-
- -
-

The final URL of the request, i.e. after following redirects.

-
- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - -
- -
- - - -

Methods

- -
- -
-
-

- - blob(){Blob} -

- - - - -
- - -
-
- - -
-

Access the response content as blob.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Blob - - - The response content as blob.
- - - - -
- - - -
-
-

- - clone(content){LuCI.Response} -

- - - - -
- - -
-
- - -
-

Clones the given response object, optionally overriding the content -of the cloned instance.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
content - - -* - - - - - - - optional - - - - - -

Override the content of the cloned response. Object values will be -treated as JSON response data, all other types will be converted -using String() and treated as response text.

- - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - LuCI.Response - - - The cloned Response instance.
- - - - -
- - - -
-
-

- - json(){*} -

- - - - -
- - -
-
- - -
-

Access the response content as JSON data.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
Throws:
- - - -
-
-
-

Throws SyntaxError if the content isn't valid JSON.

-
-
-
-
-
- Type -
-
- -SyntaxError - - -
-
-
-
- - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - * - - - The parsed JSON data.
- - - - -
- - - -
-
-

- - text(){string} -

- - - - -
- - -
-
- - -
-

Access the response content as string.

-
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - string - - - The response content.
- - - - -
- -
- - - - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.XHR.html b/docs/jsapi/LuCI.XHR.html deleted file mode 100644 index 4516d9695..000000000 --- a/docs/jsapi/LuCI.XHR.html +++ /dev/null @@ -1,2669 +0,0 @@ - - - - - Class: XHR - - - - - - - - - - - - - - - - - -
- - -
-

Class: XHR

- - - - -
- -
-

- LuCI. - - XHR -

- -

The LuCI.XHR class is a legacy compatibility shim for the -functionality formerly provided by xhr.js. It is registered as global -window.XHR symbol for compatibility with legacy code.

-

New code should use LuCI.Request instead to implement HTTP -request handling.

- -
- -
-
- - - - -
-
-

- - new LuCI.XHR() -

- - - - -
- - -
-
- - - - - - - - - - -
- - - - - - - -
Deprecated
  • Yes
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - -

Methods

- -
- -
-
-

- - abort() -

- - - - -
- - -
-
- - -
-

Ignored for backwards compatibility.

-

This function does nothing.

-
- - - - - - - - - -
- - - - - - - -
Deprecated
  • Yes
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - -
-
-

- - busy(){boolean} -

- - - - -
- - -
-
- - -
-

Checks the running state of the request.

-
- - - - - - - - - -
- - - - - - - -
Deprecated
  • Yes
- - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - boolean - - - Returns true if the request is still running or false if it -already completed.
- - - - -
- - - -
-
-

- - cancel() -

- - - - -
- - -
-
- - -
-

Cancels a running request.

-

This function does not actually cancel the underlying -XMLHTTPRequest request but it sets a flag which prevents the -invocation of the callback function when the request eventually -finishes or timed out.

-
- - - - - - - - - -
- - - - - - - -
Deprecated
  • Yes
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - -
-
-

- - get(url, data, callback, timeout){Promise.<null>} -

- - - - -
- - -
-
- - -
-

This function is a legacy wrapper around -LuCI.get().

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
url - - -string - - - - - - - - - - -

The URL to request

data - - -Object - - - - - - - optional - - - - - -

Additional query string data

callback - - -LuCI.requestCallbackFn - - - - - - - optional - - - - - -

Callback function to invoke on completion

timeout - - -number - - - - - - - optional - - - - - -

Request timeout to use

- - - -
- - - - - - - -
Deprecated
  • Yes
- - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<null> - - -
- - - - -
- - - -
-
-

- - post(url, data, callback, timeout){Promise.<null>} -

- - - - -
- - -
-
- - -
-

This function is a legacy wrapper around -LuCI.post().

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
url - - -string - - - - - - - - - - -

The URL to request

data - - -Object - - - - - - - optional - - - - - -

Additional data to append to the request body.

callback - - -LuCI.requestCallbackFn - - - - - - - optional - - - - - -

Callback function to invoke on completion

timeout - - -number - - - - - - - optional - - - - - -

Request timeout to use

- - - -
- - - - - - - -
Deprecated
  • Yes
- - - - - - - - - - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - Promise.<null> - - -
- - - - -
- - - -
-
-

- - send_form() -

- - - - -
- - -
-
- - -
-

Existing for backwards compatibility.

-

This function simply throws an InternalError when invoked.

-
- - - - - - - - - -
- - - - - - - -
Deprecated
  • Yes
- - - - - - - - - - - - - - - -
- - - - - - - - - -
Throws:
- - - -
-
-
-

Throws an InternalError with the message Not implemented -when invoked.

-
-
-
-
-
- Type -
-
- -InternalError - - -
-
-
-
- - - - - - - -
- -
- - - - - - - -
- -
- - - - - - - -
- Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) -
-
-
- - - - \ No newline at end of file diff --git a/docs/jsapi/LuCI.baseclass.html b/docs/jsapi/LuCI.baseclass.html new file mode 100644 index 000000000..01e84ba58 --- /dev/null +++ b/docs/jsapi/LuCI.baseclass.html @@ -0,0 +1,2952 @@ + + + + + Class: baseclass + + + + + + + + + + + + + + + + + +
+ + +
+

Class: baseclass

+ + + + +
+ +
+

+ LuCI. + + baseclass +

+ +

LuCI.baseclass is the abstract base class all LuCI classes inherit from.

+

It provides simple means to create subclasses of given classes and +implements prototypal inheritance.

+ +
+ +
+
+ + + + +
+
+

+ + new LuCI.baseclass() +

+ + + + +
+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

+ + staticLuCI.baseclass.extend(properties){LuCI.baseclass} +

+ + + + +
+ + +
+
+ + +
+

Extends this base class with the properties described in +properties and returns a new subclassed Class instance

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
properties + + +Object.<string, *> + + + + + +

An object describing the properties to add to the new +subclass.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.baseclass + + + Returns a new LuCI.baseclass sublassed from this class, extended +by the given properties and with its prototype set to this base +class to enable inheritance. The resulting value represents a +class constructor and can be instantiated with new.
+ + + + +
+ + + +
+
+

+ + staticLuCI.baseclass.instantiate(params, new_args){LuCI.baseclass} +

+ + + + +
+ + +
+
+ + +
+

Calls the class constructor using new with the given argument +array being passed as variadic parameters to the constructor.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
params + + +Array.<*> + + + + + + + + + + +

An array of arbitrary values which will be passed as arguments +to the constructor function.

new_args + + +* + + + + + + + optional + + + + + repeatable + + +

Specifies arguments to be passed to the subclass constructor +as-is in order to instantiate the new subclass.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.baseclass + + + Returns a new LuCI.baseclass instance extended by the given +properties with its prototype set to this base class to +enable inheritance.
+ + + + +
+ + + +
+
+

+ + staticLuCI.baseclass.isSubclass(classValue){boolean} +

+ + + + +
+ + +
+
+ + +
+

Checks whether the given class value is a subclass of this class.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
classValue + + +LuCI.baseclass + + + + + +

The class object to test.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + boolean + + + Returns true when the given classValue is a subclass of this +class or false if the given value is not a valid class or not +a subclass of this class'.
+ + + + +
+ + + +
+
+

+ + staticLuCI.baseclass.singleton(properties, new_args){LuCI.baseclass} +

+ + + + +
+ + +
+
+ + +
+

Extends this base class with the properties described in +properties, instantiates the resulting subclass using +the additional optional arguments passed to this function +and returns the resulting subclassed Class instance.

+

This function serves as a convenience shortcut for +Class.extend() and subsequent +new.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
properties + + +Object.<string, *> + + + + + + + + + + +

An object describing the properties to add to the new +subclass.

new_args + + +* + + + + + + + optional + + + + + repeatable + + +

Specifies arguments to be passed to the subclass constructor +as-is in order to instantiate the new subclass.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + LuCI.baseclass + + + Returns a new LuCI.baseclass instance extended by the given +properties with its prototype set to this base class to +enable inheritance.
+ + + + +
+ + + +
+
+

+ + super(key, callArgs){*|null} +

+ + + + +
+ + +
+
+ + +
+

Walks up the parent class chain and looks for a class member +called key in any of the parent classes this class inherits +from. Returns the member value of the superclass or calls the +member as function and returns its return value when the +optional callArgs array is given.

+

This function has two signatures and is sensitive to the +amount of arguments passed to it:

+
    +
  • super('key') - +Returns the value of key when found within one of the +parent classes.
  • +
  • super('key', ['arg1', 'arg2']) - +Calls the key() method with parameters arg1 and arg2 +when found within one of the parent classes.
  • +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +string + + + + + + + + + + +

The name of the superclass member to retrieve.

callArgs + + +Array.<*> + + + + + + + optional + + + + + +

An optional array of function call parameters to use. When +this parameter is specified, the found member value is called +as function using the values of this array as arguments.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
Throws:
+ + + +
+
+
+

Throws a ReferenceError when callArgs are specified and +the found member named by key is not a function value.

+
+
+
+
+
+ Type +
+
+ +ReferenceError + + +
+
+
+
+ + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + * + | + + null + + + Returns the value of the found member or the return value of +the call to the found method. Returns null when no member +was found in the parent class chain or when the call to the +superclass method returned null.
+ + + + +
+ + + +
+
+

+ + varargs(args, offset, extra_args){Array.<*>} +

+ + + + +
+ + +
+
+ + +
+

Extract all values from the given argument array beginning from +offset and prepend any further given optional parameters to +the beginning of the resulting array copy.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
args + + +Array.<*> + + + + + + + + + + +

The array to extract the values from.

offset + + +number + + + + + + + + + + +

The offset from which to extract the values. An offset of 0 +would copy all values till the end.

extra_args + + +* + + + + + + + optional + + + + + repeatable + + +

Extra arguments to add to prepend to the resultung array.

+ + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + Array.<*> + + + Returns a new array consisting of the optional extra arguments +and the values extracted from the args array beginning with +offset.
+ + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ Documentation generated by JSDoc 3.6.3 on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time) +
+
+
+ + + + \ No newline at end of file diff --git a/docs/jsapi/LuCI.dom.html b/docs/jsapi/LuCI.dom.html index abf438601..c050ca0be 100644 --- a/docs/jsapi/LuCI.dom.html +++ b/docs/jsapi/LuCI.dom.html @@ -43,8 +43,18 @@ Members +
  • Class
  • + +
  • dom
  • +
  • env
  • +
  • Poll
  • + +
  • Request
  • + +
  • view
  • + -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -1728,7 +1736,7 @@ it in external JavaScript, use L.require("ui").then(...) @@ -1813,7 +1821,7 @@ it in external JavaScript, use L.require("ui").then(...) @@ -1922,7 +1930,7 @@ an array of strings or null for unset values. @@ -2023,7 +2031,7 @@ not meet the validation constraints. @@ -2193,7 +2201,7 @@ registered.

      @@ -2294,7 +2302,7 @@ widget markup. @@ -2451,7 +2459,7 @@ as dirty.

      @@ -2606,7 +2614,7 @@ trigger input value validation.

      @@ -2731,7 +2739,7 @@ or null values.

      @@ -2987,7 +2995,7 @@ corresponding <input> element.

      An expression describing the input data validation constraints. It defaults to string which will allow any value. -SeeLuCI.validation for details on the expression format.

      +See LuCI.validation for details on the expression format.

      @@ -3076,7 +3084,7 @@ converted to a string and treated as validation error message.

      - Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) + Documentation generated by JSDoc 3.6.3 on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time)
      diff --git a/docs/jsapi/LuCI.ui.Checkbox.html b/docs/jsapi/LuCI.ui.Checkbox.html index 79fa47f08..2554607b9 100644 --- a/docs/jsapi/LuCI.ui.Checkbox.html +++ b/docs/jsapi/LuCI.ui.Checkbox.html @@ -43,8 +43,18 @@ Members +
    • Class
    • + +
    • dom
    • +
    • env
    • +
    • Poll
    • + +
    • Request
    • + +
    • view
    • +
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -1720,7 +1728,7 @@ external JavaScript, use L.require("ui").then(...).

      - ui.js, line 2925 + ui.js, line 2929 @@ -1848,7 +1856,7 @@ external JavaScript, use L.require("ui").then(...).

      - ui.js, line 3105 + ui.js, line 3109 @@ -1950,7 +1958,7 @@ will be rendered.

      The contents to add to the notification banner. This should be a DOM node or a document fragment in most cases. The value is passed as-is -to the L.dom.content() function - refer to its documentation for +to the dom.content() function - refer to its documentation for applicable values.

      @@ -2078,7 +2086,7 @@ banner element.

      @@ -2392,7 +2400,7 @@ trigger field validation or to bind it to further events. @@ -2529,7 +2537,7 @@ default.

      @@ -2755,7 +2763,7 @@ valid function value. @@ -2903,7 +2911,7 @@ requested indicator was not found. @@ -2979,7 +2987,7 @@ handler as-is without the need to bind it first.

      @@ -3221,7 +3229,7 @@ accepted by LuCI.dom.content().

      @@ -3424,7 +3432,7 @@ or rejecting with null when the connectivity check timed out. @@ -3695,7 +3703,7 @@ changes were made. @@ -3796,7 +3804,7 @@ the dialog. Valid values for the classes depend on the underlying theme.

      The contents to add to the modal dialog. This should be a DOM node or a document fragment in most cases. The value is passed as-is to the -L.dom.content() function - refer to its documentation for applicable +dom.content() function - refer to its documentation for applicable values.

      @@ -3924,7 +3932,7 @@ element.

      @@ -4282,7 +4290,7 @@ cancelled by the user.
      - Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) + Documentation generated by JSDoc 3.6.3 on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time)
      diff --git a/docs/jsapi/LuCI.ui.tabs.html b/docs/jsapi/LuCI.ui.tabs.html index ec5f92ffb..16d23dcfe 100644 --- a/docs/jsapi/LuCI.ui.tabs.html +++ b/docs/jsapi/LuCI.ui.tabs.html @@ -43,8 +43,18 @@ Members +
    • Class
    • + +
    • dom
    • +
    • env
    • +
    • Poll
    • + +
    • Request
    • + +
    • view
    • +
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -1724,7 +1732,7 @@ external JavaScript, use L.require("ui").then(...) and ac @@ -1809,7 +1817,7 @@ external JavaScript, use L.require("ui").then(...) and ac @@ -1938,7 +1946,7 @@ DOM node.

      @@ -2091,7 +2099,7 @@ DOM node.

      - Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) + Documentation generated by JSDoc 3.6.3 on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time)
      diff --git a/docs/jsapi/LuCI.view.html b/docs/jsapi/LuCI.view.html index 200f00ea5..456beee2a 100644 --- a/docs/jsapi/LuCI.view.html +++ b/docs/jsapi/LuCI.view.html @@ -43,8 +43,18 @@ Members +
    • Class
    • + +
    • dom
    • +
    • env
    • +
    • Poll
    • + +
    • Request
    • + +
    • view
    • +
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -1694,6 +1702,8 @@
      'use strict';
       'require rpc';
      +'require request';
      +'require baseclass';
       
       /**
        * @typedef {Object} FileStatEntry
      @@ -1846,7 +1856,7 @@ function handleCgiIoReply(res) {
        * To import the class in views, use `'require fs'`, to import it in
        * external JavaScript, use `L.require("fs").then(...)`.
        */
      -var FileSystem = L.Class.extend(/** @lends LuCI.fs.prototype */ {
      +var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
       	/**
       	 * Obtains a listing of the specified directory.
       	 *
      @@ -2051,7 +2061,7 @@ var FileSystem = L.Class.extend(/** @lends LuCI.fs.prototype */ {
       		var postdata = 'sessionid=%s&path=%s'
       			.format(encodeURIComponent(L.env.sessionid), encodeURIComponent(path));
       
      -		return L.Request.post(L.env.cgi_base + '/cgi-download', postdata, {
      +		return request.post(L.env.cgi_base + '/cgi-download', postdata, {
       			headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
       			responseType: (type == 'blob') ? 'blob' : 'text'
       		}).then(handleCgiIoReply.bind({ type: type }));
      @@ -2111,7 +2121,7 @@ var FileSystem = L.Class.extend(/** @lends LuCI.fs.prototype */ {
       		var postdata = 'sessionid=%s&command=%s'
       			.format(encodeURIComponent(L.env.sessionid), cmdstr);
       
      -		return L.Request.post(L.env.cgi_base + '/cgi-exec', postdata, {
      +		return request.post(L.env.cgi_base + '/cgi-exec', postdata, {
       			headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
       			responseType: (type == 'blob') ? 'blob' : 'text'
       		}).then(handleCgiIoReply.bind({ type: type }));
      @@ -2131,7 +2141,7 @@ return FileSystem;
               
       
               
      - Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) + Documentation generated by JSDoc 3.6.3 on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time)
      diff --git a/docs/jsapi/index.html b/docs/jsapi/index.html index 6760e4bb8..127e4e59e 100644 --- a/docs/jsapi/index.html +++ b/docs/jsapi/index.html @@ -43,8 +43,18 @@ Members +
    • Class
    • + +
    • dom
    • +
    • env
    • +
    • Poll
    • + +
    • Request
    • + +
    • view
    • +
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -1720,7 +1728,7 @@
      - Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) + Documentation generated by JSDoc 3.6.3 on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time)
      diff --git a/docs/jsapi/luci.js.html b/docs/jsapi/luci.js.html index f5e0c81d0..7455146df 100644 --- a/docs/jsapi/luci.js.html +++ b/docs/jsapi/luci.js.html @@ -43,8 +43,18 @@ Members +
    • Class
    • + +
    • dom
    • +
    • env
    • +
    • Poll
    • + +
    • Request
    • + +
    • view
    • +
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -1751,12 +1759,12 @@ }; /** - * @class Class + * @class baseclass * @hideconstructor * @memberof LuCI * @classdesc * - * `LuCI.Class` is the abstract base class all LuCI classes inherit from. + * `LuCI.baseclass` is the abstract base class all LuCI classes inherit from. * * It provides simple means to create subclasses of given classes and * implements prototypal inheritance. @@ -1766,14 +1774,14 @@ * Extends this base class with the properties described in * `properties` and returns a new subclassed Class instance * - * @memberof LuCI.Class + * @memberof LuCI.baseclass * * @param {Object<string, *>} properties * An object describing the properties to add to the new * subclass. * - * @returns {LuCI.Class} - * Returns a new LuCI.Class sublassed from this class, extended + * @returns {LuCI.baseclass} + * Returns a new LuCI.baseclass sublassed from this class, extended * by the given properties and with its prototype set to this base * class to enable inheritance. The resulting value represents a * class constructor and can be instantiated with `new`. @@ -1819,10 +1827,10 @@ * and returns the resulting subclassed Class instance. * * This function serves as a convenience shortcut for - * {@link LuCI.Class.extend Class.extend()} and subsequent + * {@link LuCI.baseclass.extend Class.extend()} and subsequent * `new`. * - * @memberof LuCI.Class + * @memberof LuCI.baseclass * * @param {Object<string, *>} properties * An object describing the properties to add to the new @@ -1832,8 +1840,8 @@ * Specifies arguments to be passed to the subclass constructor * as-is in order to instantiate the new subclass. * - * @returns {LuCI.Class} - * Returns a new LuCI.Class instance extended by the given + * @returns {LuCI.baseclass} + * Returns a new LuCI.baseclass instance extended by the given * properties with its prototype set to this base class to * enable inheritance. */ @@ -1846,7 +1854,7 @@ * Calls the class constructor using `new` with the given argument * array being passed as variadic parameters to the constructor. * - * @memberof LuCI.Class + * @memberof LuCI.baseclass * * @param {Array<*>} params * An array of arbitrary values which will be passed as arguments @@ -1856,8 +1864,8 @@ * Specifies arguments to be passed to the subclass constructor * as-is in order to instantiate the new subclass. * - * @returns {LuCI.Class} - * Returns a new LuCI.Class instance extended by the given + * @returns {LuCI.baseclass} + * Returns a new LuCI.baseclass instance extended by the given * properties with its prototype set to this base class to * enable inheritance. */ @@ -1877,9 +1885,9 @@ /** * Checks whether the given class value is a subclass of this class. * - * @memberof LuCI.Class + * @memberof LuCI.baseclass * - * @param {LuCI.Class} classValue + * @param {LuCI.baseclass} classValue * The class object to test. * * @returns {boolean} @@ -1899,7 +1907,7 @@ * `offset` and prepend any further given optional parameters to * the beginning of the resulting array copy. * - * @memberof LuCI.Class + * @memberof LuCI.baseclass * @instance * * @param {Array<*>} args @@ -1938,7 +1946,7 @@ * Calls the `key()` method with parameters `arg1` and `arg2` * when found within one of the parent classes. * - * @memberof LuCI.Class + * @memberof LuCI.baseclass * @instance * * @param {string} key @@ -2022,7 +2030,7 @@ /** - * @class + * @class headers * @memberof LuCI * @hideconstructor * @classdesc @@ -2030,8 +2038,8 @@ * The `Headers` class is an internal utility class exposed in HTTP * response objects using the `response.headers` property. */ - var Headers = Class.extend(/** @lends LuCI.Headers.prototype */ { - __name__: 'LuCI.XHR.Headers', + var Headers = Class.extend(/** @lends LuCI.headers.prototype */ { + __name__: 'LuCI.Headers', __init__: function(xhr) { var hdrs = this.headers = {}; xhr.getAllResponseHeaders().split(/\r\n/).forEach(function(line) { @@ -2046,7 +2054,7 @@ * Note: Header-Names are case-insensitive. * * @instance - * @memberof LuCI.Headers + * @memberof LuCI.headers * @param {string} name * The header name to check * @@ -2062,7 +2070,7 @@ * Note: Header-Names are case-insensitive. * * @instance - * @memberof LuCI.Headers + * @memberof LuCI.headers * @param {string} name * The header name to read * @@ -2076,7 +2084,7 @@ }); /** - * @class + * @class response * @memberof LuCI * @hideconstructor * @classdesc @@ -2084,12 +2092,12 @@ * The `Response` class is an internal utility class representing HTTP responses. */ var Response = Class.extend({ - __name__: 'LuCI.XHR.Response', + __name__: 'LuCI.Response', __init__: function(xhr, url, duration, headers, content) { /** * Describes whether the response is successful (status codes `200..299`) or not * @instance - * @memberof LuCI.Response + * @memberof LuCI.response * @name ok * @type {boolean} */ @@ -2098,7 +2106,7 @@ /** * The numeric HTTP status code of the response * @instance - * @memberof LuCI.Response + * @memberof LuCI.response * @name status * @type {number} */ @@ -2107,7 +2115,7 @@ /** * The HTTP status description message of the response * @instance - * @memberof LuCI.Response + * @memberof LuCI.response * @name statusText * @type {string} */ @@ -2116,16 +2124,16 @@ /** * The HTTP headers of the response * @instance - * @memberof LuCI.Response + * @memberof LuCI.response * @name headers - * @type {LuCI.Headers} + * @type {LuCI.headers} */ this.headers = (headers != null) ? headers : new Headers(xhr); /** * The total duration of the HTTP request in milliseconds * @instance - * @memberof LuCI.Response + * @memberof LuCI.response * @name duration * @type {number} */ @@ -2134,7 +2142,7 @@ /** * The final URL of the request, i.e. after following redirects. * @instance - * @memberof LuCI.Response + * @memberof LuCI.response * @name url * @type {string} */ @@ -2177,13 +2185,13 @@ * of the cloned instance. * * @instance - * @memberof LuCI.Response + * @memberof LuCI.response * @param {*} [content] * Override the content of the cloned response. Object values will be * treated as JSON response data, all other types will be converted * using `String()` and treated as response text. * - * @returns {LuCI.Response} + * @returns {LuCI.response} * The cloned `Response` instance. */ clone: function(content) { @@ -2200,7 +2208,7 @@ * Access the response content as JSON data. * * @instance - * @memberof LuCI.Response + * @memberof LuCI.response * @throws {SyntaxError} * Throws `SyntaxError` if the content isn't valid JSON. * @@ -2218,7 +2226,7 @@ * Access the response content as string. * * @instance - * @memberof LuCI.Response + * @memberof LuCI.response * @returns {string} * The response content. */ @@ -2233,7 +2241,7 @@ * Access the response content as blob. * * @instance - * @memberof LuCI.Response + * @memberof LuCI.response * @returns {Blob} * The response content as blob. */ @@ -2294,7 +2302,7 @@ } /** - * @class + * @class request * @memberof LuCI * @hideconstructor * @classdesc @@ -2302,8 +2310,8 @@ * The `Request` class allows initiating HTTP requests and provides utilities * for dealing with responses. */ - var Request = Class.singleton(/** @lends LuCI.Request.prototype */ { - __name__: 'LuCI.Request', + var Request = Class.singleton(/** @lends LuCI.request.prototype */ { + __name__: 'LuCI.request', interceptors: [], @@ -2311,7 +2319,7 @@ * Turn the given relative URL into an absolute URL if necessary. * * @instance - * @memberof LuCI.Request + * @memberof LuCI.request * @param {string} url * The URL to convert. * @@ -2328,7 +2336,7 @@ /** * @typedef {Object} RequestOptions - * @memberof LuCI.Request + * @memberof LuCI.request * * @property {string} [method=GET] * The HTTP method to use, e.g. `GET` or `POST`. @@ -2376,14 +2384,14 @@ * Initiate an HTTP request to the given target. * * @instance - * @memberof LuCI.Request + * @memberof LuCI.request * @param {string} target * The URL to request. * - * @param {LuCI.Request.RequestOptions} [options] + * @param {LuCI.request.RequestOptions} [options] * Additional options to configure the request. * - * @returns {Promise<LuCI.Response>} + * @returns {Promise<LuCI.response>} * The resulting HTTP response. */ request: function(target, options) { @@ -2525,14 +2533,14 @@ * Initiate an HTTP GET request to the given target. * * @instance - * @memberof LuCI.Request + * @memberof LuCI.request * @param {string} target * The URL to request. * - * @param {LuCI.Request.RequestOptions} [options] + * @param {LuCI.request.RequestOptions} [options] * Additional options to configure the request. * - * @returns {Promise<LuCI.Response>} + * @returns {Promise<LuCI.response>} * The resulting HTTP response. */ get: function(url, options) { @@ -2543,17 +2551,17 @@ * Initiate an HTTP POST request to the given target. * * @instance - * @memberof LuCI.Request + * @memberof LuCI.request * @param {string} target * The URL to request. * * @param {*} [data] - * The request data to send, see {@link LuCI.Request.RequestOptions} for details. + * The request data to send, see {@link LuCI.request.RequestOptions} for details. * - * @param {LuCI.Request.RequestOptions} [options] + * @param {LuCI.request.RequestOptions} [options] * Additional options to configure the request. * - * @returns {Promise<LuCI.Response>} + * @returns {Promise<LuCI.response>} * The resulting HTTP response. */ post: function(url, data, options) { @@ -2563,8 +2571,8 @@ /** * Interceptor functions are invoked whenever an HTTP reply is received, in the order * these functions have been registered. - * @callback LuCI.Request.interceptorFn - * @param {LuCI.Response} res + * @callback LuCI.request.interceptorFn + * @param {LuCI.response} res * The HTTP response object */ @@ -2575,11 +2583,11 @@ * implementing request retries before returning a failure. * * @instance - * @memberof LuCI.Request - * @param {LuCI.Request.interceptorFn} interceptorFn + * @memberof LuCI.request + * @param {LuCI.request.interceptorFn} interceptorFn * The interceptor function to register. * - * @returns {LuCI.Request.interceptorFn} + * @returns {LuCI.request.interceptorFn} * The registered function. */ addInterceptor: function(interceptorFn) { @@ -2594,8 +2602,8 @@ * function. * * @instance - * @memberof LuCI.Request - * @param {LuCI.Request.interceptorFn} interceptorFn + * @memberof LuCI.request + * @param {LuCI.request.interceptorFn} interceptorFn * The interceptor function to remove. * * @returns {boolean} @@ -2611,12 +2619,12 @@ /** * @class - * @memberof LuCI.Request + * @memberof LuCI.request * @hideconstructor * @classdesc * * The `Request.poll` class provides some convience wrappers around - * {@link LuCI.Poll} mainly to simplify registering repeating HTTP + * {@link LuCI.poll} mainly to simplify registering repeating HTTP * request calls as polling functions. */ poll: { @@ -2625,8 +2633,8 @@ * polled request is received or when the polled request timed * out. * - * @callback LuCI.Request.poll~callbackFn - * @param {LuCI.Response} res + * @callback LuCI.request.poll~callbackFn + * @param {LuCI.response} res * The HTTP response object. * * @param {*} data @@ -2642,18 +2650,18 @@ * to invoke whenever a response for the request is received. * * @instance - * @memberof LuCI.Request.poll + * @memberof LuCI.request.poll * @param {number} interval * The poll interval in seconds. * * @param {string} url * The URL to request on each poll. * - * @param {LuCI.Request.RequestOptions} [options] + * @param {LuCI.request.RequestOptions} [options] * Additional options to configure the request. * - * @param {LuCI.Request.poll~callbackFn} [callback] - * {@link LuCI.Request.poll~callbackFn Callback} function to + * @param {LuCI.request.poll~callbackFn} [callback] + * {@link LuCI.request.poll~callbackFn Callback} function to * invoke for each HTTP reply. * * @throws {TypeError} @@ -2689,12 +2697,12 @@ /** * Remove a polling request that has been previously added using `add()`. * This function is essentially a wrapper around - * {@link LuCI.Poll.remove LuCI.Poll.remove()}. + * {@link LuCI.poll.remove LuCI.poll.remove()}. * * @instance - * @memberof LuCI.Request.poll + * @memberof LuCI.request.poll * @param {function} entry - * The poll function returned by {@link LuCI.Request.poll#add add()}. + * The poll function returned by {@link LuCI.request.poll#add add()}. * * @returns {boolean} * Returns `true` if any function has been removed, else `false`. @@ -2702,33 +2710,33 @@ remove: function(entry) { return Poll.remove(entry) }, /** - * Alias for {@link LuCI.Poll.start LuCI.Poll.start()}. + * Alias for {@link LuCI.poll.start LuCI.poll.start()}. * * @instance - * @memberof LuCI.Request.poll + * @memberof LuCI.request.poll */ start: function() { return Poll.start() }, /** - * Alias for {@link LuCI.Poll.stop LuCI.Poll.stop()}. + * Alias for {@link LuCI.poll.stop LuCI.poll.stop()}. * * @instance - * @memberof LuCI.Request.poll + * @memberof LuCI.request.poll */ stop: function() { return Poll.stop() }, /** - * Alias for {@link LuCI.Poll.active LuCI.Poll.active()}. + * Alias for {@link LuCI.poll.active LuCI.poll.active()}. * * @instance - * @memberof LuCI.Request.poll + * @memberof LuCI.request.poll */ active: function() { return Poll.active() } } }); /** - * @class + * @class poll * @memberof LuCI * @hideconstructor * @classdesc @@ -2737,8 +2745,8 @@ * as well as starting, stopping and querying the state of the polling * loop. */ - var Poll = Class.singleton(/** @lends LuCI.Poll.prototype */ { - __name__: 'LuCI.Poll', + var Poll = Class.singleton(/** @lends LuCI.poll.prototype */ { + __name__: 'LuCI.poll', queue: [], @@ -2747,7 +2755,7 @@ * already started at this point, it will be implicitely started. * * @instance - * @memberof LuCI.Poll + * @memberof LuCI.poll * @param {function} fn * The function to invoke on each poll interval. * @@ -2766,7 +2774,7 @@ interval = window.L ? window.L.env.pollinterval : null; if (isNaN(interval) || typeof(fn) != 'function') - throw new TypeError('Invalid argument to LuCI.Poll.add()'); + throw new TypeError('Invalid argument to LuCI.poll.add()'); for (var i = 0; i < this.queue.length; i++) if (this.queue[i].fn === fn) @@ -2791,7 +2799,7 @@ * are registered, the polling loop is implicitely stopped. * * @instance - * @memberof LuCI.Poll + * @memberof LuCI.poll * @param {function} fn * The function to remove. * @@ -2804,7 +2812,7 @@ */ remove: function(fn) { if (typeof(fn) != 'function') - throw new TypeError('Invalid argument to LuCI.Poll.remove()'); + throw new TypeError('Invalid argument to LuCI.poll.remove()'); var len = this.queue.length; @@ -2823,7 +2831,7 @@ * to the `document` object upon successful start. * * @instance - * @memberof LuCI.Poll + * @memberof LuCI.poll * @returns {boolean} * Returns `true` if polling has been started (or if no functions * where registered) or `false` when the polling loop already runs. @@ -2848,7 +2856,7 @@ * to the `document` object upon successful stop. * * @instance - * @memberof LuCI.Poll + * @memberof LuCI.poll * @returns {boolean} * Returns `true` if polling has been stopped or `false` if it din't * run to begin with. @@ -2885,7 +2893,7 @@ * Test whether the polling loop is running. * * @instance - * @memberof LuCI.Poll + * @memberof LuCI.poll * @returns {boolean} - Returns `true` if polling is active, else `false`. */ active: function() { @@ -2893,1831 +2901,1887 @@ } }); + /** + * @class dom + * @memberof LuCI + * @hideconstructor + * @classdesc + * + * The `dom` class provides convenience method for creating and + * manipulating DOM elements. + * + * To import the class in views, use `'require dom'`, to import it in + * external JavaScript, use `L.require("dom").then(...)`. + */ + var DOM = Class.singleton(/* @lends LuCI.dom.prototype */ { + __name__: 'LuCI.DOM', - var dummyElem = null, - domParser = null, - originalCBIInit = null, - rpcBaseURL = null, - sysFeatures = null, - classes = {}; - - var LuCI = Class.extend(/** @lends LuCI.prototype */ { - __name__: 'LuCI', - __init__: function(env) { - - document.querySelectorAll('script[src*="/luci.js"]').forEach(function(s) { - if (env.base_url == null || env.base_url == '') { - var m = (s.getAttribute('src') || '').match(/^(.*)\/luci\.js(?:\?v=([^?]+))?$/); - if (m) { - env.base_url = m[1]; - env.resource_version = m[2]; - } - } - }); - - if (env.base_url == null) - this.error('InternalError', 'Cannot find url of luci.js'); - - env.cgi_base = env.scriptname.replace(/\/[^\/]+$/, ''); - - Object.assign(this.env, env); - - document.addEventListener('poll-start', function(ev) { - document.querySelectorAll('[id^="xhr_poll_status"]').forEach(function(e) { - e.style.display = (e.id == 'xhr_poll_status_off') ? 'none' : ''; - }); - }); + /** + * Tests whether the given argument is a valid DOM `Node`. + * + * @instance + * @memberof LuCI.dom + * @param {*} e + * The value to test. + * + * @returns {boolean} + * Returns `true` if the value is a DOM `Node`, else `false`. + */ + elem: function(e) { + return (e != null && typeof(e) == 'object' && 'nodeType' in e); + }, - document.addEventListener('poll-stop', function(ev) { - document.querySelectorAll('[id^="xhr_poll_status"]').forEach(function(e) { - e.style.display = (e.id == 'xhr_poll_status_on') ? 'none' : ''; - }); - }); + /** + * Parses a given string as HTML and returns the first child node. + * + * @instance + * @memberof LuCI.dom + * @param {string} s + * A string containing an HTML fragment to parse. Note that only + * the first result of the resulting structure is returned, so an + * input value of `<div>foo</div> <div>bar</div>` will only return + * the first `div` element node. + * + * @returns {Node} + * Returns the first DOM `Node` extracted from the HTML fragment or + * `null` on parsing failures or if no element could be found. + */ + parse: function(s) { + var elem; - var domReady = new Promise(function(resolveFn, rejectFn) { - document.addEventListener('DOMContentLoaded', resolveFn); - }); + try { + domParser = domParser || new DOMParser(); + elem = domParser.parseFromString(s, 'text/html').body.firstChild; + } + catch(e) {} - Promise.all([ - domReady, - this.require('ui'), - this.require('rpc'), - this.require('form'), - this.probeRPCBaseURL() - ]).then(this.setupDOM.bind(this)).catch(this.error); + if (!elem) { + try { + dummyElem = dummyElem || document.createElement('div'); + dummyElem.innerHTML = s; + elem = dummyElem.firstChild; + } + catch (e) {} + } - originalCBIInit = window.cbi_init; - window.cbi_init = function() {}; + return elem || null; }, /** - * Captures the current stack trace and throws an error of the - * specified type as a new exception. Also logs the exception as - * error to the debug console if it is available. + * Tests whether a given `Node` matches the given query selector. + * + * This function is a convenience wrapper around the standard + * `Node.matches("selector")` function with the added benefit that + * the `node` argument may be a non-`Node` value, in which case + * this function simply returns `false`. * * @instance - * @memberof LuCI + * @memberof LuCI.dom + * @param {*} node + * The `Node` argument to test the selector against. * - * @param {Error|string} [type=Error] - * Either a string specifying the type of the error to throw or an - * existing `Error` instance to copy. + * @param {string} [selector] + * The query selector expression to test against the given node. * - * @param {string} [fmt=Unspecified error] - * A format string which is used to form the error message, together - * with all subsequent optional arguments. + * @returns {boolean} + * Returns `true` if the given node matches the specified selector + * or `false` when the node argument is no valid DOM `Node` or the + * selector didn't match. + */ + matches: function(node, selector) { + var m = this.elem(node) ? node.matches || node.msMatchesSelector : null; + return m ? m.call(node, selector) : false; + }, + + /** + * Returns the closest parent node that matches the given query + * selector expression. * - * @param {...*} [args] - * Zero or more variable arguments to the supplied format string. + * This function is a convenience wrapper around the standard + * `Node.closest("selector")` function with the added benefit that + * the `node` argument may be a non-`Node` value, in which case + * this function simply returns `null`. * - * @throws {Error} - * Throws the created error object with the captured stack trace - * appended to the message and the type set to the given type - * argument or copied from the given error instance. + * @instance + * @memberof LuCI.dom + * @param {*} node + * The `Node` argument to find the closest parent for. + * + * @param {string} [selector] + * The query selector expression to test against each parent. + * + * @returns {Node|null} + * Returns the closest parent node matching the selector or + * `null` when the node argument is no valid DOM `Node` or the + * selector didn't match any parent. */ - raise: function(type, fmt /*, ...*/) { - var e = null, - msg = fmt ? String.prototype.format.apply(fmt, this.varargs(arguments, 2)) : null, - stack = null; + parent: function(node, selector) { + if (this.elem(node) && node.closest) + return node.closest(selector); - if (type instanceof Error) { - e = type; + while (this.elem(node)) + if (this.matches(node, selector)) + return node; + else + node = node.parentNode; - if (msg) - e.message = msg + ': ' + e.message; - } - else { - try { throw new Error('stacktrace') } - catch (e2) { stack = (e2.stack || '').split(/\n/) } + return null; + }, - e = new (window[type || 'Error'] || Error)(msg || 'Unspecified error'); - e.name = type || 'Error'; - } + /** + * Appends the given children data to the given node. + * + * @instance + * @memberof LuCI.dom + * @param {*} node + * The `Node` argument to append the children to. + * + * @param {*} [children] + * The childrens to append to the given node. + * + * When `children` is an array, then each item of the array + * will be either appended as child element or text node, + * depending on whether the item is a DOM `Node` instance or + * some other non-`null` value. Non-`Node`, non-`null` values + * will be converted to strings first before being passed as + * argument to `createTextNode()`. + * + * When `children` is a function, it will be invoked with + * the passed `node` argument as sole parameter and the `append` + * function will be invoked again, with the given `node` argument + * as first and the return value of the `children` function as + * second parameter. + * + * When `children` is is a DOM `Node` instance, it will be + * appended to the given `node`. + * + * When `children` is any other non-`null` value, it will be + * converted to a string and appened to the `innerHTML` property + * of the given `node`. + * + * @returns {Node|null} + * Returns the last children `Node` appended to the node or `null` + * if either the `node` argument was no valid DOM `node` or if the + * `children` was `null` or didn't result in further DOM nodes. + */ + append: function(node, children) { + if (!this.elem(node)) + return null; - stack = (stack || []).map(function(frame) { - frame = frame.replace(/(.*?)@(.+):(\d+):(\d+)/g, 'at $1 ($2:$3:$4)').trim(); - return frame ? ' ' + frame : ''; - }); + if (Array.isArray(children)) { + for (var i = 0; i < children.length; i++) + if (this.elem(children[i])) + node.appendChild(children[i]); + else if (children !== null && children !== undefined) + node.appendChild(document.createTextNode('' + children[i])); - if (!/^ at /.test(stack[0])) - stack.shift(); + return node.lastChild; + } + else if (typeof(children) === 'function') { + return this.append(node, children(node)); + } + else if (this.elem(children)) { + return node.appendChild(children); + } + else if (children !== null && children !== undefined) { + node.innerHTML = '' + children; + return node.lastChild; + } - if (/\braise /.test(stack[0])) - stack.shift(); + return null; + }, - if (/\berror /.test(stack[0])) - stack.shift(); + /** + * Replaces the content of the given node with the given children. + * + * This function first removes any children of the given DOM + * `Node` and then adds the given given children following the + * rules outlined below. + * + * @instance + * @memberof LuCI.dom + * @param {*} node + * The `Node` argument to replace the children of. + * + * @param {*} [children] + * The childrens to replace into the given node. + * + * When `children` is an array, then each item of the array + * will be either appended as child element or text node, + * depending on whether the item is a DOM `Node` instance or + * some other non-`null` value. Non-`Node`, non-`null` values + * will be converted to strings first before being passed as + * argument to `createTextNode()`. + * + * When `children` is a function, it will be invoked with + * the passed `node` argument as sole parameter and the `append` + * function will be invoked again, with the given `node` argument + * as first and the return value of the `children` function as + * second parameter. + * + * When `children` is is a DOM `Node` instance, it will be + * appended to the given `node`. + * + * When `children` is any other non-`null` value, it will be + * converted to a string and appened to the `innerHTML` property + * of the given `node`. + * + * @returns {Node|null} + * Returns the last children `Node` appended to the node or `null` + * if either the `node` argument was no valid DOM `node` or if the + * `children` was `null` or didn't result in further DOM nodes. + */ + content: function(node, children) { + if (!this.elem(node)) + return null; - if (stack.length) - e.message += '\n' + stack.join('\n'); + var dataNodes = node.querySelectorAll('[data-idref]'); - if (window.console && console.debug) - console.debug(e); + for (var i = 0; i < dataNodes.length; i++) + delete this.registry[dataNodes[i].getAttribute('data-idref')]; - throw e; + while (node.firstChild) + node.removeChild(node.firstChild); + + return this.append(node, children); }, /** - * A wrapper around {@link LuCI#raise raise()} which also renders - * the error either as modal overlay when `ui.js` is already loaed - * or directly into the view body. + * Sets attributes or registers event listeners on element nodes. * * @instance - * @memberof LuCI + * @memberof LuCI.dom + * @param {*} node + * The `Node` argument to set the attributes or add the event + * listeners for. When the given `node` value is not a valid + * DOM `Node`, the function returns and does nothing. + * + * @param {string|Object<string, *>} key + * Specifies either the attribute or event handler name to use, + * or an object containing multiple key, value pairs which are + * each added to the node as either attribute or event handler, + * depending on the respective value. * - * @param {Error|string} [type=Error] - * Either a string specifying the type of the error to throw or an - * existing `Error` instance to copy. + * @param {*} [val] + * Specifies the attribute value or event handler function to add. + * If the `key` parameter is an `Object`, this parameter will be + * ignored. * - * @param {string} [fmt=Unspecified error] - * A format string which is used to form the error message, together - * with all subsequent optional arguments. + * When `val` is of type function, it will be registered as event + * handler on the given `node` with the `key` parameter being the + * event name. * - * @param {...*} [args] - * Zero or more variable arguments to the supplied format string. + * When `val` is of type object, it will be serialized as JSON and + * added as attribute to the given `node`, using the given `key` + * as attribute name. * - * @throws {Error} - * Throws the created error object with the captured stack trace - * appended to the message and the type set to the given type - * argument or copied from the given error instance. + * When `val` is of any other type, it will be added as attribute + * to the given `node` as-is, with the underlying `setAttribute()` + * call implicitely turning it into a string. */ - error: function(type, fmt /*, ...*/) { - try { - L.raise.apply(L, Array.prototype.slice.call(arguments)); - } - catch (e) { - if (!e.reported) { - if (L.ui) - L.ui.addNotification(e.name || _('Runtime error'), - E('pre', {}, e.message), 'danger'); - else - L.dom.content(document.querySelector('#maincontent'), - E('pre', { 'class': 'alert-message error' }, e.message)); + attr: function(node, key, val) { + if (!this.elem(node)) + return null; - e.reported = true; - } + var attr = null; - throw e; + if (typeof(key) === 'object' && key !== null) + attr = key; + else if (typeof(key) === 'string') + attr = {}, attr[key] = val; + + for (key in attr) { + if (!attr.hasOwnProperty(key) || attr[key] == null) + continue; + + switch (typeof(attr[key])) { + case 'function': + node.addEventListener(key, attr[key]); + break; + + case 'object': + node.setAttribute(key, JSON.stringify(attr[key])); + break; + + default: + node.setAttribute(key, attr[key]); + } } }, /** - * Return a bound function using the given `self` as `this` context - * and any further arguments as parameters to the bound function. + * Creates a new DOM `Node` from the given `html`, `attr` and + * `data` parameters. + * + * This function has multiple signatures, it can be either invoked + * in the form `create(html[, attr[, data]])` or in the form + * `create(html[, data])`. The used variant is determined from the + * type of the second argument. * * @instance - * @memberof LuCI + * @memberof LuCI.dom + * @param {*} html + * Describes the node to create. * - * @param {function} fn - * The function to bind. + * When the value of `html` is of type array, a `DocumentFragment` + * node is created and each item of the array is first converted + * to a DOM `Node` by passing it through `create()` and then added + * as child to the fragment. * - * @param {*} self - * The value to bind as `this` context to the specified function. + * When the value of `html` is a DOM `Node` instance, no new + * element will be created but the node will be used as-is. * - * @param {...*} [args] - * Zero or more variable arguments which are bound to the function - * as parameters. + * When the value of `html` is a string starting with `<`, it will + * be passed to `dom.parse()` and the resulting value is used. * - * @returns {function} - * Returns the bound function. + * When the value of `html` is any other string, it will be passed + * to `document.createElement()` for creating a new DOM `Node` of + * the given name. + * + * @param {Object<string, *>} [attr] + * Specifies an Object of key, value pairs to set as attributes + * or event handlers on the created node. Refer to + * {@link LuCI.dom#attr dom.attr()} for details. + * + * @param {*} [data] + * Specifies children to append to the newly created element. + * Refer to {@link LuCI.dom#append dom.append()} for details. + * + * @throws {InvalidCharacterError} + * Throws an `InvalidCharacterError` when the given `html` + * argument contained malformed markup (such as not escaped + * `&` characters in XHTML mode) or when the given node name + * in `html` contains characters which are not legal in DOM + * element names, such as spaces. + * + * @returns {Node} + * Returns the newly created `Node`. */ - bind: function(fn, self /*, ... */) { - return Function.prototype.bind.apply(fn, this.varargs(arguments, 2, self)); + create: function() { + var html = arguments[0], + attr = arguments[1], + data = arguments[2], + elem; + + if (!(attr instanceof Object) || Array.isArray(attr)) + data = attr, attr = null; + + if (Array.isArray(html)) { + elem = document.createDocumentFragment(); + for (var i = 0; i < html.length; i++) + elem.appendChild(this.create(html[i])); + } + else if (this.elem(html)) { + elem = html; + } + else if (html.charCodeAt(0) === 60) { + elem = this.parse(html); + } + else { + elem = document.createElement(html); + } + + if (!elem) + return null; + + this.attr(elem, attr); + this.append(elem, data); + + return elem; }, + registry: {}, + /** - * Load an additional LuCI JavaScript class and its dependencies, - * instantiate it and return the resulting class instance. Each - * class is only loaded once. Subsequent attempts to load the same - * class will return the already instantiated class. + * Attaches or detaches arbitrary data to and from a DOM `Node`. + * + * This function is useful to attach non-string values or runtime + * data that is not serializable to DOM nodes. To decouple data + * from the DOM, values are not added directly to nodes, but + * inserted into a registry instead which is then referenced by a + * string key stored as `data-idref` attribute in the node. + * + * This function has multiple signatures and is sensitive to the + * number of arguments passed to it. + * + * - `dom.data(node)` - + * Fetches all data associated with the given node. + * - `dom.data(node, key)` - + * Fetches a specific key associated with the given node. + * - `dom.data(node, key, val)` - + * Sets a specific key to the given value associated with the + * given node. + * - `dom.data(node, null)` - + * Clears any data associated with the node. + * - `dom.data(node, key, null)` - + * Clears the given key associated with the node. * * @instance - * @memberof LuCI - * - * @param {string} name - * The name of the class to load in dotted notation. Dots will - * be replaced by spaces and joined with the runtime-determined - * base URL of LuCI.js to form an absolute URL to load the class - * file from. + * @memberof LuCI.dom + * @param {Node} node + * The DOM `Node` instance to set or retrieve the data for. * - * @throws {DependencyError} - * Throws a `DependencyError` when the class to load includes - * circular dependencies. - * - * @throws {NetworkError} - * Throws `NetworkError` when the underlying {@link LuCI.Request} - * call failed. - * - * @throws {SyntaxError} - * Throws `SyntaxError` when the loaded class file code cannot - * be interpreted by `eval`. + * @param {string|null} [key] + * This is either a string specifying the key to retrieve, or + * `null` to unset the entire node data. * - * @throws {TypeError} - * Throws `TypeError` when the class file could be loaded and - * interpreted, but when invoking its code did not yield a valid - * class instance. + * @param {*|null} [val] + * This is either a non-`null` value to set for a given key or + * `null` to remove the given `key` from the specified node. * - * @returns {Promise<LuCI#Class>} - * Returns the instantiated class. + * @returns {*} + * Returns the get or set value, or `null` when no value could + * be found. */ - require: function(name, from) { - var L = this, url = null, from = from || []; + data: function(node, key, val) { + if (!node || !node.getAttribute) + return null; - /* Class already loaded */ - if (classes[name] != null) { - /* Circular dependency */ - if (from.indexOf(name) != -1) - L.raise('DependencyError', - 'Circular dependency: class "%s" depends on "%s"', - name, from.join('" which depends on "')); - - return Promise.resolve(classes[name]); - } - - url = '%s/%s.js%s'.format(L.env.base_url, name.replace(/\./g, '/'), (L.env.resource_version ? '?v=' + L.env.resource_version : '')); - from = [ name ].concat(from); + var id = node.getAttribute('data-idref'); - var compileClass = function(res) { - if (!res.ok) - L.raise('NetworkError', - 'HTTP error %d while loading class file "%s"', res.status, url); + /* clear all data */ + if (arguments.length > 1 && key == null) { + if (id != null) { + node.removeAttribute('data-idref'); + val = this.registry[id] + delete this.registry[id]; + return val; + } - var source = res.text(), - requirematch = /^require[ \t]+(\S+)(?:[ \t]+as[ \t]+([a-zA-Z_]\S*))?$/, - strictmatch = /^use[ \t]+strict$/, - depends = [], - args = ''; + return null; + } - /* find require statements in source */ - for (var i = 0, off = -1, quote = -1, esc = false; i < source.length; i++) { - var chr = source.charCodeAt(i); + /* clear a key */ + else if (arguments.length > 2 && key != null && val == null) { + if (id != null) { + val = this.registry[id][key]; + delete this.registry[id][key]; + return val; + } - if (esc) { - esc = false; - } - else if (chr == 92) { - esc = true; - } - else if (chr == quote) { - var s = source.substring(off, i), - m = requirematch.exec(s); + return null; + } - if (m) { - var dep = m[1], as = m[2] || dep.replace(/[^a-zA-Z0-9_]/g, '_'); - depends.push(L.require(dep, from)); - args += ', ' + as; - } - else if (!strictmatch.exec(s)) { - break; - } + /* set a key */ + else if (arguments.length > 2 && key != null && val != null) { + if (id == null) { + do { id = Math.floor(Math.random() * 0xffffffff).toString(16) } + while (this.registry.hasOwnProperty(id)); - off = -1; - quote = -1; - } - else if (quote == -1 && (chr == 34 || chr == 39)) { - off = i + 1; - quote = chr; - } + node.setAttribute('data-idref', id); + this.registry[id] = {}; } - /* load dependencies and instantiate class */ - return Promise.all(depends).then(function(instances) { - var _factory, _class; + return (this.registry[id][key] = val); + } - try { - _factory = eval( - '(function(window, document, L%s) { %s })\n\n//# sourceURL=%s\n' - .format(args, source, res.url)); - } - catch (error) { - L.raise('SyntaxError', '%s\n in %s:%s', - error.message, res.url, error.lineNumber || '?'); - } + /* get all data */ + else if (arguments.length == 1) { + if (id != null) + return this.registry[id]; - _factory.displayName = toCamelCase(name + 'ClassFactory'); - _class = _factory.apply(_factory, [window, document, L].concat(instances)); + return null; + } - if (!Class.isSubclass(_class)) - L.error('TypeError', '"%s" factory yields invalid constructor', name); + /* get a key */ + else if (arguments.length == 2) { + if (id != null) + return this.registry[id][key]; + } - if (_class.displayName == 'AnonymousClass') - _class.displayName = toCamelCase(name + 'Class'); + return null; + }, - var ptr = Object.getPrototypeOf(L), - parts = name.split(/\./), - instance = new _class(); + /** + * Binds the given class instance ot the specified DOM `Node`. + * + * This function uses the `dom.data()` facility to attach the + * passed instance of a Class to a node. This is needed for + * complex widget elements or similar where the corresponding + * class instance responsible for the element must be retrieved + * from DOM nodes obtained by `querySelector()` or similar means. + * + * @instance + * @memberof LuCI.dom + * @param {Node} node + * The DOM `Node` instance to bind the class to. + * + * @param {Class} inst + * The Class instance to bind to the node. + * + * @throws {TypeError} + * Throws a `TypeError` when the given instance argument isn't + * a valid Class instance. + * + * @returns {Class} + * Returns the bound class instance. + */ + bindClassInstance: function(node, inst) { + if (!(inst instanceof Class)) + L.error('TypeError', 'Argument must be a class instance'); - for (var i = 0; ptr && i < parts.length - 1; i++) - ptr = ptr[parts[i]]; + return this.data(node, '_class', inst); + }, - if (ptr) - ptr[parts[i]] = instance; + /** + * Finds a bound class instance on the given node itself or the + * first bound instance on its closest parent node. + * + * @instance + * @memberof LuCI.dom + * @param {Node} node + * The DOM `Node` instance to start from. + * + * @returns {Class|null} + * Returns the founds class instance if any or `null` if no bound + * class could be found on the node itself or any of its parents. + */ + findClassInstance: function(node) { + var inst = null; - classes[name] = instance; + do { + inst = this.data(node, '_class'); + node = node.parentNode; + } + while (!(inst instanceof Class) && node != null); - return instance; - }); - }; + return inst; + }, - /* Request class file */ - classes[name] = Request.get(url, { cache: true }).then(compileClass); + /** + * Finds a bound class instance on the given node itself or the + * first bound instance on its closest parent node and invokes + * the specified method name on the found class instance. + * + * @instance + * @memberof LuCI.dom + * @param {Node} node + * The DOM `Node` instance to start from. + * + * @param {string} method + * The name of the method to invoke on the found class instance. + * + * @param {...*} params + * Additional arguments to pass to the invoked method as-is. + * + * @returns {*|null} + * Returns the return value of the invoked method if a class + * instance and method has been found. Returns `null` if either + * no bound class instance could be found, or if the found + * instance didn't have the requested `method`. + */ + callClassMethod: function(node, method /*, ... */) { + var inst = this.findClassInstance(node); - return classes[name]; + if (inst == null || typeof(inst[method]) != 'function') + return null; + + return inst[method].apply(inst, inst.varargs(arguments, 2)); }, - /* DOM setup */ - probeRPCBaseURL: function() { - if (rpcBaseURL == null) { - try { - rpcBaseURL = window.sessionStorage.getItem('rpcBaseURL'); - } - catch (e) { } - } + /** + * The ignore callback function is invoked by `isEmpty()` for each + * child node to decide whether to ignore a child node or not. + * + * When this function returns `false`, the node passed to it is + * ignored, else not. + * + * @callback LuCI.dom~ignoreCallbackFn + * @param {Node} node + * The child node to test. + * + * @returns {boolean} + * Boolean indicating whether to ignore the node or not. + */ - if (rpcBaseURL == null) { - var rpcFallbackURL = this.url('admin/ubus'); + /** + * Tests whether a given DOM `Node` instance is empty or appears + * empty. + * + * Any element child nodes which have the CSS class `hidden` set + * or for which the optionally passed `ignoreFn` callback function + * returns `false` are ignored. + * + * @instance + * @memberof LuCI.dom + * @param {Node} node + * The DOM `Node` instance to test. + * + * @param {LuCI.dom~ignoreCallbackFn} [ignoreFn] + * Specifies an optional function which is invoked for each child + * node to decide whether the child node should be ignored or not. + * + * @returns {boolean} + * Returns `true` if the node does not have any children or if + * any children node either has a `hidden` CSS class or a `false` + * result when testing it using the given `ignoreFn`. + */ + isEmpty: function(node, ignoreFn) { + for (var child = node.firstElementChild; child != null; child = child.nextElementSibling) + if (!child.classList.contains('hidden') && (!ignoreFn || !ignoreFn(child))) + return false; - rpcBaseURL = Request.get(this.env.ubuspath).then(function(res) { - return (rpcBaseURL = (res.status == 400) ? L.env.ubuspath : rpcFallbackURL); - }, function() { - return (rpcBaseURL = rpcFallbackURL); - }).then(function(url) { - try { - window.sessionStorage.setItem('rpcBaseURL', url); - } - catch (e) { } + return true; + } + }); - return url; - }); - } + /** + * @class view + * @memberof LuCI + * @hideconstructor + * @classdesc + * + * The `view` class forms the basis of views and provides a standard + * set of methods to inherit from. + */ + var View = Class.extend(/* @lends LuCI.view.prototype */ { + __name__: 'LuCI.View', - return Promise.resolve(rpcBaseURL); - }, + __init__: function() { + var vp = document.getElementById('view'); - probeSystemFeatures: function() { - var sessionid = classes.rpc.getSessionID(); + DOM.content(vp, E('div', { 'class': 'spinning' }, _('Loading view…'))); - if (sysFeatures == null) { - try { - var data = JSON.parse(window.sessionStorage.getItem('sysFeatures')); + return Promise.resolve(this.load()) + .then(L.bind(this.render, this)) + .then(L.bind(function(nodes) { + var vp = document.getElementById('view'); - if (this.isObject(data) && this.isObject(data[sessionid])) - sysFeatures = data[sessionid]; - } - catch (e) {} - } + DOM.content(vp, nodes); + DOM.append(vp, this.addFooter()); + }, this)).catch(L.error); + }, - if (!this.isObject(sysFeatures)) { - sysFeatures = classes.rpc.declare({ - object: 'luci', - method: 'getFeatures', - expect: { '': {} } - })().then(function(features) { - try { - var data = {}; - data[sessionid] = features; + /** + * The load function is invoked before the view is rendered. + * + * The invocation of this function is wrapped by + * `Promise.resolve()` so it may return Promises if needed. + * + * The return value of the function (or the resolved values + * of the promise returned by it) will be passed as first + * argument to `render()`. + * + * This function is supposed to be overwritten by subclasses, + * the default implementation does nothing. + * + * @instance + * @abstract + * @memberof LuCI.view + * + * @returns {*|Promise<*>} + * May return any value or a Promise resolving to any value. + */ + load: function() {}, - window.sessionStorage.setItem('sysFeatures', JSON.stringify(data)); - } - catch (e) {} + /** + * The render function is invoked after the + * {@link LuCI.view#load load()} function and responsible + * for setting up the view contents. It must return a DOM + * `Node` or `DocumentFragment` holding the contents to + * insert into the view area. + * + * The invocation of this function is wrapped by + * `Promise.resolve()` so it may return Promises if needed. + * + * The return value of the function (or the resolved values + * of the promise returned by it) will be inserted into the + * main content area using + * {@link LuCI.dom#append dom.append()}. + * + * This function is supposed to be overwritten by subclasses, + * the default implementation does nothing. + * + * @instance + * @abstract + * @memberof LuCI.view + * @param {*|null} load_results + * This function will receive the return value of the + * {@link LuCI.view#load view.load()} function as first + * argument. + * + * @returns {Node|Promise<Node>} + * Should return a DOM `Node` value or a `Promise` resolving + * to a `Node` value. + */ + render: function() {}, - sysFeatures = features; + /** + * The handleSave function is invoked when the user clicks + * the `Save` button in the page action footer. + * + * The default implementation should be sufficient for most + * views using {@link form#Map form.Map()} based forms - it + * will iterate all forms present in the view and invoke + * the {@link form#Map#save Map.save()} method on each form. + * + * Views not using `Map` instances or requiring other special + * logic should overwrite `handleSave()` with a custom + * implementation. + * + * To disable the `Save` page footer button, views extending + * this base class should overwrite the `handleSave` function + * with `null`. + * + * The invocation of this function is wrapped by + * `Promise.resolve()` so it may return Promises if needed. + * + * @instance + * @memberof LuCI.view + * @param {Event} ev + * The DOM event that triggered the function. + * + * @returns {*|Promise<*>} + * Any return values of this function are discarded, but + * passed through `Promise.resolve()` to ensure that any + * returned promise runs to completion before the button + * is reenabled. + */ + handleSave: function(ev) { + var tasks = []; - return features; + document.getElementById('maincontent') + .querySelectorAll('.cbi-map').forEach(function(map) { + tasks.push(DOM.callClassMethod(map, 'save')); }); - } - return Promise.resolve(sysFeatures); + return Promise.all(tasks); }, /** - * Test whether a particular system feature is available, such as - * hostapd SAE support or an installed firewall. The features are - * queried once at the beginning of the LuCI session and cached in - * `SessionStorage` throughout the lifetime of the associated tab or - * browser window. + * The handleSaveApply function is invoked when the user clicks + * the `Save & Apply` button in the page action footer. + * + * The default implementation should be sufficient for most + * views using {@link form#Map form.Map()} based forms - it + * will first invoke + * {@link LuCI.view.handleSave view.handleSave()} and then + * call {@link ui#changes#apply ui.changes.apply()} to start the + * modal config apply and page reload flow. + * + * Views not using `Map` instances or requiring other special + * logic should overwrite `handleSaveApply()` with a custom + * implementation. + * + * To disable the `Save & Apply` page footer button, views + * extending this base class should overwrite the + * `handleSaveApply` function with `null`. + * + * The invocation of this function is wrapped by + * `Promise.resolve()` so it may return Promises if needed. * * @instance - * @memberof LuCI + * @memberof LuCI.view + * @param {Event} ev + * The DOM event that triggered the function. + * + * @returns {*|Promise<*>} + * Any return values of this function are discarded, but + * passed through `Promise.resolve()` to ensure that any + * returned promise runs to completion before the button + * is reenabled. + */ + handleSaveApply: function(ev, mode) { + return this.handleSave(ev).then(function() { + L.ui.changes.apply(mode == '0'); + }); + }, + + /** + * The handleReset function is invoked when the user clicks + * the `Reset` button in the page action footer. * - * @param {string} feature - * The feature to test. For detailed list of known feature flags, - * see `/modules/luci-base/root/usr/libexec/rpcd/luci`. + * The default implementation should be sufficient for most + * views using {@link form#Map form.Map()} based forms - it + * will iterate all forms present in the view and invoke + * the {@link form#Map#save Map.reset()} method on each form. * - * @param {string} [subfeature] - * Some feature classes like `hostapd` provide sub-feature flags, - * such as `sae` or `11w` support. The `subfeature` argument can - * be used to query these. + * Views not using `Map` instances or requiring other special + * logic should overwrite `handleReset()` with a custom + * implementation. * - * @return {boolean|null} - * Return `true` if the queried feature (and sub-feature) is available - * or `false` if the requested feature isn't present or known. - * Return `null` when a sub-feature was queried for a feature which - * has no sub-features. + * To disable the `Reset` page footer button, views extending + * this base class should overwrite the `handleReset` function + * with `null`. + * + * The invocation of this function is wrapped by + * `Promise.resolve()` so it may return Promises if needed. + * + * @instance + * @memberof LuCI.view + * @param {Event} ev + * The DOM event that triggered the function. + * + * @returns {*|Promise<*>} + * Any return values of this function are discarded, but + * passed through `Promise.resolve()` to ensure that any + * returned promise runs to completion before the button + * is reenabled. */ - hasSystemFeature: function() { - var ft = sysFeatures[arguments[0]]; + handleReset: function(ev) { + var tasks = []; - if (arguments.length == 2) - return this.isObject(ft) ? ft[arguments[1]] : null; + document.getElementById('maincontent') + .querySelectorAll('.cbi-map').forEach(function(map) { + tasks.push(DOM.callClassMethod(map, 'reset')); + }); - return (ft != null && ft != false); + return Promise.all(tasks); }, - /* private */ - notifySessionExpiry: function() { - Poll.stop(); - - L.ui.showModal(_('Session expired'), [ - E('div', { class: 'alert-message warning' }, - _('A new login is required since the authentication session expired.')), - E('div', { class: 'right' }, - E('div', { - class: 'btn primary', - click: function() { - var loc = window.location; - window.location = loc.protocol + '//' + loc.host + loc.pathname + loc.search; - } - }, _('To login…'))) - ]); - - L.raise('SessionError', 'Login session is expired'); - }, + /** + * Renders a standard page action footer if any of the + * `handleSave()`, `handleSaveApply()` or `handleReset()` + * functions are defined. + * + * The default implementation should be sufficient for most + * views - it will render a standard page footer with action + * buttons labeled `Save`, `Save & Apply` and `Reset` + * triggering the `handleSave()`, `handleSaveApply()` and + * `handleReset()` functions respectively. + * + * When any of these `handle*()` functions is overwritten + * with `null` by a view extending this class, the + * corresponding button will not be rendered. + * + * @instance + * @memberof LuCI.view + * @returns {DocumentFragment} + * Returns a `DocumentFragment` containing the footer bar + * with buttons for each corresponding `handle*()` action + * or an empty `DocumentFragment` if all three `handle*()` + * methods are overwritten with `null`. + */ + addFooter: function() { + var footer = E([]); + + var saveApplyBtn = this.handleSaveApply ? new L.ui.ComboButton('0', { + 0: [ _('Save & Apply') ], + 1: [ _('Apply unchecked') ] + }, { + classes: { + 0: 'btn cbi-button cbi-button-apply important', + 1: 'btn cbi-button cbi-button-negative important' + }, + click: L.ui.createHandlerFn(this, 'handleSaveApply') + }).render() : E([]); + + if (this.handleSaveApply || this.handleSave || this.handleReset) { + footer.appendChild(E('div', { 'class': 'cbi-page-actions control-group' }, [ + saveApplyBtn, ' ', + this.handleSave ? E('button', { + 'class': 'cbi-button cbi-button-save', + 'click': L.ui.createHandlerFn(this, 'handleSave') + }, [ _('Save') ]) : '', ' ', + this.handleReset ? E('button', { + 'class': 'cbi-button cbi-button-reset', + 'click': L.ui.createHandlerFn(this, 'handleReset') + }, [ _('Reset') ]) : '' + ])); + } - /* private */ - setupDOM: function(res) { - var domEv = res[0], - uiClass = res[1], - rpcClass = res[2], - formClass = res[3], - rpcBaseURL = res[4]; + return footer; + } + }); - rpcClass.setBaseURL(rpcBaseURL); - rpcClass.addInterceptor(function(msg, req) { - if (!L.isObject(msg) || !L.isObject(msg.error) || msg.error.code != -32002) - return; + var dummyElem = null, + domParser = null, + originalCBIInit = null, + rpcBaseURL = null, + sysFeatures = null; + + /* "preload" builtin classes to make the available via require */ + var classes = { + baseclass: Class, + dom: DOM, + poll: Poll, + request: Request, + view: View + }; - if (!L.isObject(req) || (req.object == 'session' && req.method == 'access')) - return; + var LuCI = Class.extend(/** @lends LuCI.prototype */ { + __name__: 'LuCI', + __init__: function(env) { - return rpcClass.declare({ - 'object': 'session', - 'method': 'access', - 'params': [ 'scope', 'object', 'function' ], - 'expect': { access: true } - })('uci', 'luci', 'read').catch(L.notifySessionExpiry); + document.querySelectorAll('script[src*="/luci.js"]').forEach(function(s) { + if (env.base_url == null || env.base_url == '') { + var m = (s.getAttribute('src') || '').match(/^(.*)\/luci\.js(?:\?v=([^?]+))?$/); + if (m) { + env.base_url = m[1]; + env.resource_version = m[2]; + } + } }); - Request.addInterceptor(function(res) { - var isDenied = false; + if (env.base_url == null) + this.error('InternalError', 'Cannot find url of luci.js'); - if (res.status == 403 && res.headers.get('X-LuCI-Login-Required') == 'yes') - isDenied = true; + env.cgi_base = env.scriptname.replace(/\/[^\/]+$/, ''); - if (!isDenied) - return; + Object.assign(this.env, env); - L.notifySessionExpiry(); + document.addEventListener('poll-start', function(ev) { + document.querySelectorAll('[id^="xhr_poll_status"]').forEach(function(e) { + e.style.display = (e.id == 'xhr_poll_status_off') ? 'none' : ''; + }); }); - return this.probeSystemFeatures().finally(this.initDOM); - }, + document.addEventListener('poll-stop', function(ev) { + document.querySelectorAll('[id^="xhr_poll_status"]').forEach(function(e) { + e.style.display = (e.id == 'xhr_poll_status_on') ? 'none' : ''; + }); + }); - /* private */ - initDOM: function() { - originalCBIInit(); - Poll.start(); - document.dispatchEvent(new CustomEvent('luci-loaded')); + var domReady = new Promise(function(resolveFn, rejectFn) { + document.addEventListener('DOMContentLoaded', resolveFn); + }); + + Promise.all([ + domReady, + this.require('ui'), + this.require('rpc'), + this.require('form'), + this.probeRPCBaseURL() + ]).then(this.setupDOM.bind(this)).catch(this.error); + + originalCBIInit = window.cbi_init; + window.cbi_init = function() {}; }, /** - * The `env` object holds environment settings used by LuCI, such - * as request timeouts, base URLs etc. + * Captures the current stack trace and throws an error of the + * specified type as a new exception. Also logs the exception as + * error to the debug console if it is available. * * @instance * @memberof LuCI - */ - env: {}, - - /** - * Construct a relative URL path from the given prefix and parts. - * The resulting URL is guaranteed to only contain the characters - * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well - * as `/` for the path separator. * - * @instance - * @memberof LuCI + * @param {Error|string} [type=Error] + * Either a string specifying the type of the error to throw or an + * existing `Error` instance to copy. * - * @param {string} [prefix] - * The prefix to join the given parts with. If the `prefix` is - * omitted, it defaults to an empty string. + * @param {string} [fmt=Unspecified error] + * A format string which is used to form the error message, together + * with all subsequent optional arguments. * - * @param {string[]} [parts] - * An array of parts to join into an URL path. Parts may contain - * slashes and any of the other characters mentioned above. + * @param {...*} [args] + * Zero or more variable arguments to the supplied format string. * - * @return {string} - * Return the joined URL path. + * @throws {Error} + * Throws the created error object with the captured stack trace + * appended to the message and the type set to the given type + * argument or copied from the given error instance. */ - path: function(prefix, parts) { - var url = [ prefix || '' ]; + raise: function(type, fmt /*, ...*/) { + var e = null, + msg = fmt ? String.prototype.format.apply(fmt, this.varargs(arguments, 2)) : null, + stack = null; - for (var i = 0; i < parts.length; i++) - if (/^(?:[a-zA-Z0-9_.%,;-]+\/)*[a-zA-Z0-9_.%,;-]+$/.test(parts[i])) - url.push('/', parts[i]); + if (type instanceof Error) { + e = type; - if (url.length === 1) - url.push('/'); + if (msg) + e.message = msg + ': ' + e.message; + } + else { + try { throw new Error('stacktrace') } + catch (e2) { stack = (e2.stack || '').split(/\n/) } - return url.join(''); + e = new (window[type || 'Error'] || Error)(msg || 'Unspecified error'); + e.name = type || 'Error'; + } + + stack = (stack || []).map(function(frame) { + frame = frame.replace(/(.*?)@(.+):(\d+):(\d+)/g, 'at $1 ($2:$3:$4)').trim(); + return frame ? ' ' + frame : ''; + }); + + if (!/^ at /.test(stack[0])) + stack.shift(); + + if (/\braise /.test(stack[0])) + stack.shift(); + + if (/\berror /.test(stack[0])) + stack.shift(); + + if (stack.length) + e.message += '\n' + stack.join('\n'); + + if (window.console && console.debug) + console.debug(e); + + throw e; }, /** - * Construct an URL pathrelative to the script path of the server - * side LuCI application (usually `/cgi-bin/luci`). - * - * The resulting URL is guaranteed to only contain the characters - * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well - * as `/` for the path separator. + * A wrapper around {@link LuCI#raise raise()} which also renders + * the error either as modal overlay when `ui.js` is already loaed + * or directly into the view body. * * @instance * @memberof LuCI * - * @param {string[]} [parts] - * An array of parts to join into an URL path. Parts may contain - * slashes and any of the other characters mentioned above. + * @param {Error|string} [type=Error] + * Either a string specifying the type of the error to throw or an + * existing `Error` instance to copy. * - * @return {string} - * Returns the resulting URL path. + * @param {string} [fmt=Unspecified error] + * A format string which is used to form the error message, together + * with all subsequent optional arguments. + * + * @param {...*} [args] + * Zero or more variable arguments to the supplied format string. + * + * @throws {Error} + * Throws the created error object with the captured stack trace + * appended to the message and the type set to the given type + * argument or copied from the given error instance. */ - url: function() { - return this.path(this.env.scriptname, arguments); + error: function(type, fmt /*, ...*/) { + try { + L.raise.apply(L, Array.prototype.slice.call(arguments)); + } + catch (e) { + if (!e.reported) { + if (L.ui) + L.ui.addNotification(e.name || _('Runtime error'), + E('pre', {}, e.message), 'danger'); + else + DOM.content(document.querySelector('#maincontent'), + E('pre', { 'class': 'alert-message error' }, e.message)); + + e.reported = true; + } + + throw e; + } }, /** - * Construct an URL path relative to the global static resource path - * of the LuCI ui (usually `/luci-static/resources`). - * - * The resulting URL is guaranteed to only contain the characters - * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well - * as `/` for the path separator. + * Return a bound function using the given `self` as `this` context + * and any further arguments as parameters to the bound function. * * @instance * @memberof LuCI * - * @param {string[]} [parts] - * An array of parts to join into an URL path. Parts may contain - * slashes and any of the other characters mentioned above. + * @param {function} fn + * The function to bind. * - * @return {string} - * Returns the resulting URL path. + * @param {*} self + * The value to bind as `this` context to the specified function. + * + * @param {...*} [args] + * Zero or more variable arguments which are bound to the function + * as parameters. + * + * @returns {function} + * Returns the bound function. */ - resource: function() { - return this.path(this.env.resource, arguments); + bind: function(fn, self /*, ... */) { + return Function.prototype.bind.apply(fn, this.varargs(arguments, 2, self)); }, /** - * Construct an URL path relative to the media resource path of the - * LuCI ui (usually `/luci-static/$theme_name`). - * - * The resulting URL is guaranteed to only contain the characters - * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well - * as `/` for the path separator. + * Load an additional LuCI JavaScript class and its dependencies, + * instantiate it and return the resulting class instance. Each + * class is only loaded once. Subsequent attempts to load the same + * class will return the already instantiated class. * * @instance * @memberof LuCI * - * @param {string[]} [parts] - * An array of parts to join into an URL path. Parts may contain - * slashes and any of the other characters mentioned above. - * - * @return {string} - * Returns the resulting URL path. - */ - media: function() { - return this.path(this.env.media, arguments); - }, - - /** - * Return the complete URL path to the current view. + * @param {string} name + * The name of the class to load in dotted notation. Dots will + * be replaced by spaces and joined with the runtime-determined + * base URL of LuCI.js to form an absolute URL to load the class + * file from. * - * @instance - * @memberof LuCI + * @throws {DependencyError} + * Throws a `DependencyError` when the class to load includes + * circular dependencies. * - * @return {string} - * Returns the URL path to the current view. - */ - location: function() { - return this.path(this.env.scriptname, this.env.requestpath); - }, - - - /** - * Tests whether the passed argument is a JavaScript object. - * This function is meant to be an object counterpart to the - * standard `Array.isArray()` function. + * @throws {NetworkError} + * Throws `NetworkError` when the underlying {@link LuCI.request} + * call failed. * - * @instance - * @memberof LuCI + * @throws {SyntaxError} + * Throws `SyntaxError` when the loaded class file code cannot + * be interpreted by `eval`. * - * @param {*} [val] - * The value to test + * @throws {TypeError} + * Throws `TypeError` when the class file could be loaded and + * interpreted, but when invoking its code did not yield a valid + * class instance. * - * @return {boolean} - * Returns `true` if the given value is of type object and - * not `null`, else returns `false`. + * @returns {Promise<LuCI.baseclass>} + * Returns the instantiated class. */ - isObject: function(val) { - return (val != null && typeof(val) == 'object'); - }, + require: function(name, from) { + var L = this, url = null, from = from || []; - /** - * Return an array of sorted object keys, optionally sorted by - * a different key or a different sorting mode. - * - * @instance - * @memberof LuCI - * - * @param {object} obj - * The object to extract the keys from. If the given value is - * not an object, the function will return an empty array. - * - * @param {string} [key] - * Specifies the key to order by. This is mainly useful for - * nested objects of objects or objects of arrays when sorting - * shall not be performed by the primary object keys but by - * some other key pointing to a value within the nested values. - * - * @param {string} [sortmode] - * May be either `addr` or `num` to override the natural - * lexicographic sorting with a sorting suitable for IP/MAC style - * addresses or numeric values respectively. - * - * @return {string[]} - * Returns an array containing the sorted keys of the given object. - */ - sortedKeys: function(obj, key, sortmode) { - if (obj == null || typeof(obj) != 'object') - return []; + /* Class already loaded */ + if (classes[name] != null) { + /* Circular dependency */ + if (from.indexOf(name) != -1) + L.raise('DependencyError', + 'Circular dependency: class "%s" depends on "%s"', + name, from.join('" which depends on "')); - return Object.keys(obj).map(function(e) { - var v = (key != null) ? obj[e][key] : e; + return Promise.resolve(classes[name]); + } - switch (sortmode) { - case 'addr': - v = (v != null) ? v.replace(/(?:^|[.:])([0-9a-fA-F]{1,4})/g, - function(m0, m1) { return ('000' + m1.toLowerCase()).substr(-4) }) : null; - break; + url = '%s/%s.js%s'.format(L.env.base_url, name.replace(/\./g, '/'), (L.env.resource_version ? '?v=' + L.env.resource_version : '')); + from = [ name ].concat(from); - case 'num': - v = (v != null) ? +v : null; - break; + var compileClass = function(res) { + if (!res.ok) + L.raise('NetworkError', + 'HTTP error %d while loading class file "%s"', res.status, url); + + var source = res.text(), + requirematch = /^require[ \t]+(\S+)(?:[ \t]+as[ \t]+([a-zA-Z_]\S*))?$/, + strictmatch = /^use[ \t]+strict$/, + depends = [], + args = ''; + + /* find require statements in source */ + for (var i = 0, off = -1, quote = -1, esc = false; i < source.length; i++) { + var chr = source.charCodeAt(i); + + if (esc) { + esc = false; + } + else if (chr == 92) { + esc = true; + } + else if (chr == quote) { + var s = source.substring(off, i), + m = requirematch.exec(s); + + if (m) { + var dep = m[1], as = m[2] || dep.replace(/[^a-zA-Z0-9_]/g, '_'); + depends.push(L.require(dep, from)); + args += ', ' + as; + } + else if (!strictmatch.exec(s)) { + break; + } + + off = -1; + quote = -1; + } + else if (quote == -1 && (chr == 34 || chr == 39)) { + off = i + 1; + quote = chr; + } } - return [ e, v ]; - }).filter(function(e) { - return (e[1] != null); - }).sort(function(a, b) { - return (a[1] > b[1]); - }).map(function(e) { - return e[0]; - }); - }, + /* load dependencies and instantiate class */ + return Promise.all(depends).then(function(instances) { + var _factory, _class; - /** - * Converts the given value to an array. If the given value is of - * type array, it is returned as-is, values of type object are - * returned as one-element array containing the object, empty - * strings and `null` values are returned as empty array, all other - * values are converted using `String()`, trimmed, split on white - * space and returned as array. - * - * @instance - * @memberof LuCI - * - * @param {*} val - * The value to convert into an array. - * - * @return {Array<*>} - * Returns the resulting array. - */ - toArray: function(val) { - if (val == null) - return []; - else if (Array.isArray(val)) - return val; - else if (typeof(val) == 'object') - return [ val ]; + try { + _factory = eval( + '(function(window, document, L%s) { %s })\n\n//# sourceURL=%s\n' + .format(args, source, res.url)); + } + catch (error) { + L.raise('SyntaxError', '%s\n in %s:%s', + error.message, res.url, error.lineNumber || '?'); + } - var s = String(val).trim(); + _factory.displayName = toCamelCase(name + 'ClassFactory'); + _class = _factory.apply(_factory, [window, document, L].concat(instances)); - if (s == '') - return []; + if (!Class.isSubclass(_class)) + L.error('TypeError', '"%s" factory yields invalid constructor', name); - return s.split(/\s+/); - }, + if (_class.displayName == 'AnonymousClass') + _class.displayName = toCamelCase(name + 'Class'); - /** - * Returns a promise resolving with either the given value or or with - * the given default in case the input value is a rejecting promise. - * - * @instance - * @memberof LuCI - * - * @param {*} value - * The value to resolve the promise with. - * - * @param {*} defvalue - * The default value to resolve the promise with in case the given - * input value is a rejecting promise. - * - * @returns {Promise<*>} - * Returns a new promise resolving either to the given input value or - * to the given default value on error. - */ - resolveDefault: function(value, defvalue) { - return Promise.resolve(value).catch(function() { return defvalue }); - }, + var ptr = Object.getPrototypeOf(L), + parts = name.split(/\./), + instance = new _class(); - /** - * The request callback function is invoked whenever an HTTP - * reply to a request made using the `L.get()`, `L.post()` or - * `L.poll()` function is timed out or received successfully. - * - * @instance - * @memberof LuCI - * - * @callback LuCI.requestCallbackFn - * @param {XMLHTTPRequest} xhr - * The XMLHTTPRequest instance used to make the request. - * - * @param {*} data - * The response JSON if the response could be parsed as such, - * else `null`. - * - * @param {number} duration - * The total duration of the request in milliseconds. - */ + for (var i = 0; ptr && i < parts.length - 1; i++) + ptr = ptr[parts[i]]; - /** - * Issues a GET request to the given url and invokes the specified - * callback function. The function is a wrapper around - * {@link LuCI.Request#request Request.request()}. + if (ptr) + ptr[parts[i]] = instance; + + classes[name] = instance; + + return instance; + }); + }; + + /* Request class file */ + classes[name] = Request.get(url, { cache: true }).then(compileClass); + + return classes[name]; + }, + + /* DOM setup */ + probeRPCBaseURL: function() { + if (rpcBaseURL == null) { + try { + rpcBaseURL = window.sessionStorage.getItem('rpcBaseURL'); + } + catch (e) { } + } + + if (rpcBaseURL == null) { + var rpcFallbackURL = this.url('admin/ubus'); + + rpcBaseURL = Request.get(this.env.ubuspath).then(function(res) { + return (rpcBaseURL = (res.status == 400) ? L.env.ubuspath : rpcFallbackURL); + }, function() { + return (rpcBaseURL = rpcFallbackURL); + }).then(function(url) { + try { + window.sessionStorage.setItem('rpcBaseURL', url); + } + catch (e) { } + + return url; + }); + } + + return Promise.resolve(rpcBaseURL); + }, + + probeSystemFeatures: function() { + var sessionid = classes.rpc.getSessionID(); + + if (sysFeatures == null) { + try { + var data = JSON.parse(window.sessionStorage.getItem('sysFeatures')); + + if (this.isObject(data) && this.isObject(data[sessionid])) + sysFeatures = data[sessionid]; + } + catch (e) {} + } + + if (!this.isObject(sysFeatures)) { + sysFeatures = classes.rpc.declare({ + object: 'luci', + method: 'getFeatures', + expect: { '': {} } + })().then(function(features) { + try { + var data = {}; + data[sessionid] = features; + + window.sessionStorage.setItem('sysFeatures', JSON.stringify(data)); + } + catch (e) {} + + sysFeatures = features; + + return features; + }); + } + + return Promise.resolve(sysFeatures); + }, + + /** + * Test whether a particular system feature is available, such as + * hostapd SAE support or an installed firewall. The features are + * queried once at the beginning of the LuCI session and cached in + * `SessionStorage` throughout the lifetime of the associated tab or + * browser window. * - * @deprecated * @instance * @memberof LuCI * - * @param {string} url - * The URL to request. - * - * @param {Object<string, string>} [args] - * Additional query string arguments to append to the URL. + * @param {string} feature + * The feature to test. For detailed list of known feature flags, + * see `/modules/luci-base/root/usr/libexec/rpcd/luci`. * - * @param {LuCI.requestCallbackFn} cb - * The callback function to invoke when the request finishes. + * @param {string} [subfeature] + * Some feature classes like `hostapd` provide sub-feature flags, + * such as `sae` or `11w` support. The `subfeature` argument can + * be used to query these. * - * @return {Promise<null>} - * Returns a promise resolving to `null` when concluded. + * @return {boolean|null} + * Return `true` if the queried feature (and sub-feature) is available + * or `false` if the requested feature isn't present or known. + * Return `null` when a sub-feature was queried for a feature which + * has no sub-features. */ - get: function(url, args, cb) { - return this.poll(null, url, args, cb, false); + hasSystemFeature: function() { + var ft = sysFeatures[arguments[0]]; + + if (arguments.length == 2) + return this.isObject(ft) ? ft[arguments[1]] : null; + + return (ft != null && ft != false); + }, + + /* private */ + notifySessionExpiry: function() { + Poll.stop(); + + L.ui.showModal(_('Session expired'), [ + E('div', { class: 'alert-message warning' }, + _('A new login is required since the authentication session expired.')), + E('div', { class: 'right' }, + E('div', { + class: 'btn primary', + click: function() { + var loc = window.location; + window.location = loc.protocol + '//' + loc.host + loc.pathname + loc.search; + } + }, _('To login…'))) + ]); + + L.raise('SessionError', 'Login session is expired'); + }, + + /* private */ + setupDOM: function(res) { + var domEv = res[0], + uiClass = res[1], + rpcClass = res[2], + formClass = res[3], + rpcBaseURL = res[4]; + + rpcClass.setBaseURL(rpcBaseURL); + + rpcClass.addInterceptor(function(msg, req) { + if (!L.isObject(msg) || !L.isObject(msg.error) || msg.error.code != -32002) + return; + + if (!L.isObject(req) || (req.object == 'session' && req.method == 'access')) + return; + + return rpcClass.declare({ + 'object': 'session', + 'method': 'access', + 'params': [ 'scope', 'object', 'function' ], + 'expect': { access: true } + })('uci', 'luci', 'read').catch(L.notifySessionExpiry); + }); + + Request.addInterceptor(function(res) { + var isDenied = false; + + if (res.status == 403 && res.headers.get('X-LuCI-Login-Required') == 'yes') + isDenied = true; + + if (!isDenied) + return; + + L.notifySessionExpiry(); + }); + + return this.probeSystemFeatures().finally(this.initDOM); + }, + + /* private */ + initDOM: function() { + originalCBIInit(); + Poll.start(); + document.dispatchEvent(new CustomEvent('luci-loaded')); }, /** - * Issues a POST request to the given url and invokes the specified - * callback function. The function is a wrapper around - * {@link LuCI.Request#request Request.request()}. The request is - * sent using `application/x-www-form-urlencoded` encoding and will - * contain a field `token` with the current value of `LuCI.env.token` - * by default. + * The `env` object holds environment settings used by LuCI, such + * as request timeouts, base URLs etc. * - * @deprecated * @instance * @memberof LuCI + */ + env: {}, + + /** + * Construct a relative URL path from the given prefix and parts. + * The resulting URL is guaranteed to only contain the characters + * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well + * as `/` for the path separator. * - * @param {string} url - * The URL to request. + * @instance + * @memberof LuCI * - * @param {Object<string, string>} [args] - * Additional post arguments to append to the request body. + * @param {string} [prefix] + * The prefix to join the given parts with. If the `prefix` is + * omitted, it defaults to an empty string. * - * @param {LuCI.requestCallbackFn} cb - * The callback function to invoke when the request finishes. + * @param {string[]} [parts] + * An array of parts to join into an URL path. Parts may contain + * slashes and any of the other characters mentioned above. * - * @return {Promise<null>} - * Returns a promise resolving to `null` when concluded. + * @return {string} + * Return the joined URL path. */ - post: function(url, args, cb) { - return this.poll(null, url, args, cb, true); + path: function(prefix, parts) { + var url = [ prefix || '' ]; + + for (var i = 0; i < parts.length; i++) + if (/^(?:[a-zA-Z0-9_.%,;-]+\/)*[a-zA-Z0-9_.%,;-]+$/.test(parts[i])) + url.push('/', parts[i]); + + if (url.length === 1) + url.push('/'); + + return url.join(''); }, /** - * Register a polling HTTP request that invokes the specified - * callback function. The function is a wrapper around - * {@link LuCI.Request.poll#add Request.poll.add()}. + * Construct an URL pathrelative to the script path of the server + * side LuCI application (usually `/cgi-bin/luci`). + * + * The resulting URL is guaranteed to only contain the characters + * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well + * as `/` for the path separator. * - * @deprecated * @instance * @memberof LuCI * - * @param {number} interval - * The poll interval to use. If set to a value less than or equal - * to `0`, it will default to the global poll interval configured - * in `LuCI.env.pollinterval`. - * - * @param {string} url - * The URL to request. - * - * @param {Object<string, string>} [args] - * Specifies additional arguments for the request. For GET requests, - * the arguments are appended to the URL as query string, for POST - * requests, they'll be added to the request body. + * @param {string[]} [parts] + * An array of parts to join into an URL path. Parts may contain + * slashes and any of the other characters mentioned above. * - * @param {LuCI.requestCallbackFn} cb - * The callback function to invoke whenever a request finishes. + * @return {string} + * Returns the resulting URL path. + */ + url: function() { + return this.path(this.env.scriptname, arguments); + }, + + /** + * Construct an URL path relative to the global static resource path + * of the LuCI ui (usually `/luci-static/resources`). * - * @param {boolean} [post=false] - * When set to `false` or not specified, poll requests will be made - * using the GET method. When set to `true`, POST requests will be - * issued. In case of POST requests, the request body will contain - * an argument `token` with the current value of `LuCI.env.token` by - * default, regardless of the parameters specified with `args`. + * The resulting URL is guaranteed to only contain the characters + * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well + * as `/` for the path separator. * - * @return {function} - * Returns the internally created function that has been passed to - * {@link LuCI.Request.poll#add Request.poll.add()}. This value can - * be passed to {@link LuCI.Poll.remove Poll.remove()} to remove the - * polling request. + * @instance + * @memberof LuCI + * + * @param {string[]} [parts] + * An array of parts to join into an URL path. Parts may contain + * slashes and any of the other characters mentioned above. + * + * @return {string} + * Returns the resulting URL path. */ - poll: function(interval, url, args, cb, post) { - if (interval !== null && interval <= 0) - interval = this.env.pollinterval; - - var data = post ? { token: this.env.token } : null, - method = post ? 'POST' : 'GET'; - - if (!/^(?:\/|\S+:\/\/)/.test(url)) - url = this.url(url); - - if (args != null) - data = Object.assign(data || {}, args); - - if (interval !== null) - return Request.poll.add(interval, url, { method: method, query: data }, cb); - else - return Request.request(url, { method: method, query: data }) - .then(function(res) { - var json = null; - if (/^application\/json\b/.test(res.headers.get('Content-Type'))) - try { json = res.json() } catch(e) {} - cb(res.xhr, json, res.duration); - }); + resource: function() { + return this.path(this.env.resource, arguments); }, /** - * Deprecated wrapper around {@link LuCI.Poll.remove Poll.remove()}. + * Construct an URL path relative to the media resource path of the + * LuCI ui (usually `/luci-static/$theme_name`). + * + * The resulting URL is guaranteed to only contain the characters + * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well + * as `/` for the path separator. * - * @deprecated * @instance * @memberof LuCI * - * @param {function} entry - * The polling function to remove. + * @param {string[]} [parts] + * An array of parts to join into an URL path. Parts may contain + * slashes and any of the other characters mentioned above. * - * @return {boolean} - * Returns `true` when the function has been removed or `false` if - * it could not be found. + * @return {string} + * Returns the resulting URL path. */ - stop: function(entry) { return Poll.remove(entry) }, + media: function() { + return this.path(this.env.media, arguments); + }, /** - * Deprecated wrapper around {@link LuCI.Poll.stop Poll.stop()}. + * Return the complete URL path to the current view. * - * @deprecated * @instance * @memberof LuCI * - * @return {boolean} - * Returns `true` when the polling loop has been stopped or `false` - * when it didn't run to begin with. + * @return {string} + * Returns the URL path to the current view. */ - halt: function() { return Poll.stop() }, + location: function() { + return this.path(this.env.scriptname, this.env.requestpath); + }, + /** - * Deprecated wrapper around {@link LuCI.Poll.start Poll.start()}. + * Tests whether the passed argument is a JavaScript object. + * This function is meant to be an object counterpart to the + * standard `Array.isArray()` function. * - * @deprecated * @instance * @memberof LuCI * + * @param {*} [val] + * The value to test + * * @return {boolean} - * Returns `true` when the polling loop has been started or `false` - * when it was already running. + * Returns `true` if the given value is of type object and + * not `null`, else returns `false`. */ - run: function() { return Poll.start() }, - + isObject: function(val) { + return (val != null && typeof(val) == 'object'); + }, /** - * @class + * Return an array of sorted object keys, optionally sorted by + * a different key or a different sorting mode. + * + * @instance * @memberof LuCI - * @hideconstructor - * @classdesc * - * The `dom` class provides convenience method for creating and - * manipulating DOM elements. + * @param {object} obj + * The object to extract the keys from. If the given value is + * not an object, the function will return an empty array. + * + * @param {string} [key] + * Specifies the key to order by. This is mainly useful for + * nested objects of objects or objects of arrays when sorting + * shall not be performed by the primary object keys but by + * some other key pointing to a value within the nested values. + * + * @param {string} [sortmode] + * May be either `addr` or `num` to override the natural + * lexicographic sorting with a sorting suitable for IP/MAC style + * addresses or numeric values respectively. + * + * @return {string[]} + * Returns an array containing the sorted keys of the given object. */ - dom: Class.singleton(/* @lends LuCI.dom.prototype */ { - __name__: 'LuCI.DOM', - - /** - * Tests whether the given argument is a valid DOM `Node`. - * - * @instance - * @memberof LuCI.dom - * @param {*} e - * The value to test. - * - * @returns {boolean} - * Returns `true` if the value is a DOM `Node`, else `false`. - */ - elem: function(e) { - return (e != null && typeof(e) == 'object' && 'nodeType' in e); - }, + sortedKeys: function(obj, key, sortmode) { + if (obj == null || typeof(obj) != 'object') + return []; - /** - * Parses a given string as HTML and returns the first child node. - * - * @instance - * @memberof LuCI.dom - * @param {string} s - * A string containing an HTML fragment to parse. Note that only - * the first result of the resulting structure is returned, so an - * input value of `<div>foo</div> <div>bar</div>` will only return - * the first `div` element node. - * - * @returns {Node} - * Returns the first DOM `Node` extracted from the HTML fragment or - * `null` on parsing failures or if no element could be found. - */ - parse: function(s) { - var elem; + return Object.keys(obj).map(function(e) { + var v = (key != null) ? obj[e][key] : e; - try { - domParser = domParser || new DOMParser(); - elem = domParser.parseFromString(s, 'text/html').body.firstChild; - } - catch(e) {} + switch (sortmode) { + case 'addr': + v = (v != null) ? v.replace(/(?:^|[.:])([0-9a-fA-F]{1,4})/g, + function(m0, m1) { return ('000' + m1.toLowerCase()).substr(-4) }) : null; + break; - if (!elem) { - try { - dummyElem = dummyElem || document.createElement('div'); - dummyElem.innerHTML = s; - elem = dummyElem.firstChild; - } - catch (e) {} + case 'num': + v = (v != null) ? +v : null; + break; } - return elem || null; - }, - - /** - * Tests whether a given `Node` matches the given query selector. - * - * This function is a convenience wrapper around the standard - * `Node.matches("selector")` function with the added benefit that - * the `node` argument may be a non-`Node` value, in which case - * this function simply returns `false`. - * - * @instance - * @memberof LuCI.dom - * @param {*} node - * The `Node` argument to test the selector against. - * - * @param {string} [selector] - * The query selector expression to test against the given node. - * - * @returns {boolean} - * Returns `true` if the given node matches the specified selector - * or `false` when the node argument is no valid DOM `Node` or the - * selector didn't match. - */ - matches: function(node, selector) { - var m = this.elem(node) ? node.matches || node.msMatchesSelector : null; - return m ? m.call(node, selector) : false; - }, + return [ e, v ]; + }).filter(function(e) { + return (e[1] != null); + }).sort(function(a, b) { + return (a[1] > b[1]); + }).map(function(e) { + return e[0]; + }); + }, - /** - * Returns the closest parent node that matches the given query - * selector expression. - * - * This function is a convenience wrapper around the standard - * `Node.closest("selector")` function with the added benefit that - * the `node` argument may be a non-`Node` value, in which case - * this function simply returns `null`. - * - * @instance - * @memberof LuCI.dom - * @param {*} node - * The `Node` argument to find the closest parent for. - * - * @param {string} [selector] - * The query selector expression to test against each parent. - * - * @returns {Node|null} - * Returns the closest parent node matching the selector or - * `null` when the node argument is no valid DOM `Node` or the - * selector didn't match any parent. - */ - parent: function(node, selector) { - if (this.elem(node) && node.closest) - return node.closest(selector); + /** + * Converts the given value to an array. If the given value is of + * type array, it is returned as-is, values of type object are + * returned as one-element array containing the object, empty + * strings and `null` values are returned as empty array, all other + * values are converted using `String()`, trimmed, split on white + * space and returned as array. + * + * @instance + * @memberof LuCI + * + * @param {*} val + * The value to convert into an array. + * + * @return {Array<*>} + * Returns the resulting array. + */ + toArray: function(val) { + if (val == null) + return []; + else if (Array.isArray(val)) + return val; + else if (typeof(val) == 'object') + return [ val ]; - while (this.elem(node)) - if (this.matches(node, selector)) - return node; - else - node = node.parentNode; + var s = String(val).trim(); - return null; - }, + if (s == '') + return []; - /** - * Appends the given children data to the given node. - * - * @instance - * @memberof LuCI.dom - * @param {*} node - * The `Node` argument to append the children to. - * - * @param {*} [children] - * The childrens to append to the given node. - * - * When `children` is an array, then each item of the array - * will be either appended as child element or text node, - * depending on whether the item is a DOM `Node` instance or - * some other non-`null` value. Non-`Node`, non-`null` values - * will be converted to strings first before being passed as - * argument to `createTextNode()`. - * - * When `children` is a function, it will be invoked with - * the passed `node` argument as sole parameter and the `append` - * function will be invoked again, with the given `node` argument - * as first and the return value of the `children` function as - * second parameter. - * - * When `children` is is a DOM `Node` instance, it will be - * appended to the given `node`. - * - * When `children` is any other non-`null` value, it will be - * converted to a string and appened to the `innerHTML` property - * of the given `node`. - * - * @returns {Node|null} - * Returns the last children `Node` appended to the node or `null` - * if either the `node` argument was no valid DOM `node` or if the - * `children` was `null` or didn't result in further DOM nodes. - */ - append: function(node, children) { - if (!this.elem(node)) - return null; + return s.split(/\s+/); + }, - if (Array.isArray(children)) { - for (var i = 0; i < children.length; i++) - if (this.elem(children[i])) - node.appendChild(children[i]); - else if (children !== null && children !== undefined) - node.appendChild(document.createTextNode('' + children[i])); - - return node.lastChild; - } - else if (typeof(children) === 'function') { - return this.append(node, children(node)); - } - else if (this.elem(children)) { - return node.appendChild(children); - } - else if (children !== null && children !== undefined) { - node.innerHTML = '' + children; - return node.lastChild; - } - - return null; - }, - - /** - * Replaces the content of the given node with the given children. - * - * This function first removes any children of the given DOM - * `Node` and then adds the given given children following the - * rules outlined below. - * - * @instance - * @memberof LuCI.dom - * @param {*} node - * The `Node` argument to replace the children of. - * - * @param {*} [children] - * The childrens to replace into the given node. - * - * When `children` is an array, then each item of the array - * will be either appended as child element or text node, - * depending on whether the item is a DOM `Node` instance or - * some other non-`null` value. Non-`Node`, non-`null` values - * will be converted to strings first before being passed as - * argument to `createTextNode()`. - * - * When `children` is a function, it will be invoked with - * the passed `node` argument as sole parameter and the `append` - * function will be invoked again, with the given `node` argument - * as first and the return value of the `children` function as - * second parameter. - * - * When `children` is is a DOM `Node` instance, it will be - * appended to the given `node`. - * - * When `children` is any other non-`null` value, it will be - * converted to a string and appened to the `innerHTML` property - * of the given `node`. - * - * @returns {Node|null} - * Returns the last children `Node` appended to the node or `null` - * if either the `node` argument was no valid DOM `node` or if the - * `children` was `null` or didn't result in further DOM nodes. - */ - content: function(node, children) { - if (!this.elem(node)) - return null; - - var dataNodes = node.querySelectorAll('[data-idref]'); - - for (var i = 0; i < dataNodes.length; i++) - delete this.registry[dataNodes[i].getAttribute('data-idref')]; - - while (node.firstChild) - node.removeChild(node.firstChild); - - return this.append(node, children); - }, - - /** - * Sets attributes or registers event listeners on element nodes. - * - * @instance - * @memberof LuCI.dom - * @param {*} node - * The `Node` argument to set the attributes or add the event - * listeners for. When the given `node` value is not a valid - * DOM `Node`, the function returns and does nothing. - * - * @param {string|Object<string, *>} key - * Specifies either the attribute or event handler name to use, - * or an object containing multiple key, value pairs which are - * each added to the node as either attribute or event handler, - * depending on the respective value. - * - * @param {*} [val] - * Specifies the attribute value or event handler function to add. - * If the `key` parameter is an `Object`, this parameter will be - * ignored. - * - * When `val` is of type function, it will be registered as event - * handler on the given `node` with the `key` parameter being the - * event name. - * - * When `val` is of type object, it will be serialized as JSON and - * added as attribute to the given `node`, using the given `key` - * as attribute name. - * - * When `val` is of any other type, it will be added as attribute - * to the given `node` as-is, with the underlying `setAttribute()` - * call implicitely turning it into a string. - */ - attr: function(node, key, val) { - if (!this.elem(node)) - return null; - - var attr = null; - - if (typeof(key) === 'object' && key !== null) - attr = key; - else if (typeof(key) === 'string') - attr = {}, attr[key] = val; - - for (key in attr) { - if (!attr.hasOwnProperty(key) || attr[key] == null) - continue; - - switch (typeof(attr[key])) { - case 'function': - node.addEventListener(key, attr[key]); - break; - - case 'object': - node.setAttribute(key, JSON.stringify(attr[key])); - break; - - default: - node.setAttribute(key, attr[key]); - } - } - }, - - /** - * Creates a new DOM `Node` from the given `html`, `attr` and - * `data` parameters. - * - * This function has multiple signatures, it can be either invoked - * in the form `create(html[, attr[, data]])` or in the form - * `create(html[, data])`. The used variant is determined from the - * type of the second argument. - * - * @instance - * @memberof LuCI.dom - * @param {*} html - * Describes the node to create. - * - * When the value of `html` is of type array, a `DocumentFragment` - * node is created and each item of the array is first converted - * to a DOM `Node` by passing it through `create()` and then added - * as child to the fragment. - * - * When the value of `html` is a DOM `Node` instance, no new - * element will be created but the node will be used as-is. - * - * When the value of `html` is a string starting with `<`, it will - * be passed to `dom.parse()` and the resulting value is used. - * - * When the value of `html` is any other string, it will be passed - * to `document.createElement()` for creating a new DOM `Node` of - * the given name. - * - * @param {Object<string, *>} [attr] - * Specifies an Object of key, value pairs to set as attributes - * or event handlers on the created node. Refer to - * {@link LuCI.dom#attr dom.attr()} for details. - * - * @param {*} [data] - * Specifies children to append to the newly created element. - * Refer to {@link LuCI.dom#append dom.append()} for details. - * - * @throws {InvalidCharacterError} - * Throws an `InvalidCharacterError` when the given `html` - * argument contained malformed markup (such as not escaped - * `&` characters in XHTML mode) or when the given node name - * in `html` contains characters which are not legal in DOM - * element names, such as spaces. - * - * @returns {Node} - * Returns the newly created `Node`. - */ - create: function() { - var html = arguments[0], - attr = arguments[1], - data = arguments[2], - elem; - - if (!(attr instanceof Object) || Array.isArray(attr)) - data = attr, attr = null; - - if (Array.isArray(html)) { - elem = document.createDocumentFragment(); - for (var i = 0; i < html.length; i++) - elem.appendChild(this.create(html[i])); - } - else if (this.elem(html)) { - elem = html; - } - else if (html.charCodeAt(0) === 60) { - elem = this.parse(html); - } - else { - elem = document.createElement(html); - } - - if (!elem) - return null; - - this.attr(elem, attr); - this.append(elem, data); - - return elem; - }, - - registry: {}, - - /** - * Attaches or detaches arbitrary data to and from a DOM `Node`. - * - * This function is useful to attach non-string values or runtime - * data that is not serializable to DOM nodes. To decouple data - * from the DOM, values are not added directly to nodes, but - * inserted into a registry instead which is then referenced by a - * string key stored as `data-idref` attribute in the node. - * - * This function has multiple signatures and is sensitive to the - * number of arguments passed to it. - * - * - `dom.data(node)` - - * Fetches all data associated with the given node. - * - `dom.data(node, key)` - - * Fetches a specific key associated with the given node. - * - `dom.data(node, key, val)` - - * Sets a specific key to the given value associated with the - * given node. - * - `dom.data(node, null)` - - * Clears any data associated with the node. - * - `dom.data(node, key, null)` - - * Clears the given key associated with the node. - * - * @instance - * @memberof LuCI.dom - * @param {Node} node - * The DOM `Node` instance to set or retrieve the data for. - * - * @param {string|null} [key] - * This is either a string specifying the key to retrieve, or - * `null` to unset the entire node data. - * - * @param {*|null} [val] - * This is either a non-`null` value to set for a given key or - * `null` to remove the given `key` from the specified node. - * - * @returns {*} - * Returns the get or set value, or `null` when no value could - * be found. - */ - data: function(node, key, val) { - if (!node || !node.getAttribute) - return null; - - var id = node.getAttribute('data-idref'); - - /* clear all data */ - if (arguments.length > 1 && key == null) { - if (id != null) { - node.removeAttribute('data-idref'); - val = this.registry[id] - delete this.registry[id]; - return val; - } - - return null; - } - - /* clear a key */ - else if (arguments.length > 2 && key != null && val == null) { - if (id != null) { - val = this.registry[id][key]; - delete this.registry[id][key]; - return val; - } - - return null; - } - - /* set a key */ - else if (arguments.length > 2 && key != null && val != null) { - if (id == null) { - do { id = Math.floor(Math.random() * 0xffffffff).toString(16) } - while (this.registry.hasOwnProperty(id)); - - node.setAttribute('data-idref', id); - this.registry[id] = {}; - } - - return (this.registry[id][key] = val); - } - - /* get all data */ - else if (arguments.length == 1) { - if (id != null) - return this.registry[id]; - - return null; - } - - /* get a key */ - else if (arguments.length == 2) { - if (id != null) - return this.registry[id][key]; - } - - return null; - }, - - /** - * Binds the given class instance ot the specified DOM `Node`. - * - * This function uses the `dom.data()` facility to attach the - * passed instance of a Class to a node. This is needed for - * complex widget elements or similar where the corresponding - * class instance responsible for the element must be retrieved - * from DOM nodes obtained by `querySelector()` or similar means. - * - * @instance - * @memberof LuCI.dom - * @param {Node} node - * The DOM `Node` instance to bind the class to. - * - * @param {Class} inst - * The Class instance to bind to the node. - * - * @throws {TypeError} - * Throws a `TypeError` when the given instance argument isn't - * a valid Class instance. - * - * @returns {Class} - * Returns the bound class instance. - */ - bindClassInstance: function(node, inst) { - if (!(inst instanceof Class)) - L.error('TypeError', 'Argument must be a class instance'); - - return this.data(node, '_class', inst); - }, - - /** - * Finds a bound class instance on the given node itself or the - * first bound instance on its closest parent node. - * - * @instance - * @memberof LuCI.dom - * @param {Node} node - * The DOM `Node` instance to start from. - * - * @returns {Class|null} - * Returns the founds class instance if any or `null` if no bound - * class could be found on the node itself or any of its parents. - */ - findClassInstance: function(node) { - var inst = null; - - do { - inst = this.data(node, '_class'); - node = node.parentNode; - } - while (!(inst instanceof Class) && node != null); - - return inst; - }, - - /** - * Finds a bound class instance on the given node itself or the - * first bound instance on its closest parent node and invokes - * the specified method name on the found class instance. - * - * @instance - * @memberof LuCI.dom - * @param {Node} node - * The DOM `Node` instance to start from. - * - * @param {string} method - * The name of the method to invoke on the found class instance. - * - * @param {...*} params - * Additional arguments to pass to the invoked method as-is. - * - * @returns {*|null} - * Returns the return value of the invoked method if a class - * instance and method has been found. Returns `null` if either - * no bound class instance could be found, or if the found - * instance didn't have the requested `method`. - */ - callClassMethod: function(node, method /*, ... */) { - var inst = this.findClassInstance(node); - - if (inst == null || typeof(inst[method]) != 'function') - return null; - - return inst[method].apply(inst, inst.varargs(arguments, 2)); - }, - - /** - * The ignore callback function is invoked by `isEmpty()` for each - * child node to decide whether to ignore a child node or not. - * - * When this function returns `false`, the node passed to it is - * ignored, else not. - * - * @callback LuCI.dom~ignoreCallbackFn - * @param {Node} node - * The child node to test. - * - * @returns {boolean} - * Boolean indicating whether to ignore the node or not. - */ - - /** - * Tests whether a given DOM `Node` instance is empty or appears - * empty. - * - * Any element child nodes which have the CSS class `hidden` set - * or for which the optionally passed `ignoreFn` callback function - * returns `false` are ignored. - * - * @instance - * @memberof LuCI.dom - * @param {Node} node - * The DOM `Node` instance to test. - * - * @param {LuCI.dom~ignoreCallbackFn} [ignoreFn] - * Specifies an optional function which is invoked for each child - * node to decide whether the child node should be ignored or not. - * - * @returns {boolean} - * Returns `true` if the node does not have any children or if - * any children node either has a `hidden` CSS class or a `false` - * result when testing it using the given `ignoreFn`. - */ - isEmpty: function(node, ignoreFn) { - for (var child = node.firstElementChild; child != null; child = child.nextElementSibling) - if (!child.classList.contains('hidden') && (!ignoreFn || !ignoreFn(child))) - return false; - - return true; - } - }), - - Poll: Poll, - Class: Class, - Request: Request, + /** + * Returns a promise resolving with either the given value or or with + * the given default in case the input value is a rejecting promise. + * + * @instance + * @memberof LuCI + * + * @param {*} value + * The value to resolve the promise with. + * + * @param {*} defvalue + * The default value to resolve the promise with in case the given + * input value is a rejecting promise. + * + * @returns {Promise<*>} + * Returns a new promise resolving either to the given input value or + * to the given default value on error. + */ + resolveDefault: function(value, defvalue) { + return Promise.resolve(value).catch(function() { return defvalue }); + }, /** - * @class + * The request callback function is invoked whenever an HTTP + * reply to a request made using the `L.get()`, `L.post()` or + * `L.poll()` function is timed out or received successfully. + * + * @instance * @memberof LuCI - * @hideconstructor - * @classdesc * - * The `view` class forms the basis of views and provides a standard - * set of methods to inherit from. + * @callback LuCI.requestCallbackFn + * @param {XMLHTTPRequest} xhr + * The XMLHTTPRequest instance used to make the request. + * + * @param {*} data + * The response JSON if the response could be parsed as such, + * else `null`. + * + * @param {number} duration + * The total duration of the request in milliseconds. */ - view: Class.extend(/* @lends LuCI.view.prototype */ { - __name__: 'LuCI.View', - __init__: function() { - var vp = document.getElementById('view'); - - L.dom.content(vp, E('div', { 'class': 'spinning' }, _('Loading view…'))); + /** + * Issues a GET request to the given url and invokes the specified + * callback function. The function is a wrapper around + * {@link LuCI.request#request Request.request()}. + * + * @deprecated + * @instance + * @memberof LuCI + * + * @param {string} url + * The URL to request. + * + * @param {Object<string, string>} [args] + * Additional query string arguments to append to the URL. + * + * @param {LuCI.requestCallbackFn} cb + * The callback function to invoke when the request finishes. + * + * @return {Promise<null>} + * Returns a promise resolving to `null` when concluded. + */ + get: function(url, args, cb) { + return this.poll(null, url, args, cb, false); + }, - return Promise.resolve(this.load()) - .then(L.bind(this.render, this)) - .then(L.bind(function(nodes) { - var vp = document.getElementById('view'); + /** + * Issues a POST request to the given url and invokes the specified + * callback function. The function is a wrapper around + * {@link LuCI.request#request Request.request()}. The request is + * sent using `application/x-www-form-urlencoded` encoding and will + * contain a field `token` with the current value of `LuCI.env.token` + * by default. + * + * @deprecated + * @instance + * @memberof LuCI + * + * @param {string} url + * The URL to request. + * + * @param {Object<string, string>} [args] + * Additional post arguments to append to the request body. + * + * @param {LuCI.requestCallbackFn} cb + * The callback function to invoke when the request finishes. + * + * @return {Promise<null>} + * Returns a promise resolving to `null` when concluded. + */ + post: function(url, args, cb) { + return this.poll(null, url, args, cb, true); + }, - L.dom.content(vp, nodes); - L.dom.append(vp, this.addFooter()); - }, this)).catch(L.error); - }, + /** + * Register a polling HTTP request that invokes the specified + * callback function. The function is a wrapper around + * {@link LuCI.request.poll#add Request.poll.add()}. + * + * @deprecated + * @instance + * @memberof LuCI + * + * @param {number} interval + * The poll interval to use. If set to a value less than or equal + * to `0`, it will default to the global poll interval configured + * in `LuCI.env.pollinterval`. + * + * @param {string} url + * The URL to request. + * + * @param {Object<string, string>} [args] + * Specifies additional arguments for the request. For GET requests, + * the arguments are appended to the URL as query string, for POST + * requests, they'll be added to the request body. + * + * @param {LuCI.requestCallbackFn} cb + * The callback function to invoke whenever a request finishes. + * + * @param {boolean} [post=false] + * When set to `false` or not specified, poll requests will be made + * using the GET method. When set to `true`, POST requests will be + * issued. In case of POST requests, the request body will contain + * an argument `token` with the current value of `LuCI.env.token` by + * default, regardless of the parameters specified with `args`. + * + * @return {function} + * Returns the internally created function that has been passed to + * {@link LuCI.request.poll#add Request.poll.add()}. This value can + * be passed to {@link LuCI.poll.remove Poll.remove()} to remove the + * polling request. + */ + poll: function(interval, url, args, cb, post) { + if (interval !== null && interval <= 0) + interval = this.env.pollinterval; - /** - * The load function is invoked before the view is rendered. - * - * The invocation of this function is wrapped by - * `Promise.resolve()` so it may return Promises if needed. - * - * The return value of the function (or the resolved values - * of the promise returned by it) will be passed as first - * argument to `render()`. - * - * This function is supposed to be overwritten by subclasses, - * the default implementation does nothing. - * - * @instance - * @abstract - * @memberof LuCI.view - * - * @returns {*|Promise<*>} - * May return any value or a Promise resolving to any value. - */ - load: function() {}, + var data = post ? { token: this.env.token } : null, + method = post ? 'POST' : 'GET'; - /** - * The render function is invoked after the - * {@link LuCI.view#load load()} function and responsible - * for setting up the view contents. It must return a DOM - * `Node` or `DocumentFragment` holding the contents to - * insert into the view area. - * - * The invocation of this function is wrapped by - * `Promise.resolve()` so it may return Promises if needed. - * - * The return value of the function (or the resolved values - * of the promise returned by it) will be inserted into the - * main content area using - * {@link LuCI.dom#append dom.append()}. - * - * This function is supposed to be overwritten by subclasses, - * the default implementation does nothing. - * - * @instance - * @abstract - * @memberof LuCI.view - * @param {*|null} load_results - * This function will receive the return value of the - * {@link LuCI.view#load view.load()} function as first - * argument. - * - * @returns {Node|Promise<Node>} - * Should return a DOM `Node` value or a `Promise` resolving - * to a `Node` value. - */ - render: function() {}, + if (!/^(?:\/|\S+:\/\/)/.test(url)) + url = this.url(url); - /** - * The handleSave function is invoked when the user clicks - * the `Save` button in the page action footer. - * - * The default implementation should be sufficient for most - * views using {@link form#Map form.Map()} based forms - it - * will iterate all forms present in the view and invoke - * the {@link form#Map#save Map.save()} method on each form. - * - * Views not using `Map` instances or requiring other special - * logic should overwrite `handleSave()` with a custom - * implementation. - * - * To disable the `Save` page footer button, views extending - * this base class should overwrite the `handleSave` function - * with `null`. - * - * The invocation of this function is wrapped by - * `Promise.resolve()` so it may return Promises if needed. - * - * @instance - * @memberof LuCI.view - * @param {Event} ev - * The DOM event that triggered the function. - * - * @returns {*|Promise<*>} - * Any return values of this function are discarded, but - * passed through `Promise.resolve()` to ensure that any - * returned promise runs to completion before the button - * is reenabled. - */ - handleSave: function(ev) { - var tasks = []; + if (args != null) + data = Object.assign(data || {}, args); - document.getElementById('maincontent') - .querySelectorAll('.cbi-map').forEach(function(map) { - tasks.push(L.dom.callClassMethod(map, 'save')); + if (interval !== null) + return Request.poll.add(interval, url, { method: method, query: data }, cb); + else + return Request.request(url, { method: method, query: data }) + .then(function(res) { + var json = null; + if (/^application\/json\b/.test(res.headers.get('Content-Type'))) + try { json = res.json() } catch(e) {} + cb(res.xhr, json, res.duration); }); + }, - return Promise.all(tasks); - }, + /** + * Deprecated wrapper around {@link LuCI.poll.remove Poll.remove()}. + * + * @deprecated + * @instance + * @memberof LuCI + * + * @param {function} entry + * The polling function to remove. + * + * @return {boolean} + * Returns `true` when the function has been removed or `false` if + * it could not be found. + */ + stop: function(entry) { return Poll.remove(entry) }, - /** - * The handleSaveApply function is invoked when the user clicks - * the `Save & Apply` button in the page action footer. - * - * The default implementation should be sufficient for most - * views using {@link form#Map form.Map()} based forms - it - * will first invoke - * {@link LuCI.view.handleSave view.handleSave()} and then - * call {@link ui#changes#apply ui.changes.apply()} to start the - * modal config apply and page reload flow. - * - * Views not using `Map` instances or requiring other special - * logic should overwrite `handleSaveApply()` with a custom - * implementation. - * - * To disable the `Save & Apply` page footer button, views - * extending this base class should overwrite the - * `handleSaveApply` function with `null`. - * - * The invocation of this function is wrapped by - * `Promise.resolve()` so it may return Promises if needed. - * - * @instance - * @memberof LuCI.view - * @param {Event} ev - * The DOM event that triggered the function. - * - * @returns {*|Promise<*>} - * Any return values of this function are discarded, but - * passed through `Promise.resolve()` to ensure that any - * returned promise runs to completion before the button - * is reenabled. - */ - handleSaveApply: function(ev, mode) { - return this.handleSave(ev).then(function() { - L.ui.changes.apply(mode == '0'); - }); - }, + /** + * Deprecated wrapper around {@link LuCI.poll.stop Poll.stop()}. + * + * @deprecated + * @instance + * @memberof LuCI + * + * @return {boolean} + * Returns `true` when the polling loop has been stopped or `false` + * when it didn't run to begin with. + */ + halt: function() { return Poll.stop() }, - /** - * The handleReset function is invoked when the user clicks - * the `Reset` button in the page action footer. - * - * The default implementation should be sufficient for most - * views using {@link form#Map form.Map()} based forms - it - * will iterate all forms present in the view and invoke - * the {@link form#Map#save Map.reset()} method on each form. - * - * Views not using `Map` instances or requiring other special - * logic should overwrite `handleReset()` with a custom - * implementation. - * - * To disable the `Reset` page footer button, views extending - * this base class should overwrite the `handleReset` function - * with `null`. - * - * The invocation of this function is wrapped by - * `Promise.resolve()` so it may return Promises if needed. - * - * @instance - * @memberof LuCI.view - * @param {Event} ev - * The DOM event that triggered the function. - * - * @returns {*|Promise<*>} - * Any return values of this function are discarded, but - * passed through `Promise.resolve()` to ensure that any - * returned promise runs to completion before the button - * is reenabled. - */ - handleReset: function(ev) { - var tasks = []; + /** + * Deprecated wrapper around {@link LuCI.poll.start Poll.start()}. + * + * @deprecated + * @instance + * @memberof LuCI + * + * @return {boolean} + * Returns `true` when the polling loop has been started or `false` + * when it was already running. + */ + run: function() { return Poll.start() }, - document.getElementById('maincontent') - .querySelectorAll('.cbi-map').forEach(function(map) { - tasks.push(L.dom.callClassMethod(map, 'reset')); - }); + /** + * Legacy `L.dom` class alias. New view code should use `'require dom';` + * to request the `LuCI.dom` class. + * + * @instance + * @memberof LuCI + * @deprecated + */ + dom: DOM, - return Promise.all(tasks); - }, + /** + * Legacy `L.view` class alias. New view code should use `'require view';` + * to request the `LuCI.view` class. + * + * @instance + * @memberof LuCI + * @deprecated + */ + view: View, - /** - * Renders a standard page action footer if any of the - * `handleSave()`, `handleSaveApply()` or `handleReset()` - * functions are defined. - * - * The default implementation should be sufficient for most - * views - it will render a standard page footer with action - * buttons labeled `Save`, `Save & Apply` and `Reset` - * triggering the `handleSave()`, `handleSaveApply()` and - * `handleReset()` functions respectively. - * - * When any of these `handle*()` functions is overwritten - * with `null` by a view extending this class, the - * corresponding button will not be rendered. - * - * @instance - * @memberof LuCI.view - * @returns {DocumentFragment} - * Returns a `DocumentFragment` containing the footer bar - * with buttons for each corresponding `handle*()` action - * or an empty `DocumentFragment` if all three `handle*()` - * methods are overwritten with `null`. - */ - addFooter: function() { - var footer = E([]); - - var saveApplyBtn = this.handleSaveApply ? new L.ui.ComboButton('0', { - 0: [ _('Save & Apply') ], - 1: [ _('Apply unchecked') ] - }, { - classes: { - 0: 'btn cbi-button cbi-button-apply important', - 1: 'btn cbi-button cbi-button-negative important' - }, - click: L.ui.createHandlerFn(this, 'handleSaveApply') - }).render() : E([]); - - if (this.handleSaveApply || this.handleSave || this.handleReset) { - footer.appendChild(E('div', { 'class': 'cbi-page-actions control-group' }, [ - saveApplyBtn, ' ', - this.handleSave ? E('button', { - 'class': 'cbi-button cbi-button-save', - 'click': L.ui.createHandlerFn(this, 'handleSave') - }, [ _('Save') ]) : '', ' ', - this.handleReset ? E('button', { - 'class': 'cbi-button cbi-button-reset', - 'click': L.ui.createHandlerFn(this, 'handleReset') - }, [ _('Reset') ]) : '' - ])); - } + /** + * Legacy `L.Poll` class alias. New view code should use `'require poll';` + * to request the `LuCI.poll` class. + * + * @instance + * @memberof LuCI + * @deprecated + */ + Poll: Poll, - return footer; - } - }) + /** + * Legacy `L.Request` class alias. New view code should use `'require request';` + * to request the `LuCI.request` class. + * + * @instance + * @memberof LuCI + * @deprecated + */ + Request: Request, + + /** + * Legacy `L.Class` class alias. New view code should use `'require baseclass';` + * to request the `LuCI.baseclass` class. + * + * @instance + * @memberof LuCI + * @deprecated + */ + Class: Class }); /** - * @class + * @class xhr * @memberof LuCI * @deprecated * @classdesc * - * The `LuCI.XHR` class is a legacy compatibility shim for the + * The `LuCI.xhr` class is a legacy compatibility shim for the * functionality formerly provided by `xhr.js`. It is registered as global * `window.XHR` symbol for compatibility with legacy code. * - * New code should use {@link LuCI.Request} instead to implement HTTP + * New code should use {@link LuCI.request} instead to implement HTTP * request handling. */ - var XHR = Class.extend(/** @lends LuCI.XHR.prototype */ { - __name__: 'LuCI.XHR', + var XHR = Class.extend(/** @lends LuCI.xhr.prototype */ { + __name__: 'LuCI.xhr', __init__: function() { if (window.console && console.debug) console.debug('Direct use XHR() is deprecated, please use L.Request instead'); @@ -4735,7 +4799,7 @@ * * @instance * @deprecated - * @memberof LuCI.XHR + * @memberof LuCI.xhr * * @param {string} url * The URL to request @@ -4762,7 +4826,7 @@ * * @instance * @deprecated - * @memberof LuCI.XHR + * @memberof LuCI.xhr * * @param {string} url * The URL to request @@ -4793,7 +4857,7 @@ * * @instance * @deprecated - * @memberof LuCI.XHR + * @memberof LuCI.xhr */ cancel: function() { delete this.active }, @@ -4802,7 +4866,7 @@ * * @instance * @deprecated - * @memberof LuCI.XHR + * @memberof LuCI.xhr * * @returns {boolean} * Returns `true` if the request is still running or `false` if it @@ -4817,7 +4881,7 @@ * * @instance * @deprecated - * @memberof LuCI.XHR + * @memberof LuCI.xhr */ abort: function() {}, @@ -4828,7 +4892,7 @@ * * @instance * @deprecated - * @memberof LuCI.XHR + * @memberof LuCI.xhr * * @throws {InternalError} * Throws an `InternalError` with the message `Not implemented` @@ -4860,7 +4924,7 @@
      - Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) + Documentation generated by JSDoc 3.6.3 on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time)
      diff --git a/docs/jsapi/network.js.html b/docs/jsapi/network.js.html index 07aca9add..51277d671 100644 --- a/docs/jsapi/network.js.html +++ b/docs/jsapi/network.js.html @@ -43,8 +43,18 @@ Members +
    • Class
    • + +
    • dom
    • +
    • env
    • +
    • Poll
    • + +
    • Request
    • + +
    • view
    • +
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -1696,6 +1704,8 @@ 'require uci'; 'require rpc'; 'require validation'; +'require baseclass'; +'require firewall'; var proto_errors = { CONNECT_FAILED: _('Connection attempt failed'), @@ -2326,18 +2336,18 @@ function enumerateNetworks() { var Hosts, Network, Protocol, Device, WifiDevice, WifiNetwork; /** - * @class + * @class network * @memberof LuCI * @hideconstructor * @classdesc * - * The `LuCI.Network` class combines data from multiple `ubus` apis to + * The `LuCI.network` class combines data from multiple `ubus` apis to * provide an abstraction of the current network configuration state. * * It provides methods to enumerate interfaces and devices, to query * current configuration details and to manipulate settings. */ -Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { +Network = baseclass.extend(/** @lends LuCI.network.prototype */ { /** * Converts the given prefix size in bits to a netmask. * @@ -2380,8 +2390,8 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * such as the used key management protocols, active ciphers and * protocol versions. * - * @typedef {Object<string, boolean|Array<number|string>>} LuCI.Network.WifiEncryption - * @memberof LuCI.Network + * @typedef {Object<string, boolean|Array<number|string>>} LuCI.network.WifiEncryption + * @memberof LuCI.network * * @property {boolean} enabled * Specifies whether any kind of encryption, such as `WEP` or `WPA` is @@ -2415,13 +2425,13 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { */ /** - * Converts a given {@link LuCI.Network.WifiEncryption encryption entry} + * Converts a given {@link LuCI.network.WifiEncryption encryption entry} * into a human readable string such as `mixed WPA/WPA2 PSK (TKIP, CCMP)` * or `WPA3 SAE (CCMP)`. * * @method * - * @param {LuCI.Network.WifiEncryption} encryption + * @param {LuCI.network.WifiEncryption} encryption * The wireless encryption entry to convert. * * @returns {null|string} @@ -2443,7 +2453,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { }, /** - * Instantiates the given {@link LuCI.Network.Protocol Protocol} backend, + * Instantiates the given {@link LuCI.network.Protocol Protocol} backend, * optionally using the given network name. * * @param {string} protoname @@ -2455,7 +2465,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * but it is allowed to omit it, e.g. to query protocol capabilities * without the need for an existing interface. * - * @returns {null|LuCI.Network.Protocol} + * @returns {null|LuCI.network.Protocol} * Returns the instantiated protocol backend class or `null` if the given * protocol isn't known. */ @@ -2468,10 +2478,10 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { }, /** - * Obtains instances of all known {@link LuCI.Network.Protocol Protocol} + * Obtains instances of all known {@link LuCI.network.Protocol Protocol} * backend classes. * - * @returns {Array<LuCI.Network.Protocol>} + * @returns {Array<LuCI.network.Protocol>} * Returns an array of protocol class instances. */ getProtocols: function() { @@ -2484,7 +2494,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { }, /** - * Registers a new {@link LuCI.Network.Protocol Protocol} subclass + * Registers a new {@link LuCI.network.Protocol Protocol} subclass * with the given methods and returns the resulting subclass value. * * This functions internally calls @@ -2498,7 +2508,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * The member methods and values of the new `Protocol` subclass to * be passed to {@link LuCI.Class.extend Class.extend()}. * - * @returns {LuCI.Network.Protocol} + * @returns {LuCI.network.Protocol} * Returns the new `Protocol` subclass. */ registerProtocol: function(protoname, methods) { @@ -2587,7 +2597,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * An object of uci option values to set on the new network or to * update in an existing, empty network. * - * @returns {Promise<null|LuCI.Network.Protocol>} + * @returns {Promise<null|LuCI.network.Protocol>} * Returns a promise resolving to the `Protocol` subclass instance * describing the added network or resolving to `null` if the name * was invalid or if a non-empty network of the given name already @@ -2619,15 +2629,15 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { }, /** - * Get a {@link LuCI.Network.Protocol Protocol} instance describing + * Get a {@link LuCI.network.Protocol Protocol} instance describing * the network with the given name. * * @param {string} name * The logical interface name of the network get, e.g. `lan` or `wan`. * - * @returns {Promise<null|LuCI.Network.Protocol>} + * @returns {Promise<null|LuCI.network.Protocol>} * Returns a promise resolving to a - * {@link LuCI.Network.Protocol Protocol} subclass instance describing + * {@link LuCI.network.Protocol Protocol} subclass instance describing * the network or `null` if the network did not exist. */ getNetwork: function(name) { @@ -2650,9 +2660,9 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { /** * Gets an array containing all known networks. * - * @returns {Promise<Array<LuCI.Network.Protocol>>} + * @returns {Promise<Array<LuCI.network.Protocol>>} * Returns a promise resolving to a name-sorted array of - * {@link LuCI.Network.Protocol Protocol} subclass instances + * {@link LuCI.network.Protocol Protocol} subclass instances * describing all known networks. */ getNetworks: function() { @@ -2675,8 +2685,9 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { var requireFirewall = Promise.resolve(L.require('firewall')).catch(function() {}), network = this.instantiateNetwork(name); - return Promise.all([ requireFirewall, initNetworkState() ]).then(function() { - var uciInterface = uci.get('network', name); + return Promise.all([ requireFirewall, initNetworkState() ]).then(function(res) { + var uciInterface = uci.get('network', name), + firewall = res[0]; if (uciInterface != null && uciInterface['.type'] == 'interface') { return Promise.resolve(network ? network.deleteConfiguration() : null).then(function() { @@ -2711,8 +2722,8 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { uci.unset('wireless', s['.name'], 'network'); }); - if (L.firewall) - return L.firewall.deleteNetwork(name).then(function() { return true }); + if (firewall) + return firewall.deleteNetwork(name).then(function() { return true }); return true; }).catch(function() { @@ -2790,13 +2801,13 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { }, /** - * Get a {@link LuCI.Network.Device Device} instance describing the + * Get a {@link LuCI.network.Device Device} instance describing the * given network device. * * @param {string} name * The name of the network device to get, e.g. `eth0` or `br-lan`. * - * @returns {Promise<null|LuCI.Network.Device>} + * @returns {Promise<null|LuCI.network.Device>} * Returns a promise resolving to the `Device` instance describing * the network device or `null` if the given device name could not * be found. @@ -2820,7 +2831,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { /** * Get a sorted list of all found network devices. * - * @returns {Promise<Array<LuCI.Network.Device>>} + * @returns {Promise<Array<LuCI.network.Device>>} * Returns a promise resolving to a sorted array of `Device` class * instances describing the network devices found on the system. */ @@ -2945,14 +2956,14 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { }, /** - * Get a {@link LuCI.Network.WifiDevice WifiDevice} instance describing + * Get a {@link LuCI.network.WifiDevice WifiDevice} instance describing * the given wireless radio. * * @param {string} devname * The configuration name of the wireless radio to lookup, e.g. `radio0` * for the first mac80211 phy on the system. * - * @returns {Promise<null|LuCI.Network.WifiDevice>} + * @returns {Promise<null|LuCI.network.WifiDevice>} * Returns a promise resolving to the `WifiDevice` instance describing * the underlying radio device or `null` if the wireless radio could not * be found. @@ -2971,7 +2982,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { /** * Obtain a list of all configured radio devices. * - * @returns {Promise<Array<LuCI.Network.WifiDevice>>} + * @returns {Promise<Array<LuCI.network.WifiDevice>>} * Returns a promise resolving to an array of `WifiDevice` instances * describing the wireless radios configured in the system. * The order of the array corresponds to the order of the radios in @@ -2992,7 +3003,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { }, /** - * Get a {@link LuCI.Network.WifiNetwork WifiNetwork} instance describing + * Get a {@link LuCI.network.WifiNetwork WifiNetwork} instance describing * the given wireless network. * * @param {string} netname @@ -3001,7 +3012,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * or a Linux network device name like `wlan0` which is resolved to the * corresponding configuration section through `ubus` runtime information. * - * @returns {Promise<null|LuCI.Network.WifiNetwork>} + * @returns {Promise<null|LuCI.network.WifiNetwork>} * Returns a promise resolving to the `WifiNetwork` instance describing * the wireless network or `null` if the corresponding network could not * be found. @@ -3012,10 +3023,10 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { }, /** - * Get an array of all {@link LuCI.Network.WifiNetwork WifiNetwork} + * Get an array of all {@link LuCI.network.WifiNetwork WifiNetwork} * instances describing the wireless networks present on the system. * - * @returns {Promise<Array<LuCI.Network.WifiNetwork>>} + * @returns {Promise<Array<LuCI.network.WifiNetwork>>} * Returns a promise resolving to an array of `WifiNetwork` instances * describing the wireless networks. The array will be empty if no networks * are found. @@ -3045,7 +3056,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * must at least contain a `device` property which is set to the radio * name the new network belongs to. * - * @returns {Promise<null|LuCI.Network.WifiNetwork>} + * @returns {Promise<null|LuCI.network.WifiNetwork>} * Returns a promise resolving to a `WifiNetwork` instance describing * the newly added wireless network or `null` if the given options * were invalid or if the associated radio device could not be found. @@ -3166,7 +3177,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * This function looks up all networks having a default `0.0.0.0/0` route * and returns them as array. * - * @returns {Promise<Array<LuCI.Network.Protocol>>} + * @returns {Promise<Array<LuCI.network.Protocol>>} * Returns a promise resolving to an array of `Protocol` subclass * instances describing the found default route interfaces. */ @@ -3191,7 +3202,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * This function looks up all networks having a default `::/0` route * and returns them as array. * - * @returns {Promise<Array<LuCI.Network.Protocol>>} + * @returns {Promise<Array<LuCI.network.Protocol>>} * Returns a promise resolving to an array of `Protocol` subclass * instances describing the found IPv6 default route interfaces. */ @@ -3215,7 +3226,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * connections and external port labels of a switch. * * @typedef {Object<string, Object|Array>} SwitchTopology - * @memberof LuCI.Network + * @memberof LuCI.network * * @property {Object<number, string>} netdevs * The `netdevs` property points to an object describing the CPU port @@ -3237,11 +3248,11 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { /** * Returns the topologies of all swconfig switches found on the system. * - * @returns {Promise<Object<string, LuCI.Network.SwitchTopology>>} + * @returns {Promise<Object<string, LuCI.network.SwitchTopology>>} * Returns a promise resolving to an object containing the topologies * of each switch. The object keys correspond to the name of the switches * such as `switch0`, the values are - * {@link LuCI.Network.SwitchTopology SwitchTopology} objects describing + * {@link LuCI.network.SwitchTopology SwitchTopology} objects describing * the layout. */ getSwitchTopologies: function() { @@ -3332,7 +3343,7 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { /** * Obtains the the network device name of the given object. * - * @param {LuCI.Network.Protocol|LuCI.Network.Device|LuCI.Network.WifiDevice|LuCI.Network.WifiNetwork|string} obj + * @param {LuCI.network.Protocol|LuCI.network.Device|LuCI.network.WifiDevice|LuCI.network.WifiNetwork|string} obj * The object to get the device name from. * * @returns {null|string} @@ -3361,10 +3372,10 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * * This function aggregates information from various sources such as * DHCP lease databases, ARP and IPv6 neighbour entries, wireless - * association list etc. and returns a {@link LuCI.Network.Hosts Hosts} + * association list etc. and returns a {@link LuCI.network.Hosts Hosts} * class instance describing the found hosts. * - * @returns {Promise<LuCI.Network.Hosts>} + * @returns {Promise<LuCI.network.Hosts>} * Returns a `Hosts` instance describing host known on the system. */ getHostHints: function() { @@ -3376,15 +3387,15 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { /** * @class - * @memberof LuCI.Network + * @memberof LuCI.network * @hideconstructor * @classdesc * - * The `LuCI.Network.Hosts` class encapsulates host information aggregated + * The `LuCI.network.Hosts` class encapsulates host information aggregated * from multiple sources and provides convenience functions to access the * host information by different criteria. */ -Hosts = L.Class.extend(/** @lends LuCI.Network.Hosts.prototype */ { +Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ { __init__: function(hosts) { this.hosts = hosts; }, @@ -3542,7 +3553,7 @@ Hosts = L.Class.extend(/** @lends LuCI.Network.Hosts.prototype */ { /** * @class - * @memberof LuCI.Network + * @memberof LuCI.network * @hideconstructor * @classdesc * @@ -3550,7 +3561,7 @@ Hosts = L.Class.extend(/** @lends LuCI.Network.Hosts.prototype */ { * subclasses which describe logical UCI networks defined by `config * interface` sections in `/etc/config/network`. */ -Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { +Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ { __init__: function(name) { this.sid = name; }, @@ -3627,7 +3638,7 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { * Get the name of this network protocol class. * * This function will be overwritten by subclasses created by - * {@link LuCI.Network#registerProtocol Network.registerProtocol()}. + * {@link LuCI.network#registerProtocol Network.registerProtocol()}. * * @abstract * @returns {string} @@ -3661,7 +3672,7 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { * Get the type of the underlying interface. * * This function actually is a convenience wrapper around - * `proto.get("type")` and is mainly used by other `LuCI.Network` code + * `proto.get("type")` and is mainly used by other `LuCI.network` code * to check whether the interface is declared as bridge in UCI. * * @returns {null|string} @@ -3945,7 +3956,7 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { * * This function will translate the found error codes to human readable * messages using the descriptions registered by - * {@link LuCI.Network#registerErrorCode Network.registerErrorCode()} + * {@link LuCI.network#registerErrorCode Network.registerErrorCode()} * and fall back to `"Unknown error (%s)"` where `%s` is replaced by the * error code in case no translation can be found. * @@ -3996,23 +4007,6 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { return null; }, - /** - * Check function for the protocol handler if a new interface is createable. - * - * This function should be overwritten by protocol specific subclasses. - * - * @abstract - * - * @param {string} ifname - * The name of the interface to be created. - * - * @returns {Promise<null|string>} - * Returns `null` if new interface is createable, else returns (error) message. - */ - isCreateable: function(ifname) { - return Promise.resolve(null); - }, - /** * Checks whether the protocol functionality is installed. * @@ -4146,10 +4140,10 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { /** * Add the given network device to the logical interface. * - * @param {LuCI.Network.Protocol|LuCI.Network.Device|LuCI.Network.WifiDevice|LuCI.Network.WifiNetwork|string} device + * @param {LuCI.network.Protocol|LuCI.network.Device|LuCI.network.WifiDevice|LuCI.network.WifiNetwork|string} device * The object or device name to add to the logical interface. In case the * given argument is not a string, it is resolved though the - * {@link LuCI.Network#getIfnameOf Network.getIfnameOf()} function. + * {@link LuCI.network#getIfnameOf Network.getIfnameOf()} function. * * @returns {boolean} * Returns `true` if the device name has been added or `false` if any @@ -4173,10 +4167,10 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { /** * Remove the given network device from the logical interface. * - * @param {LuCI.Network.Protocol|LuCI.Network.Device|LuCI.Network.WifiDevice|LuCI.Network.WifiNetwork|string} device + * @param {LuCI.network.Protocol|LuCI.network.Device|LuCI.network.WifiDevice|LuCI.network.WifiNetwork|string} device * The object or device name to remove from the logical interface. In case * the given argument is not a string, it is resolved though the - * {@link LuCI.Network#getIfnameOf Network.getIfnameOf()} function. + * {@link LuCI.network#getIfnameOf Network.getIfnameOf()} function. * * @returns {boolean} * Returns `true` if the device name has been added or `false` if any @@ -4206,7 +4200,7 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { * Returns the Linux network device associated with this logical * interface. * - * @returns {LuCI.Network.Device} + * @returns {LuCI.network.Device} * Returns a `Network.Device` class instance representing the * expected Linux network device according to the configuration. */ @@ -4214,7 +4208,7 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { if (this.isVirtual()) { var ifname = '%s-%s'.format(this.getProtocol(), this.sid); _state.isTunnel[this.getProtocol() + '-' + this.sid] = true; - return L.network.instantiateDevice(ifname, this); + return Network.prototype.instantiateDevice(ifname, this); } else if (this.isBridge()) { var ifname = 'br-%s'.format(this.sid); @@ -4226,12 +4220,12 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { for (var i = 0; i < ifnames.length; i++) { var m = ifnames[i].match(/^([^:/]+)/); - return ((m && m[1]) ? L.network.instantiateDevice(m[1], this) : null); + return ((m && m[1]) ? Network.prototype.instantiateDevice(m[1], this) : null); } ifname = getWifiNetidByNetname(this.sid); - return (ifname != null ? L.network.instantiateDevice(ifname[0], this) : null); + return (ifname != null ? Network.prototype.instantiateDevice(ifname[0], this) : null); } }, @@ -4239,33 +4233,33 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { * Returns the layer 2 linux network device currently associated * with this logical interface. * - * @returns {LuCI.Network.Device} + * @returns {LuCI.network.Device} * Returns a `Network.Device` class instance representing the Linux * network device currently associated with the logical interface. */ getL2Device: function() { var ifname = this._ubus('device'); - return (ifname != null ? L.network.instantiateDevice(ifname, this) : null); + return (ifname != null ? Network.prototype.instantiateDevice(ifname, this) : null); }, /** * Returns the layer 3 linux network device currently associated * with this logical interface. * - * @returns {LuCI.Network.Device} + * @returns {LuCI.network.Device} * Returns a `Network.Device` class instance representing the Linux * network device currently associated with the logical interface. */ getL3Device: function() { var ifname = this._ubus('l3_device'); - return (ifname != null ? L.network.instantiateDevice(ifname, this) : null); + return (ifname != null ? Network.prototype.instantiateDevice(ifname, this) : null); }, /** * Returns a list of network sub-devices associated with this logical * interface. * - * @returns {null|Array<LuCI.Network.Device>} + * @returns {null|Array<LuCI.network.Device>} * Returns an array of of `Network.Device` class instances representing * the sub-devices attached to this logical interface or `null` if the * logical interface does not support sub-devices, e.g. because it is @@ -4285,7 +4279,7 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { var m = ifnames[i].match(/^([^:/]+)/); if (m != null) - rv.push(L.network.instantiateDevice(m[1], this)); + rv.push(Network.prototype.instantiateDevice(m[1], this)); } var uciWifiIfaces = uci.sections('wireless', 'wifi-iface'); @@ -4303,7 +4297,7 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { var netid = getWifiNetidBySid(uciWifiIfaces[i]['.name']); if (netid != null) - rv.push(L.network.instantiateDevice(netid[0], this)); + rv.push(Network.prototype.instantiateDevice(netid[0], this)); } } @@ -4316,10 +4310,10 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { * Checks whether this logical interface contains the given device * object. * - * @param {LuCI.Network.Protocol|LuCI.Network.Device|LuCI.Network.WifiDevice|LuCI.Network.WifiNetwork|string} device + * @param {LuCI.network.Protocol|LuCI.network.Device|LuCI.network.WifiDevice|LuCI.network.WifiNetwork|string} device * The object or device name to check. In case the given argument is not * a string, it is resolved though the - * {@link LuCI.Network#getIfnameOf Network.getIfnameOf()} function. + * {@link LuCI.network#getIfnameOf Network.getIfnameOf()} function. * * @returns {boolean} * Returns `true` when this logical interface contains the given network @@ -4378,14 +4372,14 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { /** * @class - * @memberof LuCI.Network + * @memberof LuCI.network * @hideconstructor * @classdesc * * A `Network.Device` class instance represents an underlying Linux network * device and allows querying device details such as packet statistics or MTU. */ -Device = L.Class.extend(/** @lends LuCI.Network.Device.prototype */ { +Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ { __init__: function(ifname, network) { var wif = getWifiSidByIfname(ifname); @@ -4565,7 +4559,7 @@ Device = L.Class.extend(/** @lends LuCI.Network.Device.prototype */ { /** * Get the associated bridge ports of the device. * - * @returns {null|Array<LuCI.Network.Device>} + * @returns {null|Array<LuCI.network.Device>} * Returns an array of `Network.Device` instances representing the ports * (slave interfaces) of the bridge or `null` when this device isn't * a Linux bridge. @@ -4578,7 +4572,7 @@ Device = L.Class.extend(/** @lends LuCI.Network.Device.prototype */ { return null; for (var i = 0; i < br.ifnames.length; i++) - rv.push(L.network.instantiateDevice(br.ifnames[i].name)); + rv.push(Network.prototype.instantiateDevice(br.ifnames[i].name)); rv.sort(deviceSort); @@ -4694,7 +4688,7 @@ Device = L.Class.extend(/** @lends LuCI.Network.Device.prototype */ { /** * Get the primary logical interface this device is assigned to. * - * @returns {null|LuCI.Network.Protocol} + * @returns {null|LuCI.network.Protocol} * Returns a `Network.Protocol` instance representing the logical * interface this device is attached to or `null` if it is not * assigned to any logical interface. @@ -4706,7 +4700,7 @@ Device = L.Class.extend(/** @lends LuCI.Network.Device.prototype */ { /** * Get the logical interfaces this device is assigned to. * - * @returns {Array<LuCI.Network.Protocol>} + * @returns {Array<LuCI.network.Protocol>} * Returns an array of `Network.Protocol` instances representing the * logical interfaces this device is assigned to. */ @@ -4729,7 +4723,7 @@ Device = L.Class.extend(/** @lends LuCI.Network.Device.prototype */ { /** * Get the related wireless network this device is related to. * - * @returns {null|LuCI.Network.WifiNetwork} + * @returns {null|LuCI.network.WifiNetwork} * Returns a `Network.WifiNetwork` instance representing the wireless * network corresponding to this network device or `null` if this device * is not a wireless device. @@ -4741,7 +4735,7 @@ Device = L.Class.extend(/** @lends LuCI.Network.Device.prototype */ { /** * @class - * @memberof LuCI.Network + * @memberof LuCI.network * @hideconstructor * @classdesc * @@ -4749,7 +4743,7 @@ Device = L.Class.extend(/** @lends LuCI.Network.Device.prototype */ { * present on the system and provides wireless capability information as * well as methods for enumerating related wireless networks. */ -WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ { +WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ { __init__: function(name, radiostate) { var uciWifiDevice = uci.get('wireless', name); @@ -4901,8 +4895,8 @@ WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ { * A wireless scan result object describes a neighbouring wireless * network found in the vincinity. * - * @typedef {Object<string, number|string|LuCI.Network.WifiEncryption>} WifiScanResult - * @memberof LuCI.Network + * @typedef {Object<string, number|string|LuCI.network.WifiEncryption>} WifiScanResult + * @memberof LuCI.network * * @property {string} ssid * The SSID / Mesh ID of the network. @@ -4927,7 +4921,7 @@ WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ { * The maximum possible quality level of the signal, can be used in * conjunction with `quality` to calculate a quality percentage. * - * @property {LuCI.Network.WifiEncryption} encryption + * @property {LuCI.network.WifiEncryption} encryption * The encryption used by the wireless network. */ @@ -4935,7 +4929,7 @@ WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ { * Trigger a wireless scan on this radio device and obtain a list of * nearby networks. * - * @returns {Promise<Array<LuCI.Network.WifiScanResult>>} + * @returns {Promise<Array<LuCI.network.WifiScanResult>>} * Returns a promise resolving to an array of scan result objects * describing the networks found in the vincinity. */ @@ -4966,14 +4960,14 @@ WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ { * or a Linux network device name like `wlan0` which is resolved to the * corresponding configuration section through `ubus` runtime information. * - * @returns {Promise<LuCI.Network.WifiNetwork>} + * @returns {Promise<LuCI.network.WifiNetwork>} * Returns a promise resolving to a `Network.WifiNetwork` instance * representing the wireless network and rejecting with `null` if * the given network could not be found or is not associated with * this radio device. */ getWifiNetwork: function(network) { - return L.network.getWifiNetwork(network).then(L.bind(function(networkInstance) { + return Network.prototype.getWifiNetwork(network).then(L.bind(function(networkInstance) { var uciWifiIface = (networkInstance.sid ? uci.get('wireless', networkInstance.sid) : null); if (uciWifiIface == null || uciWifiIface['.type'] != 'wifi-iface' || uciWifiIface.device != this.sid) @@ -4986,13 +4980,13 @@ WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ { /** * Get all wireless networks associated with this wireless radio device. * - * @returns {Promise<Array<LuCI.Network.WifiNetwork>>} + * @returns {Promise<Array<LuCI.network.WifiNetwork>>} * Returns a promise resolving to an array of `Network.WifiNetwork` * instances respresenting the wireless networks associated with this * radio device. */ getWifiNetworks: function() { - return L.network.getWifiNetworks().then(L.bind(function(networks) { + return Network.prototype.getWifiNetworks().then(L.bind(function(networks) { var rv = []; for (var i = 0; i < networks.length; i++) @@ -5010,7 +5004,7 @@ WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ { * @param {Object<string, string|string[]>} [options] * The options to set for the newly added wireless network. * - * @returns {Promise<null|LuCI.Network.WifiNetwork>} + * @returns {Promise<null|LuCI.network.WifiNetwork>} * Returns a promise resolving to a `WifiNetwork` instance describing * the newly added wireless network or `null` if the given options * were invalid. @@ -5021,7 +5015,7 @@ WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ { options.device = this.sid; - return L.network.addWifiNetwork(options); + return Network.prototype.addWifiNetwork(options); }, /** @@ -5064,7 +5058,7 @@ WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ { /** * @class - * @memberof LuCI.Network + * @memberof LuCI.network * @hideconstructor * @classdesc * @@ -5073,7 +5067,7 @@ WifiDevice = L.Class.extend(/** @lends LuCI.Network.WifiDevice.prototype */ { * the runtime state of the network. Most radio devices support multiple * such networks in parallel. */ -WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { +WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */ { __init__: function(sid, radioname, radiostate, netid, netstate, hostapd) { this.sid = sid; this.netid = netid; @@ -5256,7 +5250,7 @@ WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { /** * Get the corresponding wifi radio device. * - * @returns {null|LuCI.Network.WifiDevice} + * @returns {null|LuCI.network.WifiDevice} * Returns a `Network.WifiDevice` instance representing the corresponding * wifi radio device or `null` if the related radio device could not be * found. @@ -5267,7 +5261,7 @@ WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { if (radioname == null) return Promise.reject(); - return L.network.getWifiDevice(radioname); + return Network.prototype.getWifiDevice(radioname); }, /** @@ -5379,8 +5373,8 @@ WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { * A wireless peer entry describes the properties of a remote wireless * peer associated with a local network. * - * @typedef {Object<string, boolean|number|string|LuCI.Network.WifiRateEntry>} WifiPeerEntry - * @memberof LuCI.Network + * @typedef {Object<string, boolean|number|string|LuCI.network.WifiRateEntry>} WifiPeerEntry + * @memberof LuCI.network * * @property {string} mac * The MAC address (BSSID). @@ -5478,10 +5472,10 @@ WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { * - `DEEP SLEEP` * - `UNKNOWN` * - * @property {LuCI.Network.WifiRateEntry} rx + * @property {LuCI.network.WifiRateEntry} rx * Describes the receiving wireless rate from the peer. * - * @property {LuCI.Network.WifiRateEntry} tx + * @property {LuCI.network.WifiRateEntry} tx * Describes the transmitting wireless rate to the peer. */ @@ -5490,7 +5484,7 @@ WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { * transmission rate to or from a peer. * * @typedef {Object<string, boolean|number>} WifiRateEntry - * @memberof LuCI.Network + * @memberof LuCI.network * * @property {number} [drop_misc] * The amount of received misc. packages that have been dropped, e.g. @@ -5547,7 +5541,7 @@ WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { /** * Fetch the list of associated peers. * - * @returns {Promise<Array<LuCI.Network.WifiPeerEntry>>} + * @returns {Promise<Array<LuCI.network.WifiPeerEntry>>} * Returns a promise resolving to an array of wireless peers associated * with this network. */ @@ -5735,7 +5729,7 @@ WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { /** * Get the primary logical interface this wireless network is attached to. * - * @returns {null|LuCI.Network.Protocol} + * @returns {null|LuCI.network.Protocol} * Returns a `Network.Protocol` instance representing the logical * interface or `null` if this network is not attached to any logical * interface. @@ -5747,7 +5741,7 @@ WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { /** * Get the logical interfaces this wireless network is attached to. * - * @returns {Array<LuCI.Network.Protocol>} + * @returns {Array<LuCI.network.Protocol>} * Returns an array of `Network.Protocol` instances representing the * logical interfaces this wireless network is attached to. */ @@ -5761,7 +5755,7 @@ WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { if (uciInterface == null || uciInterface['.type'] != 'interface') continue; - networks.push(L.network.instantiateNetwork(networkNames[i])); + networks.push(Network.prototype.instantiateNetwork(networkNames[i])); } networks.sort(networkSort); @@ -5772,12 +5766,12 @@ WifiNetwork = L.Class.extend(/** @lends LuCI.Network.WifiNetwork.prototype */ { /** * Get the associated Linux network device. * - * @returns {LuCI.Network.Device} + * @returns {LuCI.network.Device} * Returns a `Network.Device` instance representing the Linux network * device associted with this wireless network. */ getDevice: function() { - return L.network.instantiateDevice(this.getIfname()); + return Network.prototype.instantiateDevice(this.getIfname()); }, /** @@ -5844,7 +5838,7 @@ return Network;
      - Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) + Documentation generated by JSDoc 3.6.3 on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time)
      diff --git a/docs/jsapi/rpc.js.html b/docs/jsapi/rpc.js.html index 983f091fb..48e5a95e9 100644 --- a/docs/jsapi/rpc.js.html +++ b/docs/jsapi/rpc.js.html @@ -43,8 +43,18 @@ Members +
    • Class
    • + +
    • dom
    • +
    • env
    • +
    • Poll
    • + +
    • Request
    • + +
    • view
    • +
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -1693,6 +1701,8 @@
      'use strict';
      +'require baseclass';
      +'require request';
       
       var rpcRequestID = 1,
           rpcSessionID = L.env.sessionid || '00000000000000000000000000000000',
      @@ -1708,7 +1718,7 @@ var rpcRequestID = 1,
        * The `LuCI.rpc` class provides high level ubus JSON-RPC abstractions
        * and means for listing and invoking remove RPC methods.
        */
      -return L.Class.extend(/** @lends LuCI.rpc.prototype */ {
      +return baseclass.extend(/** @lends LuCI.rpc.prototype */ {
       	/* privates */
       	call: function(req, cb, nobatch) {
       		var q = '';
      @@ -1729,7 +1739,7 @@ return L.Class.extend(/** @lends LuCI.rpc.prototype */ {
       			q += '/%s.%s'.format(req.params[1], req.params[2]);
       		}
       
      -		return L.Request.post(rpcBaseURL + q, req, {
      +		return request.post(rpcBaseURL + q, req, {
       			timeout: (L.env.rpctimeout || 20) * 1000,
       			nobatch: nobatch,
       			credentials: true
      @@ -2181,7 +2191,7 @@ return L.Class.extend(/** @lends LuCI.rpc.prototype */ {
               
       
               
      - Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) + Documentation generated by JSDoc 3.6.3 on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time)
      diff --git a/docs/jsapi/uci.js.html b/docs/jsapi/uci.js.html index 1f320f98a..fe3fd48b9 100644 --- a/docs/jsapi/uci.js.html +++ b/docs/jsapi/uci.js.html @@ -43,8 +43,18 @@ Members +
    • Class
    • + +
    • dom
    • +
    • env
    • +
    • Poll
    • + +
    • Request
    • + +
    • view
    • +
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -1694,6 +1702,7 @@
      'use strict';
       'require rpc';
      +'require baseclass';
       
       /**
        * @class uci
      @@ -1706,7 +1715,7 @@
        * manipulation layer on top to allow for synchroneous operations on
        * UCI configuration data.
        */
      -return L.Class.extend(/** @lends LuCI.uci.prototype */ {
      +return baseclass.extend(/** @lends LuCI.uci.prototype */ {
       	__init__: function() {
       		this.state = {
       			newidx:  0,
      @@ -2647,7 +2656,7 @@ return L.Class.extend(/** @lends LuCI.uci.prototype */ {
               
       
               
      - Documentation generated by JSDoc 3.6.3 on Tue Mar 31 2020 21:30:33 GMT+0200 (Central European Summer Time) + Documentation generated by JSDoc 3.6.3 on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time)
      diff --git a/docs/jsapi/ui.js.html b/docs/jsapi/ui.js.html index 96b3006f0..015a955a2 100644 --- a/docs/jsapi/ui.js.html +++ b/docs/jsapi/ui.js.html @@ -43,8 +43,18 @@ Members +
    • Class
    • + +
    • dom
    • +
    • env
    • +
    • Poll
    • + +
    • Request
    • + +
    • view
    • +
      @@ -106,9 +116,9 @@
  • -
  • +
  • - LuCI.Class + LuCI.baseclass
      @@ -246,9 +256,9 @@
  • -
  • +
  • - LuCI.Headers + LuCI.headers
      @@ -274,9 +284,9 @@
  • -
  • +
  • - LuCI.Network + LuCI.network
      @@ -368,9 +378,9 @@
  • -
  • +
  • - LuCI.Network.Device + LuCI.network.Device
      @@ -436,9 +446,9 @@
  • -
  • +
  • - LuCI.Network.Hosts + LuCI.network.Hosts
      @@ -476,9 +486,9 @@
  • -
  • +
  • - LuCI.Network.Protocol + LuCI.network.Protocol
      @@ -580,9 +588,9 @@
  • -
  • +
  • - LuCI.Network.WifiDevice + LuCI.network.WifiDevice
      @@ -630,9 +638,9 @@
  • -
  • +
  • - LuCI.Network.WifiNetwork + LuCI.network.WifiNetwork
      @@ -728,9 +736,9 @@
  • -
  • +
  • - LuCI.Poll + LuCI.poll
      @@ -762,9 +770,9 @@
  • -
  • +
  • - LuCI.Request + LuCI.request
      @@ -804,9 +812,9 @@
  • -
  • +
  • - LuCI.Request.poll + LuCI.request.poll
      @@ -842,26 +850,26 @@
  • -
  • +
  • - LuCI.Response + LuCI.response
      @@ -1646,9 +1654,9 @@
  • -
  • +
  • - LuCI.XHR + LuCI.xhr
      @@ -1693,9 +1701,13 @@
      'use strict';
      +'require validation';
      +'require baseclass';
      +'require request';
      +'require poll';
      +'require dom';
       'require rpc';
       'require uci';
      -'require validation';
       'require fs';
       
       var modalDiv = null,
      @@ -1723,7 +1735,7 @@ var modalDiv = null,
        * it in external JavaScript, use `L.require("ui").then(...)` and access the
        * `AbstractElement` property of the class instance value.
        */
      -var UIElement = L.Class.extend(/** @lends LuCI.ui.AbstractElement.prototype */ {
      +var UIElement = baseclass.extend(/** @lends LuCI.ui.AbstractElement.prototype */ {
       	/**
       	 * @typedef {Object} InitOptions
       	 * @memberof LuCI.ui.AbstractElement
      @@ -1742,7 +1754,7 @@ var UIElement = L.Class.extend(/** @lends LuCI.ui.AbstractElement.prototype */ {
       	 * @property {string} [datatype=string]
       	 * An expression describing the input data validation constraints.
       	 * It defaults to `string` which will allow any value.
      -	 * See{@link LuCI.validation} for details on the expression format.
      +	 * See {@link LuCI.validation} for details on the expression format.
       	 *
       	 * @property {function} [validator]
       	 * Specifies a custom validator function which is invoked after the
      @@ -1763,7 +1775,7 @@ var UIElement = L.Class.extend(/** @lends LuCI.ui.AbstractElement.prototype */ {
       	 * an array of strings or `null` for unset values.
       	 */
       	getValue: function() {
      -		if (L.dom.matches(this.node, 'select') || L.dom.matches(this.node, 'input'))
      +		if (dom.matches(this.node, 'select') || dom.matches(this.node, 'input'))
       			return this.node.value;
       
       		return null;
      @@ -1781,7 +1793,7 @@ var UIElement = L.Class.extend(/** @lends LuCI.ui.AbstractElement.prototype */ {
       	 * or `null` values.
       	 */
       	setValue: function(value) {
      -		if (L.dom.matches(this.node, 'select') || L.dom.matches(this.node, 'input'))
      +		if (dom.matches(this.node, 'select') || dom.matches(this.node, 'input'))
       			this.node.value = value;
       	},
       
      @@ -1879,7 +1891,7 @@ var UIElement = L.Class.extend(/** @lends LuCI.ui.AbstractElement.prototype */ {
       		if (!datatype && !validate)
       			return;
       
      -		this.vfunc = L.ui.addValidator.apply(L.ui, [
      +		this.vfunc = UI.prototype.addValidator.apply(UI.prototype, [
       			targetNode, datatype || 'string',
       			optional, validate
       		].concat(events));
      @@ -2041,7 +2053,7 @@ var UITextfield = UIElement.extend(/** @lends LuCI.ui.Textfield.prototype */ {
       		this.setUpdateEvents(inputEl, 'keyup', 'blur');
       		this.setChangeEvents(inputEl, 'change');
       
      -		L.dom.bindClassInstance(frameEl, this);
      +		dom.bindClassInstance(frameEl, this);
       
       		return frameEl;
       	},
      @@ -2157,7 +2169,7 @@ var UITextarea = UIElement.extend(/** @lends LuCI.ui.Textarea.prototype */ {
       		this.setUpdateEvents(inputEl, 'keyup', 'blur');
       		this.setChangeEvents(inputEl, 'change');
       
      -		L.dom.bindClassInstance(frameEl, this);
      +		dom.bindClassInstance(frameEl, this);
       
       		return frameEl;
       	},
      @@ -2262,7 +2274,7 @@ var UICheckbox = UIElement.extend(/** @lends LuCI.ui.Checkbox.prototype */ {
       		this.setUpdateEvents(frameEl.lastElementChild.previousElementSibling, 'click', 'blur');
       		this.setChangeEvents(frameEl.lastElementChild.previousElementSibling, 'change');
       
      -		L.dom.bindClassInstance(frameEl, this);
      +		dom.bindClassInstance(frameEl, this);
       
       		return frameEl;
       	},
      @@ -2457,7 +2469,7 @@ var UISelect = UIElement.extend(/** @lends LuCI.ui.Select.prototype */ {
       			}
       		}
       
      -		L.dom.bindClassInstance(frameEl, this);
      +		dom.bindClassInstance(frameEl, this);
       
       		return frameEl;
       	},
      @@ -2670,7 +2682,7 @@ var UIDropdown = UIElement.extend(/** @lends LuCI.ui.Dropdown.prototype */ {
       		for (var i = 0; i < keys.length; i++) {
       			var label = this.choices[keys[i]];
       
      -			if (L.dom.elem(label))
      +			if (dom.elem(label))
       				label = label.cloneNode(true);
       
       			sb.lastElementChild.appendChild(E('li', {
      @@ -2689,8 +2701,8 @@ var UIDropdown = UIElement.extend(/** @lends LuCI.ui.Dropdown.prototype */ {
       			});
       
       			if (this.options.datatype || this.options.validate)
      -				L.ui.addValidator(createEl, this.options.datatype || 'string',
      -				                  true, this.options.validate, 'blur', 'keyup');
      +				UI.prototype.addValidator(createEl, this.options.datatype || 'string',
      +				                          true, this.options.validate, 'blur', 'keyup');
       
       			sb.lastElementChild.appendChild(E('li', { 'data-value': '-' }, createEl));
       		}
      @@ -2773,7 +2785,7 @@ var UIDropdown = UIElement.extend(/** @lends LuCI.ui.Dropdown.prototype */ {
       		else
       			sb.removeAttribute('empty');
       
      -		L.dom.content(more, (ndisplay == this.options.display_items)
      +		dom.content(more, (ndisplay == this.options.display_items)
       			? (this.options.select_placeholder || this.options.placeholder) : '···');
       
       
      @@ -2812,7 +2824,7 @@ var UIDropdown = UIElement.extend(/** @lends LuCI.ui.Dropdown.prototype */ {
       		this.setUpdateEvents(sb, 'cbi-dropdown-open', 'cbi-dropdown-close');
       		this.setChangeEvents(sb, 'cbi-dropdown-change', 'cbi-dropdown-close');
       
      -		L.dom.bindClassInstance(sb, this);
      +		dom.bindClassInstance(sb, this);
       
       		return sb;
       	},
      @@ -3037,7 +3049,7 @@ var UIDropdown = UIElement.extend(/** @lends LuCI.ui.Dropdown.prototype */ {
       			else
       				sb.removeAttribute('empty');
       
      -			L.dom.content(more, (ndisplay === this.options.display_items)
      +			dom.content(more, (ndisplay === this.options.display_items)
       				? (this.options.select_placeholder || this.options.placeholder) : '···');
       		}
       		else {
      @@ -3711,7 +3723,7 @@ var UIComboButton = UIDropdown.extend(/** @lends LuCI.ui.ComboButton.prototype *
       		var sb = ev.currentTarget,
       		    t = ev.target;
       
      -		if (sb.hasAttribute('open') || L.dom.matches(t, '.cbi-dropdown > span.open'))
      +		if (sb.hasAttribute('open') || dom.matches(t, '.cbi-dropdown > span.open'))
       			return UIDropdown.prototype.handleClick.apply(this, arguments);
       
       		if (this.options.click)
      @@ -3827,14 +3839,14 @@ var UIDynamicList = UIElement.extend(/** @lends LuCI.ui.DynamicList.prototype */
       			dl.lastElementChild.appendChild(E('div', { 'class': 'btn cbi-button cbi-button-add' }, '+'));
       
       			if (this.options.datatype || this.options.validate)
      -				L.ui.addValidator(inputEl, this.options.datatype || 'string',
      -				                  true, this.options.validate, 'blur', 'keyup');
      +				UI.prototype.addValidator(inputEl, this.options.datatype || 'string',
      +				                          true, this.options.validate, 'blur', 'keyup');
       		}
       
       		for (var i = 0; i < this.values.length; i++) {
       			var label = this.choices ? this.choices[this.values[i]] : null;
       
      -			if (L.dom.elem(label))
      +			if (dom.elem(label))
       				label = label.cloneNode(true);
       
       			this.addItem(dl, this.values[i], label);
      @@ -3854,7 +3866,7 @@ var UIDynamicList = UIElement.extend(/** @lends LuCI.ui.DynamicList.prototype */
       		this.setUpdateEvents(dl, 'cbi-dynlist-change');
       		this.setChangeEvents(dl, 'cbi-dynlist-change');
       
      -		L.dom.bindClassInstance(dl, this);
      +		dom.bindClassInstance(dl, this);
       
       		return dl;
       	},
      @@ -4066,7 +4078,7 @@ var UIDynamicList = UIElement.extend(/** @lends LuCI.ui.DynamicList.prototype */
       	 */
       	addChoices: function(values, labels) {
       		var dl = this.node.lastElementChild.firstElementChild;
      -		L.dom.callClassMethod(dl, 'addChoices', values, labels);
      +		dom.callClassMethod(dl, 'addChoices', values, labels);
       	},
       
       	/**
      @@ -4079,7 +4091,7 @@ var UIDynamicList = UIElement.extend(/** @lends LuCI.ui.DynamicList.prototype */
       	 */
       	clearChoices: function() {
       		var dl = this.node.lastElementChild.firstElementChild;
      -		L.dom.callClassMethod(dl, 'clearChoices');
      +		dom.callClassMethod(dl, 'clearChoices');
       	}
       });
       
      @@ -4133,7 +4145,7 @@ var UIHiddenfield = UIElement.extend(/** @lends LuCI.ui.Hiddenfield.prototype */
       	bind: function(hiddenEl) {
       		this.node = hiddenEl;
       
      -		L.dom.bindClassInstance(hiddenEl, this);
      +		dom.bindClassInstance(hiddenEl, this);
       
       		return hiddenEl;
       	},
      @@ -4229,7 +4241,7 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       		this.setUpdateEvents(browserEl, 'cbi-fileupload-select', 'cbi-fileupload-cancel');
       		this.setChangeEvents(browserEl, 'cbi-fileupload-select', 'cbi-fileupload-cancel');
       
      -		L.dom.bindClassInstance(browserEl, this);
      +		dom.bindClassInstance(browserEl, this);
       
       		return browserEl;
       	},
      @@ -4252,7 +4264,7 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       			return this.bind(E('div', { 'id': this.options.id }, [
       				E('button', {
       					'class': 'btn',
      -					'click': L.ui.createHandlerFn(this, 'handleFileBrowser')
      +					'click': UI.prototype.createHandlerFn(this, 'handleFileBrowser')
       				}, label),
       				E('div', {
       					'class': 'cbi-filebrowser'
      @@ -4351,7 +4363,7 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       		data.append('filename', path + '/' + filename);
       		data.append('filedata', fileinput.files[0]);
       
      -		return L.Request.post(L.env.cgi_base + '/cgi-upload', data, {
      +		return request.post(L.env.cgi_base + '/cgi-upload', data, {
       			progress: L.bind(function(btn, ev) {
       				btn.firstChild.data = '%.2f%%'.format((ev.loaded / ev.total) * 100);
       			}, this, ev.target)
      @@ -4383,7 +4395,7 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       			    hidden = this.node.lastElementChild;
       
       			if (path == hidden.value) {
      -				L.dom.content(button, _('Select file…'));
      +				dom.content(button, _('Select file…'));
       				hidden.value = '';
       			}
       
      @@ -4435,7 +4447,7 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       				E('div', {}, E('input', { 'type': 'text', 'placeholder': _('Filename') })),
       				E('button', {
       					'class': 'btn cbi-button-save',
      -					'click': L.ui.createHandlerFn(this, 'handleUpload', path, list),
      +					'click': UI.prototype.createHandlerFn(this, 'handleUpload', path, list),
       					'disabled': true
       				}, [ _('Upload file') ])
       			])
      @@ -4472,7 +4484,7 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       					E('a', {
       						'href': '#',
       						'style': selected ? 'font-weight:bold' : null,
      -						'click': L.ui.createHandlerFn(this, 'handleSelect',
      +						'click': UI.prototype.createHandlerFn(this, 'handleSelect',
       							entrypath, list[i].type != 'directory' ? list[i] : null)
       					}, '%h'.format(list[i].name))
       				]),
      @@ -4488,11 +4500,11 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       				E('div', [
       					selected ? E('button', {
       						'class': 'btn',
      -						'click': L.ui.createHandlerFn(this, 'handleReset')
      +						'click': UI.prototype.createHandlerFn(this, 'handleReset')
       					}, [ _('Deselect') ]) : '',
       					this.options.enable_remove ? E('button', {
       						'class': 'btn cbi-button-negative',
      -						'click': L.ui.createHandlerFn(this, 'handleDelete', entrypath, list[i])
      +						'click': UI.prototype.createHandlerFn(this, 'handleDelete', entrypath, list[i])
       					}, [ _('Delete') ]) : ''
       				])
       			]));
      @@ -4506,16 +4518,16 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       
       		for (var i = 0; i < dirs.length; i++) {
       			cur = cur ? cur + '/' + dirs[i] : dirs[i];
      -			L.dom.append(breadcrumb, [
      +			dom.append(breadcrumb, [
       				i ? ' » ' : '',
       				E('a', {
       					'href': '#',
      -					'click': L.ui.createHandlerFn(this, 'handleSelect', cur || '/', null)
      +					'click': UI.prototype.createHandlerFn(this, 'handleSelect', cur || '/', null)
       				}, dirs[i] != '' ? '%h'.format(dirs[i]) : E('em', '(root)')),
       			]);
       		}
       
      -		L.dom.content(container, [
      +		dom.content(container, [
       			breadcrumb,
       			rows,
       			E('div', { 'class': 'right' }, [
      @@ -4523,7 +4535,7 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       				E('a', {
       					'href': '#',
       					'class': 'btn',
      -					'click': L.ui.createHandlerFn(this, 'handleCancel')
      +					'click': UI.prototype.createHandlerFn(this, 'handleCancel')
       				}, _('Cancel'))
       			]),
       		]);
      @@ -4548,18 +4560,18 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       		    hidden = this.node.lastElementChild;
       
       		hidden.value = '';
      -		L.dom.content(button, _('Select file…'));
      +		dom.content(button, _('Select file…'));
       
       		this.handleCancel(ev);
       	},
       
       	/** @private */
       	handleSelect: function(path, fileStat, ev) {
      -		var browser = L.dom.parent(ev.target, '.cbi-filebrowser'),
      +		var browser = dom.parent(ev.target, '.cbi-filebrowser'),
       		    ul = browser.querySelector('ul');
       
       		if (fileStat == null) {
      -			L.dom.content(ul, E('em', { 'class': 'spinning' }, _('Loading directory contents…')));
      +			dom.content(ul, E('em', { 'class': 'spinning' }, _('Loading directory contents…')));
       			L.resolveDefault(fs.list(path), []).then(L.bind(this.renderListing, this, browser, path));
       		}
       		else {
      @@ -4568,7 +4580,7 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       
       			path = this.canonicalizePath(path);
       
      -			L.dom.content(button, [
      +			dom.content(button, [
       				this.iconForType(fileStat.type),
       				' %s (%1000mB)'.format(this.truncatePath(path), fileStat.size)
       			]);
      @@ -4595,7 +4607,7 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
       
       		return L.resolveDefault(fs.list(path), []).then(L.bind(function(button, browser, path, list) {
       			document.querySelectorAll('.cbi-filebrowser.open').forEach(function(browserEl) {
      -				L.dom.findClassInstance(browserEl).handleCancel(ev);
      +				dom.findClassInstance(browserEl).handleCancel(ev);
       			});
       
       			button.style.display = 'none';
      @@ -4626,14 +4638,14 @@ var UIFileUpload = UIElement.extend(/** @lends LuCI.ui.FileUpload.prototype */ {
        * To import the class in views, use `'require ui'`, to import it in
        * external JavaScript, use `L.require("ui").then(...)`.
        */
      -return L.Class.extend(/** @lends LuCI.ui.prototype */ {
      +var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
       	__init__: function() {
       		modalDiv = document.body.appendChild(
      -			L.dom.create('div', { id: 'modal_overlay' },
      -				L.dom.create('div', { class: 'modal', role: 'dialog', 'aria-modal': true })));
      +			dom.create('div', { id: 'modal_overlay' },
      +				dom.create('div', { class: 'modal', role: 'dialog', 'aria-modal': true })));
       
       		tooltipDiv = document.body.appendChild(
      -			L.dom.create('div', { class: 'cbi-tooltip' }));
      +			dom.create('div', { class: 'cbi-tooltip' }));
       
       		/* setup old aliases */
       		L.showModal = this.showModal;
      @@ -4671,7 +4683,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       	 * @param {*} contents
       	 * The contents to add to the modal dialog. This should be a DOM node or
       	 * a document fragment in most cases. The value is passed as-is to the
      -	 * `L.dom.content()` function - refer to its documentation for applicable
      +	 * `dom.content()` function - refer to its documentation for applicable
       	 * values.
       	 *
       	 * @param {...string} [classes]
      @@ -4689,8 +4701,8 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       		for (var i = 2; i < arguments.length; i++)
       			dlg.classList.add(arguments[i]);
       
      -		L.dom.content(dlg, L.dom.create('h4', {}, title));
      -		L.dom.append(dlg, children);
      +		dom.content(dlg, dom.create('h4', {}, title));
      +		dom.append(dlg, children);
       
       		document.body.classList.add('modal-overlay-active');
       
      @@ -4786,7 +4798,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       	 * @param {*} contents
       	 * The contents to add to the notification banner. This should be a DOM
       	 * node or a document fragment in most cases. The value is passed as-is
      -	 * to the `L.dom.content()` function - refer to its documentation for
      +	 * to the `dom.content()` function - refer to its documentation for
       	 * applicable values.
       	 *
       	 * @param {...string} [classes]
      @@ -4813,7 +4825,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       					'class': 'btn',
       					'style': 'margin-left:auto; margin-top:auto',
       					'click': function(ev) {
      -						L.dom.parent(ev.target, '.alert-message').classList.add('fade-out');
      +						dom.parent(ev.target, '.alert-message').classList.add('fade-out');
       					},
       
       				}, [ _('Dismiss') ])
      @@ -4821,9 +4833,9 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       		]);
       
       		if (title != null)
      -			L.dom.append(msg.firstElementChild, E('h4', {}, title));
      +			dom.append(msg.firstElementChild, E('h4', {}, title));
       
      -		L.dom.append(msg.firstElementChild, children);
      +		dom.append(msg.firstElementChild, children);
       
       		for (var i = 2; i < arguments.length; i++)
       			msg.classList.add(arguments[i]);
      @@ -4965,11 +4977,11 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       				]));
       
       				if ((i+2) < items.length)
      -					children.push(L.dom.elem(sep) ? sep.cloneNode(true) : sep);
      +					children.push(dom.elem(sep) ? sep.cloneNode(true) : sep);
       			}
       		}
       
      -		L.dom.content(node, children);
      +		dom.content(node, children);
       
       		return node;
       	},
      @@ -4989,7 +5001,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       	 * external JavaScript, use `L.require("ui").then(...)` and access the
       	 * `tabs` property of the class instance value.
       	 */
      -	tabs: L.Class.singleton(/* @lends LuCI.ui.tabs.prototype */ {
      +	tabs: baseclass.singleton(/* @lends LuCI.ui.tabs.prototype */ {
       		/** @private */
       		init: function() {
       			var groups = [], prevGroup = null, currGroup = null;
      @@ -4997,7 +5009,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       			document.querySelectorAll('[data-tab]').forEach(function(tab) {
       				var parent = tab.parentNode;
       
      -				if (L.dom.matches(tab, 'li') && L.dom.matches(parent, 'ul.cbi-tabmenu'))
      +				if (dom.matches(tab, 'li') && dom.matches(parent, 'ul.cbi-tabmenu'))
       					return;
       
       				if (!parent.hasAttribute('data-tab-group'))
      @@ -5115,7 +5127,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       		 * Returns `true` if the pane is empty, else `false`.
       		 */
       		isEmptyPane: function(pane) {
      -			return L.dom.isEmpty(pane, function(n) { return n.classList.contains('cbi-tab-descr') });
      +			return dom.isEmpty(pane, function(n) { return n.classList.contains('cbi-tab-descr') });
       		},
       
       		/** @private */
      @@ -5224,11 +5236,11 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       			});
       
       			group.childNodes.forEach(function(pane) {
      -				if (L.dom.matches(pane, '[data-tab]')) {
      +				if (dom.matches(pane, '[data-tab]')) {
       					if (pane.getAttribute('data-tab') === name) {
       						pane.setAttribute('data-tab-active', 'true');
       						pane.dispatchEvent(new CustomEvent('cbi-tab-active', { detail: { tab: name } }));
      -						L.ui.tabs.setActiveTabId(pane, index);
      +						UI.prototype.tabs.setActiveTabId(pane, index);
       					}
       					else {
       						pane.setAttribute('data-tab-active', 'false');
      @@ -5270,7 +5282,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       	 */
       	uploadFile: function(path, progressStatusNode) {
       		return new Promise(function(resolveFn, rejectFn) {
      -			L.ui.showModal(_('Uploading file…'), [
      +			UI.prototype.showModal(_('Uploading file…'), [
       				E('p', _('Please select the file to upload.')),
       				E('div', { 'style': 'display:flex' }, [
       					E('div', { 'class': 'left', 'style': 'flex:1' }, [
      @@ -5278,7 +5290,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       							type: 'file',
       							style: 'display:none',
       							change: function(ev) {
      -								var modal = L.dom.parent(ev.target, '.modal'),
      +								var modal = dom.parent(ev.target, '.modal'),
       								    body = modal.querySelector('p'),
       								    upload = modal.querySelector('.cbi-button-action.important'),
       								    file = ev.currentTarget.files[0];
      @@ -5286,7 +5298,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       								if (file == null)
       									return;
       
      -								L.dom.content(body, [
      +								dom.content(body, [
       									E('ul', {}, [
       										E('li', {}, [ '%s: %s'.format(_('Name'), file.name.replace(/^.*[\\\/]/, '')) ]),
       										E('li', {}, [ '%s: %1024mB'.format(_('Size'), file.size) ])
      @@ -5308,7 +5320,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       						E('button', {
       							'class': 'btn',
       							'click': function() {
      -								L.ui.hideModal();
      +								UI.prototype.hideModal();
       								rejectFn(new Error('Upload has been cancelled'));
       							}
       						}, [ _('Cancel') ]),
      @@ -5317,14 +5329,14 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       							'class': 'btn cbi-button-action important',
       							'disabled': true,
       							'click': function(ev) {
      -								var input = L.dom.parent(ev.target, '.modal').querySelector('input[type="file"]');
      +								var input = dom.parent(ev.target, '.modal').querySelector('input[type="file"]');
       
       								if (!input.files[0])
       									return;
       
       								var progress = E('div', { 'class': 'cbi-progressbar', 'title': '0%' }, E('div', { 'style': 'width:0' }));
       
      -								L.ui.showModal(_('Uploading file…'), [ progress ]);
      +								UI.prototype.showModal(_('Uploading file…'), [ progress ]);
       
       								var data = new FormData();
       
      @@ -5334,7 +5346,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       
       								var filename = input.files[0].name;
       
      -								L.Request.post(L.env.cgi_base + '/cgi-upload', data, {
      +								request.post(L.env.cgi_base + '/cgi-upload', data, {
       									timeout: 0,
       									progress: function(pev) {
       										var percent = (pev.loaded / pev.total) * 100;
      @@ -5348,10 +5360,10 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       								}).then(function(res) {
       									var reply = res.json();
       
      -									L.ui.hideModal();
      +									UI.prototype.hideModal();
       
       									if (L.isObject(reply) && reply.failure) {
      -										L.ui.addNotification(null, E('p', _('Upload request failed: %s').format(reply.message)));
      +										UI.prototype.addNotification(null, E('p', _('Upload request failed: %s').format(reply.message)));
       										rejectFn(new Error(reply.failure));
       									}
       									else {
      @@ -5359,7 +5371,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       										resolveFn(reply);
       									}
       								}, function(err) {
      -									L.ui.hideModal();
      +									UI.prototype.hideModal();
       									rejectFn(err);
       								});
       							}
      @@ -5420,7 +5432,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       		var ipaddrs = arguments.length ? arguments : [ window.location.host ];
       
       		window.setTimeout(L.bind(function() {
      -			L.Poll.add(L.bind(function() {
      +			poll.add(L.bind(function() {
       				var tasks = [], reachable = false;
       
       				for (var i = 0; i < 2; i++)
      @@ -5430,7 +5442,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       
       				return Promise.all(tasks).then(function() {
       					if (reachable) {
      -						L.Poll.stop();
      +						poll.stop();
       						window.location = reachable;
       					}
       				});
      @@ -5452,7 +5464,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       	 * external JavaScript, use `L.require("ui").then(...)` and access the
       	 * `changes` property of the class instance value.
       	 */
      -	changes: L.Class.singleton(/* @lends LuCI.ui.changes.prototype */ {
      +	changes: baseclass.singleton(/* @lends LuCI.ui.changes.prototype */ {
       		init: function() {
       			if (!L.env.sessionid)
       				return;
      @@ -5485,7 +5497,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       			}
       
       			if (n > 0) {
      -				L.dom.content(i, [ _('Unsaved Changes'), ': ', n ]);
      +				dom.content(i, [ _('Unsaved Changes'), ': ', n ]);
       				i.classList.add('flash');
       				i.style.display = '';
       				document.dispatchEvent(new CustomEvent('uci-new-changes'));
      @@ -5544,7 +5556,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       		 */
       		displayChanges: function() {
       			var list = E('div', { 'class': 'uci-change-list' }),
      -			    dlg = L.ui.showModal(_('Configuration') + ' / ' + _('Changes'), [
      +			    dlg = UI.prototype.showModal(_('Configuration') + ' / ' + _('Changes'), [
       				E('div', { 'class': 'cbi-section' }, [
       					E('strong', _('Legend:')),
       					E('div', { 'class': 'uci-change-legend' }, [
      @@ -5560,7 +5572,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       					E('div', { 'class': 'right' }, [
       						E('button', {
       							'class': 'btn',
      -							'click': L.ui.hideModal
      +							'click': UI.prototype.hideModal
       						}, [ _('Dismiss') ]), ' ',
       						E('button', {
       							'class': 'cbi-button cbi-button-positive important',
      @@ -5613,24 +5625,24 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       		/** @private */
       		displayStatus: function(type, content) {
       			if (type) {
      -				var message = L.ui.showModal('', '');
      +				var message = UI.prototype.showModal('', '');
       
       				message.classList.add('alert-message');
       				DOMTokenList.prototype.add.apply(message.classList, type.split(/\s+/));
       
       				if (content)
      -					L.dom.content(message, content);
      +					dom.content(message, content);
       
       				if (!this.was_polling) {
      -					this.was_polling = L.Request.poll.active();
      -					L.Request.poll.stop();
      +					this.was_polling = request.poll.active();
      +					request.poll.stop();
       				}
       			}
       			else {
      -				L.ui.hideModal();
      +				UI.prototype.hideModal();
       
       				if (this.was_polling)
      -					L.Request.poll.start();
      +					request.poll.start();
       			}
       		},
       
      @@ -5643,21 +5655,21 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       
       				var call = function(r, data, duration) {
       					if (r.status === 204) {
      -						L.ui.changes.displayStatus('warning', [
      +						UI.prototype.changes.displayStatus('warning', [
       							E('h4', _('Configuration changes have been rolled back!')),
       							E('p', _('The device could not be reached within %d seconds after applying the pending changes, which caused the configuration to be rolled back for safety reasons. If you believe that the configuration changes are correct nonetheless, perform an unchecked configuration apply. Alternatively, you can dismiss this warning and edit changes before attempting to apply again, or revert all pending changes to keep the currently working configuration state.').format(L.env.apply_rollback)),
       							E('div', { 'class': 'right' }, [
       								E('button', {
       									'class': 'btn',
      -									'click': L.bind(L.ui.changes.displayStatus, L.ui.changes, false)
      +									'click': L.bind(UI.prototype.changes.displayStatus, UI.prototype.changes, false)
       								}, [ _('Dismiss') ]), ' ',
       								E('button', {
       									'class': 'btn cbi-button-action important',
      -									'click': L.bind(L.ui.changes.revert, L.ui.changes)
      +									'click': L.bind(UI.prototype.changes.revert, UI.prototype.changes)
       								}, [ _('Revert changes') ]), ' ',
       								E('button', {
       									'class': 'btn cbi-button-negative important',
      -									'click': L.bind(L.ui.changes.apply, L.ui.changes, false)
      +									'click': L.bind(UI.prototype.changes.apply, UI.prototype.changes, false)
       								}, [ _('Apply unchecked') ])
       							])
       						]);
      @@ -5667,7 +5679,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       
       					var delay = isNaN(duration) ? 0 : Math.max(1000 - duration, 0);
       					window.setTimeout(function() {
      -						L.Request.request(L.url('admin/uci/confirm'), {
      +						request.request(L.url('admin/uci/confirm'), {
       							method: 'post',
       							timeout: L.env.apply_timeout * 1000,
       							query: { sid: L.env.sessionid, token: L.env.token }
      @@ -5698,19 +5710,19 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       			var call = function(r, data, duration) {
       				if (Date.now() >= deadline) {
       					window.clearTimeout(tt);
      -					L.ui.changes.rollback(checked);
      +					UI.prototype.changes.rollback(checked);
       					return;
       				}
       				else if (r && (r.status === 200 || r.status === 204)) {
       					document.dispatchEvent(new CustomEvent('uci-applied'));
       
      -					L.ui.changes.setIndicator(0);
      -					L.ui.changes.displayStatus('notice',
      +					UI.prototype.changes.setIndicator(0);
      +					UI.prototype.changes.displayStatus('notice',
       						E('p', _('Configuration changes applied.')));
       
       					window.clearTimeout(tt);
       					window.setTimeout(function() {
      -						//L.ui.changes.displayStatus(false);
      +						//UI.prototype.changes.displayStatus(false);
       						window.location = window.location.href.split('#')[0];
       					}, L.env.apply_display * 1000);
       
      @@ -5719,10 +5731,10 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       
       				var delay = isNaN(duration) ? 0 : Math.max(1000 - duration, 0);
       				window.setTimeout(function() {
      -					L.Request.request(L.url('admin/uci/confirm'), {
      +					request.request(L.url('admin/uci/confirm'), {
       						method: 'post',
       						timeout: L.env.apply_timeout * 1000,
      -						query: L.ui.changes.confirm_auth
      +						query: UI.prototype.changes.confirm_auth
       					}).then(call, call);
       				}, delay);
       			};
      @@ -5730,7 +5742,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       			var tick = function() {
       				var now = Date.now();
       
      -				L.ui.changes.displayStatus('notice spinning',
      +				UI.prototype.changes.displayStatus('notice spinning',
       					E('p', _('Applying configuration changes… %ds')
       						.format(Math.max(Math.floor((deadline - Date.now()) / 1000), 0))));
       
      @@ -5771,32 +5783,32 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       			this.displayStatus('notice spinning',
       				E('p', _('Starting configuration apply…')));
       
      -			L.Request.request(L.url('admin/uci', checked ? 'apply_rollback' : 'apply_unchecked'), {
      +			request.request(L.url('admin/uci', checked ? 'apply_rollback' : 'apply_unchecked'), {
       				method: 'post',
       				query: { sid: L.env.sessionid, token: L.env.token }
       			}).then(function(r) {
       				if (r.status === (checked ? 200 : 204)) {
       					var tok = null; try { tok = r.json(); } catch(e) {}
       					if (checked && tok !== null && typeof(tok) === 'object' && typeof(tok.token) === 'string')
      -						L.ui.changes.confirm_auth = tok;
      +						UI.prototype.changes.confirm_auth = tok;
       
      -					L.ui.changes.confirm(checked, Date.now() + L.env.apply_rollback * 1000);
      +					UI.prototype.changes.confirm(checked, Date.now() + L.env.apply_rollback * 1000);
       				}
       				else if (checked && r.status === 204) {
      -					L.ui.changes.displayStatus('notice',
      +					UI.prototype.changes.displayStatus('notice',
       						E('p', _('There are no changes to apply')));
       
       					window.setTimeout(function() {
      -						L.ui.changes.displayStatus(false);
      +						UI.prototype.changes.displayStatus(false);
       					}, L.env.apply_display * 1000);
       				}
       				else {
      -					L.ui.changes.displayStatus('warning',
      +					UI.prototype.changes.displayStatus('warning',
       						E('p', _('Apply request failed with status <code>%h</code>')
       							.format(r.responseText || r.statusText || r.status)));
       
       					window.setTimeout(function() {
      -						L.ui.changes.displayStatus(false);
      +						UI.prototype.changes.displayStatus(false);
       					}, L.env.apply_display * 1000);
       				}
       			});
      @@ -5818,29 +5830,29 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       			this.displayStatus('notice spinning',
       				E('p', _('Reverting configuration…')));
       
      -			L.Request.request(L.url('admin/uci/revert'), {
      +			request.request(L.url('admin/uci/revert'), {
       				method: 'post',
       				query: { sid: L.env.sessionid, token: L.env.token }
       			}).then(function(r) {
       				if (r.status === 200) {
       					document.dispatchEvent(new CustomEvent('uci-reverted'));
       
      -					L.ui.changes.setIndicator(0);
      -					L.ui.changes.displayStatus('notice',
      +					UI.prototype.changes.setIndicator(0);
      +					UI.prototype.changes.displayStatus('notice',
       						E('p', _('Changes have been reverted.')));
       
       					window.setTimeout(function() {
      -						//L.ui.changes.displayStatus(false);
      +						//UI.prototype.changes.displayStatus(false);
       						window.location = window.location.href.split('#')[0];
       					}, L.env.apply_display * 1000);
       				}
       				else {
      -					L.ui.changes.displayStatus('warning',
      +					UI.prototype.changes.displayStatus('warning',
       						E('p', _('Revert request failed with status <code>%h</code>')
       							.format(r.statusText || r.status)));
       
       					window.setTimeout(function() {
      -						L.ui.changes.displayStatus(false);
      +						UI.prototype.changes.displayStatus(false);
       					}, L.env.apply_display * 1000);
       				}
       			});
      @@ -5891,7 +5903,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       			events.push('blur', 'keyup');
       
       		try {
      -			var cbiValidator = L.validation.create(field, type, optional, vfunc),
      +			var cbiValidator = validation.create(field, type, optional, vfunc),
       			    validatorFn = cbiValidator.validate.bind(cbiValidator);
       
       			for (var i = 0; i < events.length; i++)
      @@ -5972,6 +5984,8 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {
       	Hiddenfield: UIHiddenfield,
       	FileUpload: UIFileUpload
       });
      +
      +return UI;
       
      @@ -5984,7 +5998,7 @@ return L.Class.extend(/** @lends LuCI.ui.prototype */ {