Browse Source

ensure switches are listed first: more convenient

pull/2/head
Raymond Hill 10 years ago
parent
commit
5ba8f58094
  1. 2
      src/js/matrix.js
  2. 15
      src/js/user-rules.js

2
src/js/matrix.js

@ -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');
}; };
/******************************************************************************/ /******************************************************************************/

15
src/js/user-rules.js

@ -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