Author: vvalchev
Date: Tue Apr 3 16:16:05 2012
New Revision: 1309013
URL: http://svn.apache.org/viewvc?rev=1309013&view=rev
Log:
Fixed FELIX-3314 Sort UPnP devices in alphabetical order for Chrome Browser
https://issues.apache.org/jira/browse/FELIX-3314
Modified:
felix/trunk/webconsole-plugins/upnp/src/main/resources/res/upnp.js
Modified: felix/trunk/webconsole-plugins/upnp/src/main/resources/res/upnp.js
URL:
http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/upnp/src/main/resources/res/upnp.js?rev=1309013&r1=1309012&r2=1309013&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/upnp/src/main/resources/res/upnp.js
(original)
+++ felix/trunk/webconsole-plugins/upnp/src/main/resources/res/upnp.js Tue Apr
3 16:16:05 2012
@@ -250,13 +250,25 @@ function invokeAction(udn, urn, action)
}, 'json');
}
+function sortNm(a) {
+ if (typeof a != 'undefined' && typeof a.props != undefined) {
+ var nm = a.props['UPnP.device.friendlyName'];
+ if (typeof nm != 'undefined') return nm.toLowerCase();
+ }
+ return '';
+}
+
+function sortFn(a,b) {
+ return sortNm(a) > sortNm(b) ? 1 : -1;
+}
+
function listDevices() {
browser.empty().addClass('ui-helper-hidden');
searching.removeClass('ui-helper-hidden');
-
+
$.post(pluginRoot, { 'action': 'listDevices' }, function(data) {
if (data && data.devices) {
- data.devices.sort(function(a,b){ return
a.props['UPnP.device.friendlyName'] > b.props['UPnP.device.friendlyName']});
+ data.devices.sort(sortFn);
$.each(data.devices, function(index) {
var html = addDevice(this);
browser.treeview( { add: html.appendTo(browser)
} );