Changeset 16972 for lang/actionscript
- Timestamp:
- 08/02/08 12:25:27 (4 months ago)
- Location:
- lang/actionscript/todoshare
- Files:
-
- 2 added
- 7 modified
- 1 moved
-
.actionScriptProperties (modified) (1 diff)
-
DBConsoleFlash.html (modified) (1 diff)
-
TodoShare.as (modified) (3 diffs)
-
bin-debug/TodoShare.swf (modified) (previous)
-
core/JsonScript.as (modified) (2 diffs)
-
js/common.js (modified) (3 diffs)
-
js/jsonScrOld.js (moved) (moved from lang/actionscript/todoshare/js/jsonScr.js)
-
netacho.html (added)
-
test/scriptTest.html (modified) (2 diffs)
-
test/test.jso (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/actionscript/todoshare/.actionScriptProperties
r16772 r16972 6 6 <libraryPathEntry kind="4" path=""> 7 7 <excludedEntries> 8 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_agent.swc" useDefaultLinkType="false"/> 8 9 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation.swc" useDefaultLinkType="false"/> 9 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_agent.swc" useDefaultLinkType="false"/>10 10 <libraryPathEntry kind="1" linkType="1" path="${PROJECT_FRAMEWORKS}/locale/{locale}"/> 11 11 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_flashflexkit.swc" useDefaultLinkType="false"/> 12 12 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/qtp.swc" useDefaultLinkType="false"/> 13 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/charts.swc" useDefaultLinkType="false"/> 13 14 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/rpc.swc" useDefaultLinkType="false"/> 14 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/ charts.swc" useDefaultLinkType="false"/>15 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_charts.swc" useDefaultLinkType="false"/> 15 16 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/datavisualization.swc" useDefaultLinkType="false"/> 16 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_charts.swc" useDefaultLinkType="false"/>17 17 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_dmv.swc" useDefaultLinkType="false"/> 18 18 <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/framework.swc" useDefaultLinkType="false"/> -
lang/actionscript/todoshare/DBConsoleFlash.html
r16014 r16972 53 53 } 54 54 } 55 setInterval("fetchEvents()",10); 56 </script><body><!-- 55 function start() { 56 setInterval("fetchEvents()",10); 57 } 58 59 </script><body onload="start()"><!-- 57 60 Object <input id=inp_obj type=text name=obj><BR> 58 61 Name <input id=inp_name type=text name=name><BR> -
lang/actionscript/todoshare/TodoShare.as
r16772 r16972 1 1 package { 2 2 import app.Todo; 3 4 import core.JsonScript; 3 5 4 6 import db.JSQL; … … 14 16 import flash.net.URLRequestMethod; 15 17 import flash.net.URLVariables; 18 19 import util.Debug; 16 20 [SWF(width="800",height="600",frameRate="24",backgroundColor="#FFFFFF")] 17 21 … … 48 52 inited=true; 49 53 //send(); 54 55 JsonScript.inst.registerAction("aho",function (a,b) { 56 Debug.p((a+b)+"!"); 57 }); 58 59 Debug.p("?"); 60 JsonScript.inst.exec(["aho",3,5]); 50 61 51 62 ExternalInterface.addCallback( -
lang/actionscript/todoshare/core/JsonScript.as
r16772 r16972 5 5 public static var NOP:JsonScriptAction= 6 6 new JsonScriptAction(function (){return this;}); 7 function static sequencial():JsonScriptAction{7 private function sequencial() { 8 8 var a:Array=arguments; 9 9 if (a.length==0) return NOP; 10 var firstExpr =a.shift();11 var firstAction =this.eval(firstExpr);10 var firstExpr:Object=a.shift(); 11 var firstAction:Object=this.eval(firstExpr); 12 12 if (a.length==0) return firstAction; 13 var env =this;13 var env:JsonScript=this; 14 14 var restAction=sequencial.apply(env,a); 15 15 return new JsonScriptAction(function () { 16 16 var state=this; 17 state=firstAction.apply(state );18 state=restAction.apply(state );17 state=firstAction.apply(state,[]); 18 state=restAction.apply(state,[]); 19 19 return state; 20 20 }); 21 21 } 22 22 public var functions:Object; 23 public static var inst:JsonScript=new JsonScript(); 23 24 public function JsonScript() 24 25 { … … 27 28 return sequencial.apply(this,arguments); 28 29 }); 29 registerFunction: function (name, f) { 30 this.functions[name]=f; 31 }, 32 registerAction : function (name, action) { 33 // env: for evaluating pure function 34 // state: for executing actions 35 36 this.registerFunction(name,function () { 37 var env=this; 38 var argActions=$A(arguments).map(function (expr) { 39 var r=env.eval(expr); 40 if (r instanceof JsonScriptAction) return r; 41 else return new JsonScriptAction(function () { 42 var state=this; 43 state.returnValue=r; 44 return state; 45 }); 46 }); 47 return new JsonScriptAction(function () { 48 var state=this; 49 var pass=argActions.map(function (act){ 50 state=act.apply(state); 51 return state.returnValue; 52 }); 53 state.returnValue=action.apply(state,pass); 54 return state; 55 }); 56 }); 57 }, 58 eval:function (expr) { 59 if (expr instanceof Array) { 60 var env=this; 61 var fname=expr.shift(); 62 var f=this.functions[fname]; 63 if (!f) throw fname+" is not function "; 64 return f.apply(env,expr); 65 } else return expr; 66 }, 67 compile:function (expr) {return this.eval(expr);}, 68 exec:function (prog) { 69 this.compile(prog).apply(this); 70 }, 71 handler: function(cmd) { 72 return "JsonScript.exec("+Object.toJSON(cmd)+")"; 73 } 74 }; 75 JsonScript=new JsonScriptClass(); 76 77 78 } 79 80 } 30 } 31 public function registerFunction(name:String, f:Function) { 32 this.functions[name]=f; 33 } 34 public function registerAction(name:String, action:Function):void { 35 // env: for evaluating pure function 36 // state: for executing actions 37 registerFunction(name,function () { 38 var env=this; 39 var argActions=arguments.map(function (expr) { 40 var r=env.eval(expr); 41 if (r instanceof JsonScriptAction) return r; 42 else return new JsonScriptAction(function () { 43 var state=this; 44 state.returnValue=r; 45 return state; 46 }); 47 }); 48 return new JsonScriptAction(function () { 49 var state=this; 50 var pass=argActions.map(function (act){ 51 state=act.apply(state,[]); 52 return state.returnValue; 53 }); 54 state.returnValue=action.apply(state,pass); 55 return state; 56 }); 57 }); 58 } 59 public function eval(expr:Object):Object { 60 if (expr instanceof Array) { 61 var env=this; 62 var fname=expr.shift(); 63 var f=this.functions[fname]; 64 if (!f) throw fname+" is not function "; 65 return f.apply(env,expr); 66 } else return expr; 67 } 68 public function compile(expr:Object):Object {return this.eval(expr);} 69 public function exec(prog:Object):void { 70 this.compile(prog).apply({},[]); 71 } 72 } 81 73 } -
lang/actionscript/todoshare/js/common.js
r16697 r16972 1 1 function db(cmd,onComplete) { 2 var env=this; 2 3 new Ajax.Request("db.cgi", { 3 4 method: "put", … … 5 6 onSuccess:function(httpObj){ 6 7 try { 7 onComplete (httpObj.responseText.evalJSON() );8 onComplete.apply(env, httpObj.responseText.evalJSON() ); 8 9 } catch(e) {print(e);} 9 10 }, … … 13 14 }); 14 15 } 16 function dbPut(query,after) { 17 db(["INSERT3",query],after); 18 } 19 dbPut.async=true; 20 function dbGet(query,after) { 21 db(["GET3",query],after); 22 } 23 dbGet.async=true; 24 25 Function.prototype.then=function (n) { 26 return function () { 27 return n(this.apply(this,arguments)); 28 }; 29 }; 15 30 var consoleBuf=""; 16 function print(m) { 17 var c=$("console"); 18 if (c) { 19 consoleBuf+=m+"\n"; 20 c.innerHTML=consoleBuf; 21 } else {alert(m);} 31 var indent=""; 32 function print() { 33 var app=indent; 34 $A(arguments).each(function (e) { 35 if (typeof(e)=="object") { 36 app+=Object.toJSON(e); 37 } else { 38 if (e==">") indent+="--"; 39 else if (e=="<") indent=indent.substring("--".length); 40 else app+=e; 41 } 42 }); 43 var c=$("console"); 44 if (c) { 45 consoleBuf+=app+"<BR>\n"; 46 c.innerHTML=consoleBuf; 47 } else {alert(app);} 22 48 } 23 49 function link2obj(id) { -
lang/actionscript/todoshare/test/scriptTest.html
r16713 r16972 2 2 <script src="../prototype.js"></script> 3 3 <script src="../js/jsonScr.js"></script> 4 <script src="../js/common.js"></script> 4 5 <script> 6 /*function a() { 7 alert("A " +this); 8 b.apply(this,[]); 9 } 10 function b() { 11 alert("B " +this); 12 } 13 a.apply("aho",[]); 14 a.apply("baka",[]); 5 15 6 7 16 a=[4,50,62]; 17 a.push(100); 18 alert(a.join(", ")); 19 function add5() { 20 var s=$("sp"); 21 s["innerHTML"]="Y"; 22 } 8 23 JsonScript.registerAction("test",function (x,y) { 9 24 alert(x+y); 10 25 }); 11 26 JsonScript.registerAction("alert",function (t) {alert("ALR"+t);}); 12 /*function add5() {13 14 }*/15 27 16 28 add5=JsonScript.compile(["PROGN", … … 19 31 ["alert","aho"] 20 32 ]); 21 /*add2=j.compile(["test",2,6]); 22 function add3() { 23 add2.apply(this); 24 }*/ 33 */ 34 function test(x,y) { 35 if (y==null) y=this._; 36 return x+y; 37 } 38 function testa(x,y,onEnd) { 39 onEnd.apply(this,[x+y]); 40 } 41 testa.async=true; 42 function show() { 43 print(this._); 44 } 45 function show2(x) { 46 print (x); 47 } 48 _=gv("_"); 49 function start() { 50 //print ("Aho =",["baka",3]); 51 add5=compile( 52 [testa,3,4], 53 show 54 ); 55 } 25 56 26 57 </script> 27 58 </head> 28 <body id="b" >59 <body id="b" onLoad="start()"> 29 60 <button onclick="add5()">+</button> 30 61 <HR> 62 <span id="console">X</span> 31 63 </body> 32 64
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)