demo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
demo [2010/03/16 21:07]
aspectscript
demo [2010/03/16 22:26] (current)
aspectscript
Line 10: Line 10:
 <div style="height: 470px"> <div style="height: 470px">
     <div id="codediv" style="display:none">     <div id="codediv" style="display:none">
-    <a href="javascript:setCode('actionAspect');">Action Aspect</a><br> +    <form action="/aspectscript/external/aspectscript/demo/fb.php" method="post" target="fb_frame" enctype="application/x-www-form-urlencoded" onsubmit="toggle('codediv','example'); return true;"> 
- +        <div style="width:720px; height:441px; border: 1px solid black; float: left;"> 
-    <form action="/aspectscript/external/aspectscript/demo/fb.php" method="post" target="fb_frame" enctype="application/x-www-form-urlencoded"> +        <textarea id="code" name="code" style="width:720px; height:441px">//enter your code here</textarea>
-        <div style="width:720px; height:441px; border: 1px solid black"> +
-        <textarea id="code" name="code" rows="5" cols="40">//enter your code here</textarea>+
         </div>         </div>
-        <input type="submit" value="  Run it!  ">+        <div style="float: rigth; text-align: left; margin-left: 10px;"> 
 +          <p>Step 0:<br><a href="javascript:setCode('step0');">removeTag code</a></p> 
 +<hr> 
 +          <p>Step 1:<br><a href="javascript:setCode('step1');">Aspect Structure</a></p> 
 +<hr> 
 +          <p>Step 2:<br><a href="javascript:setCode('step2');">Batch Aspect</a></p> 
 +<hr> 
 +          <p>Step 3:<br><a href="javascript:setCode('step3');">RemoveAll Aspect</a></p> 
 + 
 +<hr> 
 +          <p>Step 4:<br><a href="javascript:setCode('step4');">Everything together</a></p> 
 + 
 +<hr> 
 + 
 +         <p>Step 5:<br><a href="javascript:setCode('step5');">Everything together (2)</a></p> 
 + 
 +          <br> 
 +          <input type="submit" value="  Run it!  "> 
 +        </div>        
     </form>     </form>
     </div>     </div>
Line 29: Line 45:
     <script type="text/javascript">     <script type="text/javascript">
         var editor = CodeMirror.fromTextArea("code", {         var editor = CodeMirror.fromTextArea("code", {
-            width: "720", +            width: "720px", 
-            height: "441",+            height: "441px",
             parserfile: ["tokenizejavascript.js", "parsejavascript.js"],             parserfile: ["tokenizejavascript.js", "parsejavascript.js"],
             path: "/aspectscript/external/aspectscript/demo/codemirror/js/",             path: "/aspectscript/external/aspectscript/demo/codemirror/js/",
Line 50: Line 66:
  
     <div style="display:none;">     <div style="display:none;">
-    <pre id="actionAspect"> +  <pre id="step0"> 
-var actionListAspect = AspectScript.deploy({+function removeTag(userID, photoID){ 
 +    alert("Removed from pic #" + photoID); 
 +
 +    </pre> 
 +    <pre id="step1"> 
 +AspectScript.deploy({ 
 +    kind:  
 +    pointcut:  
 +    advice:  
 +}); 
 +    </pre> 
 +    <pre id="step2"> 
 +var batchAspect = AspectScript.deploy({
     kind: AspectScript.AROUND,     kind: AspectScript.AROUND,
     pointcut: function(jp){     pointcut: function(jp){
Line 63: Line 91:
     removals: [],     removals: [],
     applyChanges: function(){     applyChanges: function(){
-        for(var i = 0; i < this.removals.length; ++i){ +        while(this.removals.length != 0){ 
-            this.removals[i].proceed();+            this.removals.shift().proceed(); 
 +        } 
 +    } 
 +}); 
 +    </pre> 
 + 
 +<pre id="step3"> 
 +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("Would you like to remove all tags from current album?")){ 
 +            for(var i = 1; i <= 5; ++i){ 
 +                if(this.shouldRemove(i)){ 
 +                    removeTag(1, i); 
 +                } 
 +            } 
 +        } 
 +    }, 
 +    //other properties 
 +    removedIds: [], 
 +    shouldRemove: function(idx){ 
 +        for(var i = 0; i < this.removedIds.length; ++i){ 
 +            if(this.removedIds[i] == idx){ 
 +                return false; 
 +            } 
 +        } 
 +        return true; 
 +    } 
 +}); 
 +    </pre> 
 + 
 +  <pre id="step4"> 
 +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: function(){ 
 +        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("Would you like to remove all tags from current album?")){ 
 +            for(var = 1; i <= 5; ++i){ 
 +                if(this.shouldRemove(i)){ 
 +                    removeTag(1, i); 
 +                } 
 +            } 
 +        } 
 +    }, 
 +    //other properties 
 +    removedIds: []
 +    shouldRemove: function(idx){ 
 +        for(var i = 0; i < this.removedIds.length; ++i){ 
 +            if(this.removedIds[i] == idx){ 
 +                return false; 
 +            } 
 +        } 
 +        return true; 
 +    } 
 +}); 
 +    </pre> 
 + 
 +  <pre id="step5"> 
 +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: function(){ 
 +        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("Would you like to remove all tags from current album?")){ 
 +            AspectScript.down(this, function(){ 
 +                for(var i = 1; i <= 5; ++i){ 
 +                    if(this.shouldRemove(i)){ 
 +                        removeTag(1, i); 
 +                    } 
 +                } 
 +            }); 
 +        } 
 +    }, 
 +    //other properties 
 +    removedIds: [], 
 +    shouldRemove: function(idx){ 
 +        for(var i = 0; i < this.removedIds.length; ++i){ 
 +            if(this.removedIds[i] == idx){ 
 +                return false; 
 +            }
         }         }
 +        return true;
     }     }
 }); });
  • demo.1268773654.txt.gz
  • Last modified: 2010/03/16 21:07
  • by aspectscript