Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
demo [2010/03/16 21:51] aspectscript |
demo [2010/03/16 22:26] (current) aspectscript |
||
---|---|---|---|
Line 14: | Line 14: | ||
< | < | ||
</ | </ | ||
- | <div style=" | + | <div style=" |
- | <a href=" | + | |
- | <a href=" | + | <hr> |
+ | | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
- | | + | <hr> |
+ | | ||
+ | |||
+ | <hr> | ||
+ | |||
+ | <p>Step 5:< | ||
+ | |||
+ | | ||
<input type=" | <input type=" | ||
</ | </ | ||
Line 54: | Line 66: | ||
<div style=" | <div style=" | ||
- | <pre id="actionAspect"> | + | <pre id="step0"> |
function removeTag(userID, | function removeTag(userID, | ||
alert(" | alert(" | ||
} | } | ||
</ | </ | ||
- | <pre id="actionAspect"> | + | <pre id="step1"> |
- | var actionListAspect | + | AspectScript.deploy({ |
+ | kind: | ||
+ | pointcut: | ||
+ | advice: | ||
+ | }); | ||
+ | </ | ||
+ | <pre id=" | ||
+ | var batchAspect | ||
kind: AspectScript.AROUND, | kind: AspectScript.AROUND, | ||
pointcut: function(jp){ | pointcut: function(jp){ | ||
Line 72: | Line 91: | ||
removals: [], | removals: [], | ||
applyChanges: | applyChanges: | ||
- | for(var i = 0; i < this.removals.length; ++i){ | + | |
- | this.removals[i].proceed(); | + | this.removals.shift().proceed(); |
+ | } | ||
+ | } | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | <pre id=" | ||
+ | var removeAllAspect = AspectScript.deploy({ | ||
+ | kind: AspectScript.AFTER, | ||
+ | pointcut: AspectScript.Pointcuts.call(removeTag).and(function(jp){ | ||
+ | this.removedIds.push(jp.args[1]); | ||
+ | return this.removedIds.length >= 3; | ||
+ | }), | ||
+ | advice: function(){ | ||
+ | if(confirm(" | ||
+ | for(var i = 1; i <= 5; ++i){ | ||
+ | if(this.shouldRemove(i)){ | ||
+ | removeTag(1, | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | }, | ||
+ | //other properties | ||
+ | removedIds: [], | ||
+ | shouldRemove: | ||
+ | | ||
+ | | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | return true; | ||
+ | } | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | <pre id=" | ||
+ | var batchAspect = AspectScript.deploy({ | ||
+ | kind: AspectScript.AROUND, | ||
+ | pointcut: function(jp){ | ||
+ | return jp.isCall() && jp.fun === removeTag; | ||
+ | }, | ||
+ | advice: function(jp){ | ||
+ | | ||
+ | updateActionsUI(); | ||
+ | }, | ||
+ | //other properties | ||
+ | removals: | ||
+ | applyChanges: | ||
+ | while(this.removals.length != 0){ | ||
+ | this.removals.shift().proceed(); | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | var removeAllAspect = AspectScript.deploy({ | ||
+ | kind: AspectScript.AFTER, | ||
+ | pointcut: AspectScript.Pointcuts.call(removeTag).and(function(jp){ | ||
+ | this.removedIds.push(jp.args[1]); | ||
+ | return this.removedIds.length >= 3; | ||
+ | }), | ||
+ | advice: function(){ | ||
+ | if(confirm(" | ||
+ | for(var | ||
+ | if(this.shouldRemove(i)){ | ||
+ | removeTag(1, | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | }, | ||
+ | //other properties | ||
+ | removedIds: [], | ||
+ | shouldRemove: | ||
+ | for(var i = 0; i < this.removedIds.length; | ||
+ | if(this.removedIds[i] == idx){ | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | return true; | ||
+ | } | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | <pre id=" | ||
+ | var batchAspect = AspectScript.deploy({ | ||
+ | kind: AspectScript.AROUND, | ||
+ | pointcut: function(jp){ | ||
+ | return jp.isCall() && jp.fun === removeTag; | ||
+ | }, | ||
+ | advice: function(jp){ | ||
+ | this.removals.push(jp.clone()); | ||
+ | updateActionsUI(); | ||
+ | }, | ||
+ | //other properties | ||
+ | removals: [], | ||
+ | applyChanges: | ||
+ | while(this.removals.length != 0){ | ||
+ | this.removals.shift().proceed(); | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | var removeAllAspect = AspectScript.deploy({ | ||
+ | kind: AspectScript.AFTER, | ||
+ | pointcut: AspectScript.Pointcuts.call(removeTag).and(function(jp){ | ||
+ | this.removedIds.push(jp.args[1]); | ||
+ | return this.removedIds.length >= 3; | ||
+ | }), | ||
+ | advice: function(){ | ||
+ | if(confirm(" | ||
+ | AspectScript.down(this, | ||
+ | for(var i = 1; i <= 5; ++i){ | ||
+ | if(this.shouldRemove(i)){ | ||
+ | removeTag(1, | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | } | ||
+ | }, | ||
+ | //other properties | ||
+ | removedIds: [], | ||
+ | shouldRemove: | ||
+ | for(var i = 0; i < this.removedIds.length; | ||
+ | if(this.removedIds[i] == idx){ | ||
+ | return false; | ||
+ | } | ||
} | } | ||
+ | return true; | ||
} | } | ||
}); | }); |