1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-26 10:01:08 +12:00

ensure switches are listed first: more convenient

This commit is contained in:
Raymond Hill 2014-11-18 13:37:12 -02:00
parent 7429a491d7
commit 5ba8f58094
2 changed files with 15 additions and 2 deletions

View file

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

View file

@ -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 rules, rule, i;
var permanentList = [];
@ -52,7 +65,7 @@ var processUserRules = function(response) {
rule = rules[i].trim();
temporaryRules[rule] = allRules[rule] = true;
}
rules = Object.keys(allRules).sort();
rules = Object.keys(allRules).sort(directiveSort);
for ( i = 0; i < rules.length; i++ ) {
rule = rules[i];
onLeft = permanentRules.hasOwnProperty(rule);