mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-12-09 02:08:05 +00:00
Add experimental system tiddler browser
This commit is contained in:
31
core/modules/filters/splitbefore.js
Normal file
31
core/modules/filters/splitbefore.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/splitbefore.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator that splits each result on the first occurance of the specified separator and returns the unique values.
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.splitbefore = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
var parts = title.split(operator.operand);
|
||||
if(parts.length === 1) {
|
||||
$tw.utils.pushTop(results,parts[0]);
|
||||
} else {
|
||||
$tw.utils.pushTop(results,parts[0] + operator.operand);
|
||||
}
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user