1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Add x-listops filter toggle (#4990)

This commit is contained in:
saqimtiaz 2020-11-07 11:00:47 +01:00 committed by GitHub
parent 5aa4e4cb68
commit c41e34793d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -187,4 +187,19 @@ Extended filter operators to manipulate the current list.
}, []);
return set;
};
/*
Toggles an item in the current list.
*/
exports.toggle = function(source, operator) {
var results = prepare_results(source),
index = results.indexOf(operator.operand);
if(index === -1) {
results.push(operator.operand);
} else {
results.splice(index, 1);
}
return results;
};
})();