Fix sorting applications by category priority

main
Elbert Alias 8 years ago
parent 1cd2fd70b0
commit 9f25ef1913

@ -43,9 +43,11 @@
w.categories = json.categories; w.categories = json.categories;
w.apps = json.apps; w.apps = json.apps;
w.categories.sort(function(a, b) { w.driver.categoryOrder = Object.keys(w.categories).sort(function(a, b) {
return a.priority == b.priority ? 0 : ( a.priority > b.priority ? 1 : -1 ); return w.categories[a].priority - w.categories[b].priority;
}); });
console.log(w.driver.categoryOrder);
}; };
xhr.send(null); xhr.send(null);
@ -199,9 +201,9 @@
if ( count > 0 ) { if ( count > 0 ) {
// Find the main application to display // Find the main application to display
var appName, match, found = false; var appName, found = false;
for ( match in w.categories ) { w.driver.categoryOrder.forEach(function(match) {
for ( appName in w.detected[url] ) { for ( appName in w.detected[url] ) {
w.apps[appName].cats.forEach(function(cat) { w.apps[appName].cats.forEach(function(cat) {
var icon = w.apps[appName].icon; var icon = w.apps[appName].icon;
@ -217,7 +219,7 @@
} }
}); });
} }
} });
if ( typeof chrome !== 'undefined' ) { if ( typeof chrome !== 'undefined' ) {
// Browser polyfill doesn't seem to work here // Browser polyfill doesn't seem to work here

Loading…
Cancel
Save