luci-base: network.js: extend ifnameOf() and expose as getIfnameOf()
Extend the ifnameOf() helper function to cover all object types used by network.js and expose it as public getIfnameOf() api function for use by other modules. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
3e5ef065df
commit
227fae8a37
1 changed files with 12 additions and 4 deletions
|
@ -561,10 +561,14 @@ function initNetworkState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ifnameOf(obj) {
|
function ifnameOf(obj) {
|
||||||
if (obj instanceof Interface)
|
if (obj instanceof Protocol)
|
||||||
return obj.name();
|
return obj.getIfname();
|
||||||
else if (obj instanceof Protocol)
|
else if (obj instanceof Device)
|
||||||
return obj.ifname();
|
return obj.getName();
|
||||||
|
else if (obj instanceof WifiDevice)
|
||||||
|
return obj.getName();
|
||||||
|
else if (obj instanceof WifiNetwork)
|
||||||
|
return obj.getIfname();
|
||||||
else if (typeof(obj) == 'string')
|
else if (typeof(obj) == 'string')
|
||||||
return obj.replace(/:.+$/, '');
|
return obj.replace(/:.+$/, '');
|
||||||
|
|
||||||
|
@ -1151,6 +1155,10 @@ Network = L.Class.extend({
|
||||||
|
|
||||||
instantiateWifiNetwork: function(sid, radioname, radiostate, netid, netstate, iwinfo) {
|
instantiateWifiNetwork: function(sid, radioname, radiostate, netid, netstate, iwinfo) {
|
||||||
return new WifiNetwork(sid, radioname, radiostate, netid, netstate, iwinfo);
|
return new WifiNetwork(sid, radioname, radiostate, netid, netstate, iwinfo);
|
||||||
|
},
|
||||||
|
|
||||||
|
getIfnameOf: function(obj) {
|
||||||
|
return ifnameOf(obj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue