Changeset 36031

Show
Ignore:
Timestamp:
11/29/09 12:53:16 (3 years ago)
Author:
hoge1e3
Message:
 
Location:
lang/haxe/Tonyu2
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • lang/haxe/Tonyu2/File.hx

    r36012 r36031  
    1414                return buf; 
    1515        } 
     16        public static function ls(dir:String):Array<String> { 
     17                var files=neko.FileSystem.readDirectory(dir); 
     18                return files; 
     19        } 
    1620} 
  • lang/haxe/Tonyu2/Project.hx

    r36012 r36031  
    1111                f.close(); 
    1212                return buf;*/ 
     13        } 
     14        public function listTonyuSources():Array<String> { 
     15                var files=neko.FileSystem.readDirectory(getTonyuDir()); 
     16                var f; 
     17                var res=[]; 
     18                var tnf=~/^(\w[\w\d]+)\.tonyu$/; 
     19                for (f in files) { 
     20                        if(tnf.match(f)) { 
     21                                var cln=tnf.matched(1); 
     22                                res.push(cln); 
     23                        } 
     24                } 
     25                return res; 
    1326        } 
    1427        public function compile1Class(c:grm.Context,className:String) { 
  • lang/haxe/Tonyu2/htdocs/Project.class.js

    r36014 r36031  
     1function procAjax(p) { 
     2   return function (res) { 
     3     try { 
     4        p(res.responseText,res); 
     5     } catch(e) {alert(e);} 
     6   }; 
     7} 
    18Project =Class.create({ 
    29        initialize: function (name) { 
    310           this.name=name; 
     11           this.homeURL="project/"+name; 
     12           this.tonyuSrcURL=this.homeURL+"/tonyuSrc"; 
    413        }, 
    514        open: function () { 
    615                this.editor=tag("textarea",{rows:25 , cols:80}); 
    7                 $tag("body").set([["div", "プロジェクト", this.name], this.editor ]); 
     16                this.fileList=tag("div"); 
     17                $tag("body").set([["div", "プロジェクト", this.name], 
     18           this.fileList, this.editor]); 
    819                attachIndentAdaptor(this.editor.target); 
     20                this.listTonyuSource(); 
    921        }, 
    10         loadTonyuSource: function(className) { 
    11                 this.editor.value="Load "+className; 
     22        listTonyuSource: function() { 
     23             new Ajax.Request( 
     24                        this.tonyuSrcURL ,  
     25                        { 
     26                                method: 'GET',  
     27                                parameters: {},  
     28                                onComplete: procAjax(showResponse) 
     29                        }); 
     30                 var t=this; 
     31                 function showResponse(res) { 
     32                           t.fileList.set(); 
     33                       res.split(/\n/).each(function (r) { 
     34                               t.fileList.add(["div", 
     35                                        ["a",{onclick: function () { 
     36                                          t.openTonyuSource(r); 
     37                                                }},r]]); 
     38                           }); 
     39                 } 
     40        }, 
     41        openTonyuSource: function (name) { 
     42                new Ajax.Request( 
     43                        this.tonyuSrcURL+"/"+name ,  
     44                        { 
     45                                method: 'GET',  
     46                                parameters: {},  
     47                                onComplete: procAjax(showResponse) 
     48                        }); 
     49                var t=this;      
     50                function showResponse(res) { 
     51                        t.editor.setAttr("value",res); 
     52                } 
    1253        } 
    1354}); 
  • lang/haxe/Tonyu2/htdocs/TagBuilder.class.js

    r36011 r36031  
    8383   setAttr: function (k,v) { 
    8484       if (arguments.length==2) { 
    85               k={k:v}; 
     85              var p={};p[k]=v; 
     86                  k=p; 
    8687       } 
    8788           return this.addObj(k); 
     
    289290                } 
    290291             } else { 
     292                    //alert("Setting "+i+" -> "+ o[i]); 
    291293               target[i]=o[i]; 
    292294             } 
  • lang/haxe/Tonyu2/ide/Main.hx

    r36015 r36031  
    77 
    88        static function main() { 
     9                trace("http://localhost:5000/ にアクセスしてください"); 
    910            httpd.Server.start(5000, loop );             
    1011        } 
     
    3738            res.header.set("Content-type","text/plain; charset=utf8"); 
    3839                var pName=path.shift(); 
     40                if (pName==null || pName=="") { 
     41                    listProject(res); 
     42                        return; 
     43                } 
    3944                var p=getProject(pName); 
    4045                var resource=path.shift(); 
     
    4247                    var name=path.shift(); 
    4348                        if (name==null || name=="") { 
    44                            res.content=p.listTonyuSource().join("\n"); 
     49                           res.content=p.listTonyuSources().join("\n"); 
    4550                        } else { 
    46                        res.content=p.getTonyuSource(path.shift()); 
     51                       res.content=p.getTonyuSource(name); 
    4752                        } 
    4853                }  else { 
    4954                   res.content="invalid request in: "+p+"  "+resource+"  path="+path; 
    5055                } 
     56        } 
     57        static function listProject(res:httpd.Response) {  
     58            res.content=File.ls(projectPath).join("\n");         
    5159        } 
    5260        static var htdocsPath="htdocs";