mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2026-01-20 11:31:37 -08:00
Update x-listops.js
Corrected the logic of the 'allafter' filter and added a new 'move' filter.
This commit is contained in:
parent
56d467fb47
commit
3e445b8853
1 changed files with 13 additions and 2 deletions
|
|
@ -77,6 +77,17 @@ Extended filter operators to manipulate the current list.
|
|||
return results.slice(count).concat(results.slice(0, count));
|
||||
};
|
||||
|
||||
/*
|
||||
Moves the item named in the operand a number of places forward or backward in the list
|
||||
*/
|
||||
exports.move = function (source, operator, options) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand),
|
||||
count = parseInt(operator.suffix) || 1,
|
||||
marker = results.splice(index, 1);
|
||||
return results.slice(0, index + count).concat(marker).concat(results.slice(index + count));
|
||||
};
|
||||
|
||||
/*
|
||||
Returns the items from the current list that are after the item named in the operand
|
||||
*/
|
||||
|
|
@ -87,9 +98,9 @@ Extended filter operators to manipulate the current list.
|
|||
return [];
|
||||
}
|
||||
if (operator.suffix) {
|
||||
return results.slice(index - 1);
|
||||
return results.slice(index);
|
||||
}
|
||||
return results.slice(index);
|
||||
return results.slice(index + 1);
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue