mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-19 22:26:18 +00:00
![Jermolene](/assets/img/avatar_default.png)
There are still some warnings about making functions in a loop, but I’ll fix those as a separate pull request because the fixes are more than typographic errors.
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
/*\
|
|
title: $:/core/modules/filters/sort.js
|
|
type: application/javascript
|
|
module-type: filteroperator
|
|
|
|
Filter operator for sorting
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.sort = function(source,operator,options) {
|
|
var results = prepare_results(source);
|
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",false,false);
|
|
return results;
|
|
};
|
|
|
|
exports.nsort = function(source,operator,options) {
|
|
var results = prepare_results(source);
|
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",false,true);
|
|
return results;
|
|
};
|
|
|
|
exports.sortcs = function(source,operator,options) {
|
|
var results = prepare_results(source);
|
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",true,false);
|
|
return results;
|
|
};
|
|
|
|
exports.nsortcs = function(source,operator,options) {
|
|
var results = prepare_results(source);
|
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",true,true);
|
|
return results;
|
|
};
|
|
|
|
var prepare_results = function (source) {
|
|
var results = [];
|
|
source(function(tiddler,title) {
|
|
results.push(title);
|
|
});
|
|
return results;
|
|
};
|
|
|
|
})();
|