summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-07-31 08:39:10 +0200
committerJo-Philipp Wich <jo@mein.io>2019-08-14 22:58:15 +0200
commit227fae8a378826bcacd6fb118385bcff15278173 (patch)
treea6fd75f0ae1ad036dabf0813d055d2d17fe4398b
parent3e5ef065dff1b3a09e0124e370c5ed1d04aa6a3f (diff)
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>
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/network.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/network.js b/modules/luci-base/htdocs/luci-static/resources/network.js
index ac0ef212c4..2583879955 100644
--- a/modules/luci-base/htdocs/luci-static/resources/network.js
+++ b/modules/luci-base/htdocs/luci-static/resources/network.js
@@ -561,10 +561,14 @@ function initNetworkState() {
}
function ifnameOf(obj) {
- if (obj instanceof Interface)
- return obj.name();
- else if (obj instanceof Protocol)
- return obj.ifname();
+ if (obj instanceof Protocol)
+ return obj.getIfname();
+ else if (obj instanceof Device)
+ return obj.getName();
+ else if (obj instanceof WifiDevice)
+ return obj.getName();
+ else if (obj instanceof WifiNetwork)
+ return obj.getIfname();
else if (typeof(obj) == 'string')
return obj.replace(/:.+$/, '');
@@ -1151,6 +1155,10 @@ Network = L.Class.extend({
instantiateWifiNetwork: function(sid, radioname, radiostate, netid, netstate, iwinfo) {
return new WifiNetwork(sid, radioname, radiostate, netid, netstate, iwinfo);
+ },
+
+ getIfnameOf: function(obj) {
+ return ifnameOf(obj);
}
});