mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-19 18:59:42 +00:00
b7f674c51a
This is the beginning of addressing #523.
38 lines
735 B
JavaScript
38 lines
735 B
JavaScript
/*\
|
|
title: $:/core/modules/filters/tag.js
|
|
type: application/javascript
|
|
module-type: filteroperator
|
|
|
|
Filter operator for checking for the presence of a tag
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.tag = function(source,operator,options) {
|
|
var results = [];
|
|
if(operator.prefix === "!") {
|
|
source(function(tiddler,title) {
|
|
if(tiddler && !tiddler.hasTag(operator.operand)) {
|
|
results.push(title);
|
|
}
|
|
});
|
|
} else {
|
|
source(function(tiddler,title) {
|
|
if(tiddler && tiddler.hasTag(operator.operand)) {
|
|
results.push(title);
|
|
}
|
|
});
|
|
results = options.wiki.sortByList(results,operator.operand);
|
|
}
|
|
return results;
|
|
};
|
|
|
|
})();
|