Changeset 16713 for lang/actionscript

Show
Ignore:
Timestamp:
07/27/08 22:02:31 (5 years ago)
Author:
hoge1e3
Message:
 
Location:
lang/actionscript/todoshare
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/todoshare/index.cgi

    r16712 r16713  
    4545sub disp { 
    4646  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));  
     47JsonScript.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//   }); 
    5174}); 
    5275EOF 
    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"], 
    5578     [table(id=>$id),sub { 
    5679       my $p=shift; 
    57        my $res=&Obj::exe(["FINDREL",$id,any,any]); 
     80       my $res=&Obj::exe(["FINDREL",$id,any,any]);        
    5881       for (@$res) { 
    5982          my $action=toJSON( 
    6083             ["DELREL", $_->{obj},$_->{name},$_->{val}, $_->{t},$id ] 
    6184          ); 
     85          my $kms=toJSON(["KMS",$_->{obj}]); 
    6286          $p->p([&tr(id=>$_->{t}), 
    6387                [td,$_->{name}] , 
     
    6589                [td, 
    6690                   [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"] 
    6994                ] 
    7095             ]); 
  • lang/actionscript/todoshare/js/jsonScr.js

    r16711 r16713  
    11 
    2 JsonScript=Class.create (); 
    3 JsonScript.Action=Class.create(); 
    42 
    5 JsonScript.Action.prototype= { 
     3JsonScriptClass=Class.create (); 
     4JsonScriptAction=Class.create(); 
     5 
     6JsonScriptAction.prototype= { 
    67   initialize: function (a){this.f=a;}, 
    78   apply: function(t,args) { 
     
    1011   } 
    1112}; 
    12 JsonScript.NOP=new JsonScript.Action(function (){return this;}); 
     13JsonScriptNOP=new JsonScriptAction(function (){return this;}); 
    1314 
    1415function sequencial() { 
    1516        var a=$A(arguments); 
    16         if (a.length==0) return JsonScript.NOP; 
     17        if (a.length==0) return JsonScriptNOP; 
    1718        var firstExpr=a.shift(); 
    1819        var firstAction=this.eval(firstExpr); 
     
    2728        };  
    2829} 
    29 JsonScript.prototype={ 
     30JsonScriptClass.prototype={ 
    3031  initialize:function () {  
    3132     this.functions={}; 
     
    4546        var argActions=$A(arguments).map(function (expr) { 
    4647          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 () { 
    4950             var state=this; 
    5051             state.returnValue=r; 
     
    5253          }); 
    5354        }); 
    54         return new JsonScript.Action(function () { 
     55        return new JsonScriptAction(function () { 
    5556           var state=this; 
    5657           var pass=argActions.map(function (act){ 
     
    7576  exec:function (prog) { 
    7677     this.compile(prog).apply(this); 
     78  }, 
     79  handler: function(cmd) { 
     80     return "JsonScript.exec("+Object.toJSON(cmd)+")"; 
    7781  } 
    7882}; 
     83JsonScript=new JsonScriptClass(); 
     84 
    7985   
  • lang/actionscript/todoshare/js/tag.js

    r16709 r16713  
    3737function elemObj(target,o) { 
    3838  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     } 
    4048  } 
    4149} 
  • lang/actionscript/todoshare/perl/Tmpl.pm

    r16712 r16713  
    1919      script(src=>"suggest.js"), 
    2020      script(src=>"js/common.js"), 
     21      script(src=>"js/tag.js"), 
    2122      script(src=>"js/jsonScr.js"), 
    2223      [script,$opt->{script}], 
  • lang/actionscript/todoshare/test/scriptTest.html

    r16711 r16713  
    33<script src="../js/jsonScr.js"></script> 
    44<script> 
    5 j=new JsonScript(); 
    65 
    76 
    87 
    9 j.registerAction("test",function (x,y) { 
     8JsonScript.registerAction("test",function (x,y) { 
    109  alert(x+y); 
    1110}); 
    12 j.registerAction("alert",function (t) {alert("ALR"+t);}); 
     11JsonScript.registerAction("alert",function (t) {alert("ALR"+t);}); 
    1312/*function add5() { 
    1413    
    1514}*/ 
    1615 
    17 add5=j.compile(["PROGN", 
     16add5=JsonScript.compile(["PROGN", 
    1817     ["test",3,4], 
    1918     ["test",10,22], 
    2019     ["alert","aho"] 
    2120]); 
    22 add2=j.compile(["test",2,6]); 
     21/*add2=j.compile(["test",2,6]); 
    2322function add3() { 
    2423  add2.apply(this); 
    25 } 
     24}*/ 
    2625 
    2726</script> 
  • lang/actionscript/todoshare/test/tagTest.html

    r16711 r16713  
    33<script src="../prototype.js"></script> 
    44<script> 
     5function a() { 
     6   alert(32); 
     7}  
    58function add5() { 
    69  // alert(5); 
     
    1215      function (t) { 
    1316         elem(t,2+3); 
    14       } 
     17      }, 
     18      ["button",{onclick:a},"G"] 
    1519   ]); 
    1620   //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); 
    1927  } catch(e) {alert(e);throw e;} 
    2028}