ensure switches are listed first: more convenient

pull/2/head
Raymond Hill 10 years ago
parent 7429a491d7
commit 5ba8f58094

@ -619,7 +619,7 @@ Matrix.prototype.toString = function() {
out.push(switchName + ': ' + srcHostname + ' ' + val); out.push(switchName + ': ' + srcHostname + ' ' + val);
} }
} }
return out.sort().join('\n'); return out.join('\n');
}; };
/******************************************************************************/ /******************************************************************************/

@ -31,6 +31,19 @@ messaging.start('user-rules.js');
/******************************************************************************/ /******************************************************************************/
// Switches before, rules after
var directiveSort = function(a, b) {
var aIsSwitch = a.indexOf(':') !== -1;
var bIsSwitch = b.indexOf(':') !== -1;
if ( aIsSwitch === bIsSwitch ) {
return a.localeCompare(b);
}
return aIsSwitch ? -1 : 1;
};
/******************************************************************************/
var processUserRules = function(response) { var processUserRules = function(response) {
var rules, rule, i; var rules, rule, i;
var permanentList = []; var permanentList = [];
@ -52,7 +65,7 @@ var processUserRules = function(response) {
rule = rules[i].trim(); rule = rules[i].trim();
temporaryRules[rule] = allRules[rule] = true; temporaryRules[rule] = allRules[rule] = true;
} }
rules = Object.keys(allRules).sort(); rules = Object.keys(allRules).sort(directiveSort);
for ( i = 0; i < rules.length; i++ ) { for ( i = 0; i < rules.length; i++ ) {
rule = rules[i]; rule = rules[i];
onLeft = permanentRules.hasOwnProperty(rule); onLeft = permanentRules.hasOwnProperty(rule);

Loading…
Cancel
Save