Rename the operator portion after the colon to "suffix"

print-window-tiddler
Jermolene 2014-01-24 19:15:27 +00:00
rodzic 42262a637c
commit a76da88380
2 zmienionych plików z 7 dodań i 11 usunięć

Wyświetl plik

@ -44,7 +44,7 @@ function parseFilterOperation(operators,filterString,p) {
// Any suffix? // Any suffix?
var colon = operator.operator.indexOf(':'); var colon = operator.operator.indexOf(':');
if(colon > -1) { if(colon > -1) {
operator.field = operator.operator.substring(colon + 1); operator.suffix = operator.operator.substring(colon + 1);
operator.operator = operator.operator.substring(0,colon) || "field"; operator.operator = operator.operator.substring(0,colon) || "field";
} }
// Empty operator means: title // Empty operator means: title
@ -186,7 +186,7 @@ exports.compileFilter = function(filterString) {
operator: operator.operator, operator: operator.operator,
operand: operand, operand: operand,
prefix: operator.prefix, prefix: operator.prefix,
field: operator.field, suffix: operator.suffix,
regexp: operator.regexp regexp: operator.regexp
},{ },{
wiki: self, wiki: self,

Wyświetl plik

@ -16,17 +16,17 @@ Filter operator for comparing fields for equality
Export our filter function Export our filter function
*/ */
exports.field = function(source,operator,options) { exports.field = function(source,operator,options) {
var results = []; var results = [],
fieldname = (operator.suffix || operator.operator).toLowerCase();
// Function to check an individual title // Function to check an individual title
function checkTiddler(title) { function checkTiddler(title) {
var tiddler = options.wiki.getTiddler(title); var tiddler = options.wiki.getTiddler(title);
if(tiddler) { if(tiddler) {
var match, var match,
text = tiddler.getFieldString(operator.field); text = tiddler.getFieldString(fieldname);
if(operator.regexp) { if(operator.regexp) {
match = !! operator.regexp.exec(text); match = !!operator.regexp.exec(text);
} } else {
else {
match = text === operator.operand; match = text === operator.operand;
} }
if(operator.prefix === "!") { if(operator.prefix === "!") {
@ -38,10 +38,6 @@ exports.field = function(source,operator,options) {
} }
} }
// Iterate through the source tiddlers // Iterate through the source tiddlers
if(!operator.field) {
operator.field = operator.operator;
}
operator.field.toLowerCase();
if($tw.utils.isArray(source)) { if($tw.utils.isArray(source)) {
$tw.utils.each(source,function(title) { $tw.utils.each(source,function(title) {
checkTiddler(title); checkTiddler(title);