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:58] aspectscript |
demo [2010/03/16 22:26] (current) aspectscript |
||
|---|---|---|---|
| Line 14: | Line 14: | ||
| < | < | ||
| </ | </ | ||
| - | <div style=" | + | <div style=" |
| < | < | ||
| - | | + | < |
| - | < | + | |
| + | <hr> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| - | | + | <hr> |
| + | | ||
| + | |||
| + | <hr> | ||
| + | |||
| + | <p>Step 5:< | ||
| + | |||
| + | | ||
| <input type=" | <input type=" | ||
| </ | </ | ||
| Line 68: | Line 79: | ||
| </ | </ | ||
| <pre id=" | <pre id=" | ||
| - | AspectScript.deploy({ | + | var batchAspect = AspectScript.deploy({ |
| kind: AspectScript.AROUND, | kind: AspectScript.AROUND, | ||
| pointcut: function(jp){ | pointcut: function(jp){ | ||
| Line 83: | Line 94: | ||
| this.removals.shift().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: | ||
| + | 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(" | ||
| + | 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; | ||
| + | } | ||
| + | }); | ||
| + | </ | ||
| + | |||
| + | <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; | ||
| } | } | ||
| }); | }); | ||