1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-25 06:43:15 +00:00

Update x-listops.js

Change default suffix for append[], prepend[] and remove[] operators from 1 to All
This commit is contained in:
William Jackson 2015-11-08 09:49:07 +02:00
parent 817882a404
commit befb13dde1

View File

@ -122,10 +122,10 @@ Extended filter operators to manipulate the current list.
Appends the items listed in the operand array to the tail of the current list Appends the items listed in the operand array to the tail of the current list
*/ */
exports.append = function (source, operator, options) { exports.append = function (source, operator, options) {
var results = prepare_results(source), var append = $tw.utils.parseStringArray(operator.operand),
count = parseInt(operator.suffix) || 1, results = prepare_results(source),
append = $tw.utils.parseStringArray(operator.operand); count = parseInt(operator.suffix) || append.length;
if (append === "") { if (append.length === 0) {
return results; return results;
} }
if (operator.prefix) { if (operator.prefix) {
@ -139,10 +139,10 @@ Extended filter operators to manipulate the current list.
Prepends the items listed in the operand array to the head of the current list Prepends the items listed in the operand array to the head of the current list
*/ */
exports.prepend = function (source, operator, options) { exports.prepend = function (source, operator, options) {
var results = prepare_results(source), var prepend = $tw.utils.parseStringArray(operator.operand),
count = parseInt(operator.suffix) || 1, results = prepare_results(source),
prepend = $tw.utils.parseStringArray(operator.operand); count = parseInt(operator.suffix) || prepend.length;
if (prepend === "") { if (prepend.length === 0) {
return results; return results;
} }
if (operator.prefix) { if (operator.prefix) {
@ -156,9 +156,10 @@ Extended filter operators to manipulate the current list.
Returns all items from the current list except the items listed in the operand array Returns all items from the current list except the items listed in the operand array
*/ */
exports.remove = function (source, operator, options) { exports.remove = function (source, operator, options) {
var results = prepare_results(source), var array = $tw.utils.parseStringArray(operator.operand),
count = parseInt(operator.suffix) || 1, results = prepare_results(source),
p, len, index, array = $tw.utils.parseStringArray(operator.operand); count = parseInt(operator.suffix) || array.length,
p, len, index;
len = array.length - 1; len = array.length - 1;
for (p = 0; p < count; ++p) { for (p = 0; p < count; ++p) {
if (operator.prefix) { if (operator.prefix) {