summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2014-04-13 22:42:10 +0200
committerJo-Philipp Wich <jow@openwrt.org>2014-04-13 22:42:10 +0200
commitf6527cd1e850286708787c6a98fcd5c1cfc417d9 (patch)
tree7775bcea6ecb89c0ab748c408069e1d702494441
parente314622aa9ad41f5d3083dfd21ff0f61175c237f (diff)
downloadluci2-ui-f6527cd1e850286708787c6a98fcd5c1cfc417d9.tar.gz
luci2: add L.NetworkModel.Interface.renderBadge() and use it in L.cbi.NetworkList widget
-rw-r--r--luci2/htdocs/luci2/luci2.js44
1 files changed, 27 insertions, 17 deletions
diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js
index 5947791..5e95105 100644
--- a/luci2/htdocs/luci2/luci2.js
+++ b/luci2/htdocs/luci2/luci2.js
@@ -2737,6 +2737,30 @@ function LuCI2()
return dev.getTrafficHistory();
},
+ renderBadge: function()
+ {
+ var badge = $('<span />')
+ .addClass('badge')
+ .text('%s: '.format(this.name()));
+
+ var dev = this.getDevice();
+ var subdevs = this.getSubdevices();
+
+ if (subdevs.length)
+ for (var j = 0; j < subdevs.length; j++)
+ badge.append($('<img />')
+ .attr('src', subdevs[j].icon())
+ .attr('title', '%s (%s)'.format(subdevs[j].description(), subdevs[j].name() || '?')));
+ else if (dev)
+ badge.append($('<img />')
+ .attr('src', dev.icon())
+ .attr('title', '%s (%s)'.format(dev.description(), dev.name() || '?')));
+ else
+ badge.append($('<em />').text(L.tr('(No devices attached)')));
+
+ return badge;
+ },
+
setDevices: function(devs)
{
var dev = this.getPhysdev();
@@ -6010,30 +6034,16 @@ function LuCI2()
for (var i = 0; i < interfaces.length; i++)
{
var iface = interfaces[i];
- var badge = $('<span />')
- .addClass('badge')
- .text('%s: '.format(iface.name()));
-
- var dev = iface.getDevice();
- var subdevs = iface.getSubdevices();
-
- if (subdevs.length)
- for (var j = 0; j < subdevs.length; j++)
- badge.append(this._device_icon(subdevs[j]));
- else if (dev)
- badge.append(this._device_icon(dev));
- else
- badge.append($('<em />').text(L.tr('(No devices attached)')));
$('<li />')
.append($('<label />')
.addClass(itype + ' inline')
- .append($('<input />')
+ .append(this.validator(sid, $('<input />')
.attr('name', itype + id)
.attr('type', itype)
.attr('value', iface.name())
- .prop('checked', !!check[iface.name()]))
- .append(badge))
+ .prop('checked', !!check[iface.name()]), true))
+ .append(iface.renderBadge()))
.appendTo(ul);
}