1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

Sort browser apps alphabetically. Sort again in the detailed device list as we currently have old data left over and we may wish to change the sorting later anyway. Should not be terribly bad due to most devices only having one or two browsers.

This commit is contained in:
Simo Kinnunen 2015-06-26 14:53:53 +09:00
parent 7071876030
commit 3257665ec2
2 changed files with 14 additions and 3 deletions

View file

@ -49,6 +49,12 @@ module.exports = syrup.serial()
return acc return acc
} }
function compareIgnoreCase(a, b) {
var la = (a || '').toLowerCase()
, lb = (b || '').toLowerCase()
return la === lb ? 0 : (la < lb ? -1 : 1)
}
function updateBrowsers(data) { function updateBrowsers(data) {
log.info('Updating browser list') log.info('Updating browser list')
push.send([ push.send([
@ -56,7 +62,9 @@ module.exports = syrup.serial()
, wireutil.envelope(new wire.DeviceBrowserMessage( , wireutil.envelope(new wire.DeviceBrowserMessage(
options.serial options.serial
, data.selected , data.selected
, data.apps.reduce(appReducer, []) , data.apps.reduce(appReducer, []).sort(function(appA, appB) {
return compareIgnoreCase(appA.name, appB.name)
})
)) ))
]) ])
} }

View file

@ -419,9 +419,12 @@ function DeviceBrowserCell(options) {
, update: function(td, device) { , update: function(td, device) {
var span = td.firstChild var span = td.firstChild
, browser = options.value(device) , browser = options.value(device)
, apps = browser.apps.slice().sort(function(appA, appB) {
return compareIgnoreCase(appA.name, appB.name)
})
for (var i = 0, l = browser.apps.length; i < l; ++i) { for (var i = 0, l = apps.length; i < l; ++i) {
var app = browser.apps[i] var app = apps[i]
, img = span.childNodes[i] || span.appendChild(document.createElement('img')) , img = span.childNodes[i] || span.appendChild(document.createElement('img'))
, src = '/static/app/browsers/icon/36x36/' + (app.type || '_default') + '.png' , src = '/static/app/browsers/icon/36x36/' + (app.type || '_default') + '.png'