2013-09-14 15:28:46 +00:00
|
|
|
/*\
|
|
|
|
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 = [];
|
2014-04-03 19:49:16 +00:00
|
|
|
if(operator.prefix === "!") {
|
|
|
|
source(function(tiddler,title) {
|
|
|
|
if(tiddler && $tw.utils.isArray(tiddler.fields.tags) && tiddler.fields.tags.length > 0) {
|
|
|
|
$tw.utils.pushTop(results,title);
|
|
|
|
}
|
2013-09-14 15:28:46 +00:00
|
|
|
});
|
|
|
|
} else {
|
2014-04-03 19:49:16 +00:00
|
|
|
source(function(tiddler,title) {
|
2014-04-17 15:10:50 +00:00
|
|
|
if(!tiddler || !tiddler.hasField("tags") || ($tw.utils.isArray(tiddler.fields.tags) && tiddler.fields.tags.length === 0)) {
|
|
|
|
$tw.utils.pushTop(results,title);
|
2014-04-03 19:49:16 +00:00
|
|
|
}
|
2013-09-14 15:28:46 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|