mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Update x-listops.js
Added prefix and suffix options to 'append' and 'prepend' operators
This commit is contained in:
parent
3e445b8853
commit
817882a404
@ -123,11 +123,16 @@ Extended filter operators to manipulate the current list.
|
|||||||
*/
|
*/
|
||||||
exports.append = function (source, operator, options) {
|
exports.append = function (source, operator, options) {
|
||||||
var results = prepare_results(source),
|
var results = prepare_results(source),
|
||||||
|
count = parseInt(operator.suffix) || 1,
|
||||||
append = $tw.utils.parseStringArray(operator.operand);
|
append = $tw.utils.parseStringArray(operator.operand);
|
||||||
if (append === "") {
|
if (append === "") {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
return results.concat(append);
|
if (operator.prefix) {
|
||||||
|
return results.concat(append.slice(-count));
|
||||||
|
} else {
|
||||||
|
return results.concat(append.slice(0, count));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -135,11 +140,16 @@ Extended filter operators to manipulate the current list.
|
|||||||
*/
|
*/
|
||||||
exports.prepend = function (source, operator, options) {
|
exports.prepend = function (source, operator, options) {
|
||||||
var results = prepare_results(source),
|
var results = prepare_results(source),
|
||||||
|
count = parseInt(operator.suffix) || 1,
|
||||||
prepend = $tw.utils.parseStringArray(operator.operand);
|
prepend = $tw.utils.parseStringArray(operator.operand);
|
||||||
if (prepend === "") {
|
if (prepend === "") {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
return prepend.concat(results);
|
if (operator.prefix) {
|
||||||
|
return prepend.slice(-count).concat(results);
|
||||||
|
} else {
|
||||||
|
return prepend.slice(0, count).concat(results);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user