mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-07-03 02:33:15 +00:00
43 lines
924 B
JavaScript
43 lines
924 B
JavaScript
/*\
|
|
title: $:/core/modules/filters/untagged.js
|
|
type: application/javascript
|
|
module-type: filteroperator
|
|
|
|
Filter operator returning all the selected tiddlers that are untagged
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.untagged = function(source,operator,options) {
|
|
var results = [],
|
|
isTagged = (operator.operand || operator.suffix || "").toLowerCase() === "no" ?
|
|
function(tiddler) {
|
|
return false;
|
|
} : function(tiddler) {
|
|
return tiddler && $tw.utils.isArray(tiddler.fields.tags) && tiddler.fields.tags.length > 0;
|
|
};
|
|
if(operator.prefix === "!") {
|
|
source(function(tiddler,title) {
|
|
if(isTagged(tiddler)) {
|
|
$tw.utils.pushTop(results,title);
|
|
}
|
|
});
|
|
} else {
|
|
source(function(tiddler,title) {
|
|
if(!isTagged(tiddler)) {
|
|
$tw.utils.pushTop(results,title);
|
|
}
|
|
});
|
|
}
|
|
return results;
|
|
};
|
|
|
|
})();
|