1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 12:07:19 +00:00

New method for the story macro

This commit is contained in:
Jeremy Ruston 2012-06-22 18:02:34 +01:00
parent d1cee98f88
commit f718c597e3

View File

@ -67,6 +67,25 @@ exports.findStoryElementContainingNode = function(node) {
return slot; return slot;
}; };
/*
Return the index of the story element that corresponds to a particular title
startIndex: index to start search (use zero to search from the top)
tiddlerTitle: tiddler title to seach for
templateTitle: optional template title to search for
*/
exports.findStoryElementByTitle = function(startIndex,tiddlerTitle,templateTitle) {
while(startIndex < this.storyNode.children.length) {
var params = this.storyNode.children[startIndex].children[0].params;
if(params.target === tiddlerTitle) {
if(!templateTitle || params.template === templateTitle) {
return startIndex;
}
}
startIndex++;
}
return undefined;
};
exports.eventMap = {}; exports.eventMap = {};
// Navigate to a specified tiddler // Navigate to a specified tiddler