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:09] aspectscript |
demo [2010/03/16 22:26] (current) aspectscript |
||
|---|---|---|---|
| Line 10: | Line 10: | ||
| <div style=" | <div style=" | ||
| <div id=" | <div id=" | ||
| - | <form action="/ | + | <form action="/ |
| <div style=" | <div style=" | ||
| - | < | + | < |
| </ | </ | ||
| - | <div style=" | + | <div style=" |
| - | <a href=" | + | |
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | |||
| + | < | ||
| + | |||
| + | | ||
| <input type=" | <input type=" | ||
| </ | </ | ||
| Line 30: | Line 45: | ||
| <script type=" | <script type=" | ||
| var editor = CodeMirror.fromTextArea(" | var editor = CodeMirror.fromTextArea(" | ||
| - | width: "720", | + | width: "720px", |
| - | height: "441", | + | height: "441px", |
| parserfile: [" | parserfile: [" | ||
| path: "/ | path: "/ | ||
| Line 51: | Line 66: | ||
| <div style=" | <div style=" | ||
| - | | + | |
| - | var actionListAspect | + | function removeTag(userID, |
| + | alert(" | ||
| + | } | ||
| + | </ | ||
| + | <pre id=" | ||
| + | AspectScript.deploy({ | ||
| + | kind: | ||
| + | pointcut: | ||
| + | advice: | ||
| + | }); | ||
| + | </ | ||
| + | <pre id=" | ||
| + | var batchAspect | ||
| kind: AspectScript.AROUND, | kind: AspectScript.AROUND, | ||
| pointcut: function(jp){ | pointcut: function(jp){ | ||
| Line 64: | 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; | ||
| } | } | ||
| }); | }); | ||