mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-01-22 10:54:46 +00:00
Compare commits
6 Commits
revert-942
...
filtered-a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3852f4cf70 | ||
|
|
6a650ae503 | ||
|
|
5645f52499 | ||
|
|
c55188f92f | ||
|
|
4caa89b286 | ||
|
|
a9c81f08c5 |
@@ -164,12 +164,59 @@ exports.enqueueTiddlerEvent = function(title,isDeleted) {
|
||||
self.eventsTriggered = false;
|
||||
if($tw.utils.count(changes) > 0) {
|
||||
self.dispatchEvent("change",changes);
|
||||
self.runFilteredActions();
|
||||
}
|
||||
});
|
||||
this.eventsTriggered = true;
|
||||
}
|
||||
};
|
||||
|
||||
exports.runFilteredActions = function() {
|
||||
if(!$tw.browser) {
|
||||
return;
|
||||
}
|
||||
var self = this;
|
||||
var now = (new Date()).getTime();
|
||||
// Minimum interval between runs
|
||||
this.intervalFilteredActions = this.intervalFilteredActions || 100;
|
||||
// Time of the last run
|
||||
this.timestampLastRunFilteredActions = this.timestampLastRunFilteredActions || now - this.intervalFilteredActions * 2;
|
||||
// If we've run the filtered actions recently, queue another run
|
||||
if((this.timestampLastRunFilteredActions + this.intervalFilteredActions) > now) {
|
||||
if(!this.filterActionTimerId) {
|
||||
this.filterActionTimerId = setTimeout(function() {
|
||||
self.filterActionTimerId = null;
|
||||
self.runFilteredActions();
|
||||
},this.intervalFilteredActions);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Record the time of this run
|
||||
this.timestampLastRunFilteredActions = now;
|
||||
// Get the list of filtered action tiddlers and process each one
|
||||
var filteredActions = $tw.wiki.getTiddlersWithTag("$:/tags/FilteredActions");
|
||||
$tw.utils.each(filteredActions,function(filteredActionTitle) {
|
||||
var tiddler = self.getTiddler(filteredActionTitle);
|
||||
if(tiddler && tiddler.fields.filter) {
|
||||
var results = self.filterTiddlers(tiddler.fields.filter);
|
||||
if(results.length > 0) {
|
||||
console.log("Executing actions",tiddler.fields.text,results)
|
||||
self.invokeActionString(
|
||||
tiddler.fields.text,
|
||||
null,
|
||||
{
|
||||
filteredActionTitle: filteredActionTitle,
|
||||
results: $tw.utils.stringifyList(results),
|
||||
jsonResults: JSON.stringify(results)
|
||||
},{
|
||||
parentWidget: $tw.rootWidget
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
exports.getSizeOfTiddlerEventQueue = function() {
|
||||
return $tw.utils.count(this.changedTiddlers);
|
||||
};
|
||||
|
||||
5
editions/tw5.com/tiddlers/Sample Filtered Action.tid
Normal file
5
editions/tw5.com/tiddlers/Sample Filtered Action.tid
Normal file
@@ -0,0 +1,5 @@
|
||||
title: Sample Filtered Action
|
||||
tags: $:/tags/FilteredActions
|
||||
filter: [list[$:/StoryList]match[Sample Filtered Action]]
|
||||
|
||||
<$action-setfield $tiddler="$:/SiteTitle" text={{{ [{$:/SiteTitle}addsuffix[!]] }}}/>
|
||||
7
plugins/tiddlywiki/tour/tour-filtered-action.tid
Normal file
7
plugins/tiddlywiki/tour/tour-filtered-action.tid
Normal file
@@ -0,0 +1,7 @@
|
||||
title: $:/plugins/tiddlywiki/tour/filtered-action
|
||||
tags: $:/tags/FilteredActions
|
||||
filter: [{$:/config/ShowTour}!is[blank]else[show]match[show]then[$:/state/tour/step]get[text]get[step-success-filter]] :map[subfilter<currentTiddler>] :filter[<currentTiddler>!match[]]
|
||||
|
||||
\import [[$:/plugins/tiddlywiki/tour/variables]]
|
||||
<$action-sendmessage $message="tm-confetti-launch"/>
|
||||
<<tour-next-step>>
|
||||
@@ -48,7 +48,6 @@ tags: $:/tags/PageTemplate
|
||||
<$let tour-task="">
|
||||
<$transclude tiddler=<<currentTourStep>> mode="block"/>
|
||||
</$let>
|
||||
<$confetti/>
|
||||
<p>
|
||||
Congratulations, you may proceed
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user