mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-02 12:19:11 +00:00
parent
f1090d749e
commit
ffcbcbfa82
29
core/modules/filters/minlength.js
Normal file
29
core/modules/filters/minlength.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/filters/minlength.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: filteroperator
|
||||||
|
|
||||||
|
Filter operator for filtering out titles that don't meet the minimum length in the operand
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Export our filter function
|
||||||
|
*/
|
||||||
|
exports.minlength = function(source,operator,options) {
|
||||||
|
var results = [],
|
||||||
|
minLength = parseInt(operator.operand || "",10) || 0;
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(title.length >= minLength) {
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
11
editions/tw5.com/tiddlers/filters/examples/minlength.tid
Normal file
11
editions/tw5.com/tiddlers/filters/examples/minlength.tid
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
created: 20161011074235805
|
||||||
|
modified: 20161011074235805
|
||||||
|
tags: [[Operator Examples]] [[minlength Operator]]
|
||||||
|
title: minlength Operator (Examples)
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
<<.using-days-of-week>>
|
||||||
|
|
||||||
|
<<.operator-example 1 "[list[Days of the Week]minlength[7]]">>
|
||||||
|
<<.operator-example 2 "[list[Days of the Week]minlength[1]]">>
|
||||||
|
|
14
editions/tw5.com/tiddlers/filters/minlength.tid
Normal file
14
editions/tw5.com/tiddlers/filters/minlength.tid
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
caption: minlength
|
||||||
|
created: 20161011074235805
|
||||||
|
modified: 20161011074235805
|
||||||
|
op-input: a list of items
|
||||||
|
op-output: those items at least as long as the specified minimum length
|
||||||
|
op-parameter: the minimum length for items
|
||||||
|
op-parameter-name: minlength
|
||||||
|
op-purpose: filter items shorter than the specified minimum length
|
||||||
|
from-version: 5.1.14
|
||||||
|
tags: [[Filter Operators]]
|
||||||
|
title: minlength Operator
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
<<.operator-examples "minlength">>
|
Loading…
Reference in New Issue
Block a user