Changeset 16713 for lang/actionscript
- Timestamp:
- 07/27/08 22:02:31 (5 years ago)
- Location:
- lang/actionscript/todoshare
- Files:
-
- 6 modified
-
index.cgi (modified) (2 diffs)
-
js/jsonScr.js (modified) (6 diffs)
-
js/tag.js (modified) (1 diff)
-
perl/Tmpl.pm (modified) (1 diff)
-
test/scriptTest.html (modified) (1 diff)
-
test/tagTest.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/actionscript/todoshare/index.cgi
r16712 r16713 45 45 sub disp { 46 46 my $scr=<<'EOF'; 47 j=new JsonScript(); 48 j.registerAction("DELREL",function (obj,name,val,td,table) { 49 print("DE "+ obj+ " "+name+" "+val+" "+td+" "+table ); 50 $(table).firstChild/*tbody*/.removeChild($(td)); 47 JsonScript.registerAction("DELREL",function (obj,name,val,td,table) { 48 // db(["DELREL",obj,name,val],function (res) { 49 // print("DE "+ Object.toJSON(res) ); 50 $(table).firstChild/*tbody*/.removeChild($(td)); 51 var id=""+new Date(); 52 try{ 53 elem( $(table).firstChild, 54 ["tr", 55 ["td", 56 ["input",{type:"text", id:id+"name", value:name}] 57 ], 58 ["td", 59 ["input",{type:"text", id:id+"val", value:val}] 60 ], 61 ["td", 62 ["button",{ 63 id:id+"button", 64 onclick:function () { 65 print ( 66 (id+"name")+ 67 (id+"val") ); 68 } 69 },"Add"] 70 ] 71 ] 72 ); } catch(e) {alert(e);} 73 // }); 51 74 }); 52 75 EOF 53 &Tmpl::page({title=>$id,script=>$scr},[span ,54 [strong ,img(src=>"img/obj.png"),"$id"],76 &Tmpl::page({title=>$id,script=>$scr},[span(id=>"top"), 77 [strong(id=>"head"),img(src=>"img/obj.png"),"$id"], 55 78 [table(id=>$id),sub { 56 79 my $p=shift; 57 my $res=&Obj::exe(["FINDREL",$id,any,any]); 80 my $res=&Obj::exe(["FINDREL",$id,any,any]); 58 81 for (@$res) { 59 82 my $action=toJSON( 60 83 ["DELREL", $_->{obj},$_->{name},$_->{val}, $_->{t},$id ] 61 84 ); 85 my $kms=toJSON(["KMS",$_->{obj}]); 62 86 $p->p([&tr(id=>$_->{t}), 63 87 [td,$_->{name}] , … … 65 89 [td, 66 90 [button( 67 onClick=>qq(j.exec($action)) 68 ) ,"Forget"] 91 onClick=>qq(JsonScript.exec($action)) 92 ) ,"Forget"], 93 [button(onClick=>qq(JsonScript.exec($kms)) ),"View"] 69 94 ] 70 95 ]); -
lang/actionscript/todoshare/js/jsonScr.js
r16711 r16713 1 1 2 JsonScript=Class.create ();3 JsonScript.Action=Class.create();4 2 5 JsonScript.Action.prototype= { 3 JsonScriptClass=Class.create (); 4 JsonScriptAction=Class.create(); 5 6 JsonScriptAction.prototype= { 6 7 initialize: function (a){this.f=a;}, 7 8 apply: function(t,args) { … … 10 11 } 11 12 }; 12 JsonScript .NOP=new JsonScript.Action(function (){return this;});13 JsonScriptNOP=new JsonScriptAction(function (){return this;}); 13 14 14 15 function sequencial() { 15 16 var a=$A(arguments); 16 if (a.length==0) return JsonScript .NOP;17 if (a.length==0) return JsonScriptNOP; 17 18 var firstExpr=a.shift(); 18 19 var firstAction=this.eval(firstExpr); … … 27 28 }; 28 29 } 29 JsonScript .prototype={30 JsonScriptClass.prototype={ 30 31 initialize:function () { 31 32 this.functions={}; … … 45 46 var argActions=$A(arguments).map(function (expr) { 46 47 var r=env.eval(expr); 47 if (r instanceof JsonScript .Action) return r;48 else return new JsonScript .Action(function () {48 if (r instanceof JsonScriptAction) return r; 49 else return new JsonScriptAction(function () { 49 50 var state=this; 50 51 state.returnValue=r; … … 52 53 }); 53 54 }); 54 return new JsonScript .Action(function () {55 return new JsonScriptAction(function () { 55 56 var state=this; 56 57 var pass=argActions.map(function (act){ … … 75 76 exec:function (prog) { 76 77 this.compile(prog).apply(this); 78 }, 79 handler: function(cmd) { 80 return "JsonScript.exec("+Object.toJSON(cmd)+")"; 77 81 } 78 82 }; 83 JsonScript=new JsonScriptClass(); 84 79 85 -
lang/actionscript/todoshare/js/tag.js
r16709 r16713 37 37 function elemObj(target,o) { 38 38 for (var i in o) { 39 target[i]=o[i]; 39 if (i.match(/^on/)) { 40 if (target.addEventListener) { 41 target.addEventListener(i.substring(2),o[i],false); 42 } else { 43 target.attachEvent(i,o[i]); 44 } 45 } else { 46 target[i]=o[i]; 47 } 40 48 } 41 49 } -
lang/actionscript/todoshare/perl/Tmpl.pm
r16712 r16713 19 19 script(src=>"suggest.js"), 20 20 script(src=>"js/common.js"), 21 script(src=>"js/tag.js"), 21 22 script(src=>"js/jsonScr.js"), 22 23 [script,$opt->{script}], -
lang/actionscript/todoshare/test/scriptTest.html
r16711 r16713 3 3 <script src="../js/jsonScr.js"></script> 4 4 <script> 5 j=new JsonScript();6 5 7 6 8 7 9 j.registerAction("test",function (x,y) {8 JsonScript.registerAction("test",function (x,y) { 10 9 alert(x+y); 11 10 }); 12 j.registerAction("alert",function (t) {alert("ALR"+t);});11 JsonScript.registerAction("alert",function (t) {alert("ALR"+t);}); 13 12 /*function add5() { 14 13 15 14 }*/ 16 15 17 add5= j.compile(["PROGN",16 add5=JsonScript.compile(["PROGN", 18 17 ["test",3,4], 19 18 ["test",10,22], 20 19 ["alert","aho"] 21 20 ]); 22 add2=j.compile(["test",2,6]);21 /*add2=j.compile(["test",2,6]); 23 22 function add3() { 24 23 add2.apply(this); 25 } 24 }*/ 26 25 27 26 </script> -
lang/actionscript/todoshare/test/tagTest.html
r16711 r16713 3 3 <script src="../prototype.js"></script> 4 4 <script> 5 function a() { 6 alert(32); 7 } 5 8 function add5() { 6 9 // alert(5); … … 12 15 function (t) { 13 16 elem(t,2+3); 14 } 17 }, 18 ["button",{onclick:a},"G"] 15 19 ]); 16 20 //elem( $("b"),"X"); 17 //$("b").appendChild(document.createTextNode("Y")); 18 //alert(3); 21 // var bb=document.createElement("button"); 22 // bb.attachEvent("onclick",a); 23 // bb.addEventListener("click",a,false); 24 // elem(bb,"C"); 25 // $("b").appendChild(bb); 26 //alert(3); 19 27 } catch(e) {alert(e);throw e;} 20 28 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)