Fixing hanging protocols matching score issues

This commit is contained in:
Bruno Alves de Faria committed 2016-08-24 11:53:31 -03:00
1 parent 88e504a010
commit 17f8d87d32
3 files changed
+95 -38

No files matched your search

+1
View File
@@ -2,4 +2,5 @@ import './blaze.js';
import './string.js';
import './ui.js';
import './user.js';
import './utils.js';
import './viewer.js';
+44
View File
@@ -0,0 +1,44 @@
import { OHIF } from 'meteor/ohif:core';
OHIF.utils = {};
// Return the array sorting function for its object's properties
OHIF.utils.sortBy = function() {
var fields = [].slice.call(arguments),
n_fields = fields.length;
return function(A, B) {
var a, b, field, key, primer, reverse, result, i;
for (i = 0; i < n_fields; i++) {
result = 0;
field = fields[i];
key = typeof field === 'string' ? field : field.name;
a = A[key];
b = B[key];
if (typeof field.primer !== 'undefined') {
a = field.primer(a);
b = field.primer(b);
}
reverse = (field.reverse) ? -1 : 1;
if (a < b) {
result = reverse * -1;
}
if (a > b) {
result = reverse * 1;
}
if (result !== 0) {
break;
}
}
return result;
};
};