mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-27 19:42:50 +00:00
![Jermolene](/assets/img/avatar_default.png)
Now we pass a widget instead of the current tiddler title. We can use widget.getVariable(“currentTiddler”) to get the current tiddler.
38 lines
703 B
JavaScript
38 lines
703 B
JavaScript
/*\
|
|
title: $:/core/modules/filters/is/current.js
|
|
type: application/javascript
|
|
module-type: isfilteroperator
|
|
|
|
Filter function for [is[current]]
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.current = function(source,prefix,options) {
|
|
var results = [],
|
|
currTiddlerTitle = options.widget && options.widget.getVariable("currentTiddler");
|
|
if(prefix === "!") {
|
|
source(function(tiddler,title) {
|
|
if(title !== currTiddlerTitle) {
|
|
results.push(title);
|
|
}
|
|
});
|
|
} else {
|
|
source(function(tiddler,title) {
|
|
if(title === currTiddlerTitle) {
|
|
results.push(title);
|
|
}
|
|
});
|
|
}
|
|
return results;
|
|
};
|
|
|
|
})();
|