Changeset 21586 for lang/javascript/nohada
- Timestamp:
- 10/18/08 18:58:27 (3 months ago)
- Location:
- lang/javascript/nohada
- Files:
-
- 22 modified
-
empty.html (modified) (2 diffs, 1 prop)
-
game.html (modified) (1 prop)
-
gameEdit.html (modified) (1 prop)
-
js/common.js (modified) (3 diffs)
-
js/findForm.js (modified) (3 diffs)
-
js/game/SpriteChar.class.js (modified) (3 diffs)
-
js/game/main.js (modified) (3 diffs)
-
js/gui.js (modified) (1 diff)
-
js/jsonScr.js (modified) (9 diffs)
-
js/jsonScrOld.js (modified) (6 diffs)
-
js/objEdit.js (modified) (2 diffs)
-
js/objEdit2.js (modified) (4 diffs)
-
js/reactor/Variable.class.js (modified) (3 diffs)
-
js/reactor/main.js (modified) (1 diff)
-
js/reactor/test2.js (modified) (1 diff)
-
js/tag.js (modified) (4 diffs)
-
jsonDB.html (modified) (1 diff, 1 prop)
-
netacho.html (modified) (3 diffs, 1 prop)
-
reactorTest.html (modified) (1 prop)
-
reactorTest2.html (modified) (1 prop)
-
textEdit.html (modified) (1 prop)
-
todoJS.html (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/nohada/empty.html
- Property svn:mime-type changed from text/html to text/html; charset=utf-8
r20319 r21586 2 2 <head> 3 3 <meta http-equiv="Content-type" content="text/html; charset=utf-8"> 4 <title> �A�v���P�[�V�����̃^�C�g��</title>4 <title>アプリケーションのタイトル</title> 5 5 <script src="js/prototype.js"></script> 6 6 <script src="js/suggest.js"></script> … … 14 14 </head> 15 15 <body id=body onLoad="main()"> 16 �� 16 内容 17 17 <HR> 18 18 <a href="./">Home</a><BR> -
lang/javascript/nohada/game.html
- Property svn:mime-type changed from text/html to text/html; charset=utf-8
-
lang/javascript/nohada/gameEdit.html
- Property svn:mime-type changed from text/html to text/html; charset=utf-8
-
lang/javascript/nohada/js/common.js
r19985 r21586 1 1 function db(cmd,onComplete) { 2 var env=this; 2 var env=this; 3 3 var j=Object.toJSON(cmd); 4 4 //if (j.indexOf("?")>=0) {print(j);print (encodeURI(j)); } 5 5 new Ajax.Request("index.cgi", { 6 6 method: "put", 7 parameters: 'cmd='+encodeURIComponent(j) ,7 parameters: 'cmd='+encodeURIComponent(j), 8 8 onSuccess:function(httpObj){ 9 9 try { … … 25 25 query.id=res[1]; 26 26 // print (query.id); 27 after.apply(this,arguments); 27 after.apply(this,arguments); 28 28 }]); 29 29 } … … 46 46 function link2obj(id) { 47 47 var href=encodeURI(id); 48 return "<a href=\"index.cgi?"+href+"\">"+id+"</a>"; 48 return "<a href=\"index.cgi?"+href+"\">"+id+"</a>"; 49 49 } -
lang/javascript/nohada/js/findForm.js
r19985 r21586 7 7 var e=tmpl[i]; 8 8 if (e instanceof SuggestBind) { 9 e.suggest=new Suggest.Local(e.input, e.suggestArea ,[], 9 e.suggest=new Suggest.Local(e.input, e.suggestArea ,[], 10 10 {ajaxAction: function(str,max,onEnd) { 11 11 var query={}; … … 21 21 db(["GET3",query],function (res) { 22 22 var cand=res.map(function (e) {return e[i];}); 23 23 24 24 onEnd(cand ); 25 25 }); … … 30 30 ); 31 31 } 32 } 32 } 33 33 }, 34 34 watch: function (listener) { 35 35 36 36 } 37 37 -
lang/javascript/nohada/js/game/SpriteChar.class.js
r20310 r21586 18 18 this.element.style.position="absolute"; 19 19 }, 20 undisplay: function (parent) { 21 parent.removeChild(this.element); 20 undisplay: function (parent) { 21 parent.removeChild(this.element); 22 22 }, 23 23 refresh: function () { … … 31 31 die: function () {this.isDead=true;this.onDie()}, 32 32 getkey: function (k) { 33 if (mousePressed) $keyCnt++; else $keyCnt=0; 33 if (mousePressed) $keyCnt++; else $keyCnt=0; 34 34 return $keyCnt; 35 35 }, … … 44 44 Math.abs(this.y-target.y)<this.height+target.height); 45 45 } 46 }; 46 }; -
lang/javascript/nohada/js/game/main.js
r20310 r21586 34 34 this.y-=5; 35 35 //this.x=$mouseX; 36 if (this.y<100 ) { 36 if (this.y<100 ) { 37 37 for (var i=Math.random(); i<6.28 ; i+=6.28/8) { 38 38 this.appear(new Ha2(this.x,this.y,Math.cos(i)*5,Math.sin(i)*5)); 39 39 //this.appear(new Ha2(this.x,this.y,Math.cos(i)*3,Math.sin(i)*3)); 40 40 } 41 this.die(); 41 this.die(); 42 42 } 43 43 }, … … 50 50 }, 51 51 onDie:function () { 52 52 53 53 }, 54 54 miss:function () { … … 69 69 main: function () { 70 70 this.element.innerHTML=this.c; 71 this.c--; 71 this.c--; 72 72 }, 73 73 onAppear: function () { -
lang/javascript/nohada/js/gui.js
r19985 r21586 1 1 function abutton(target,args) { 2 2 // do not call directly, call from tag library 3 // [abutton,{onClick=>[jsonScript ] }, "Caption"] 3 // [abutton,{onClick=>[jsonScript ] }, "Caption"] 4 4 var a=$(args); 5 5 var attr=a[0]; -
lang/javascript/nohada/js/jsonScr.js
r19985 r21586 10 10 function compile() { 11 11 var f=_compile($A(arguments)); 12 return function () { 12 return function () { 13 13 try { 14 14 state={target:this, arguments:arguments, flag:"OK"}; … … 33 33 first=$A(first); 34 34 _assert(first.length>0,"[] cannot compile"); 35 var opr=first.shift(); 35 var opr=first.shift(); 36 36 if (isFunc(opr)) { 37 37 return compileFunc(opr,compileArgs(first),_compile(scr)); … … 39 39 first.unshift(opr); 40 40 return compilePrimitive(first,_compile(scr)); 41 throw "Invalid operation "+Object.toJSON(opr); 41 throw "Invalid operation "+Object.toJSON(opr); 42 42 /*if (isObj(opr)) { 43 43 return compileObjOpr(opr,first,_compile(scr)); … … 80 80 return compilePrimitive(e,NOP); 81 81 }); 82 } 83 // compileFunc:: Function -> [(state->void)] -> (state->void) -> ( state -> void ) 82 } 83 // compileFunc:: Function -> [(state->void)] -> (state->void) -> ( state -> void ) 84 84 function compileFunc(func,args,next) { 85 85 if (isAsyncFunc(func)) { … … 88 88 if (isFunc(func)) { 89 89 return compileSync(func,args,next); 90 } 90 } 91 91 } 92 // compileSync:: Function -> [(state->void)] -> (state->void) -> ( state -> void ) 92 // compileSync:: Function -> [(state->void)] -> (state->void) -> ( state -> void ) 93 93 function compileSync(func,args,next) { 94 94 return function () { … … 100 100 }; 101 101 } 102 // compileAsync:: Function -> [(state->void)] -> (state->void) -> ( state -> void ) 102 // compileAsync:: Function -> [(state->void)] -> (state->void) -> ( state -> void ) 103 103 function compileAsync(afunc, args,next) { 104 104 return function () { … … 124 124 func.apply(env,[]); 125 125 //print ("<","PUSH ",env._," ",env.flag); 126 return env._; 126 return env._; 127 127 }); 128 128 env._=_save; … … 155 155 function isObj(o) { 156 156 return typeof(o)=="object"; 157 } 157 } 158 158 function isArray(o) { 159 159 return o instanceof Array; … … 179 179 } else { 180 180 if (e==">") indent+="--"; 181 else if (e=="<") indent=indent.substring("--".length); 181 else if (e=="<") indent=indent.substring("--".length); 182 182 else app+=e; 183 183 } -
lang/javascript/nohada/js/jsonScrOld.js
r19985 r21586 18 18 var firstExpr=a.shift(); 19 19 var firstAction=this.eval(firstExpr); 20 if (a.length==0) return firstAction; 20 if (a.length==0) return firstAction; 21 21 var env=this; 22 22 var restAction=sequencial.apply(env,a); … … 26 26 state=restAction.apply(state); 27 27 return state; 28 }; 28 }; 29 29 } 30 30 JsonScriptClass.prototype={ 31 initialize:function () { 31 initialize:function () { 32 32 this.functions={}; 33 33 this.registerFunction("PROGN",function () { … … 37 37 registerFunction: function (name, f) { 38 38 this.functions[name]=f; 39 }, 39 }, 40 40 registerAction : function (name, action) { 41 41 // env: for evaluating pure function 42 42 // state: for executing actions 43 43 44 44 this.registerFunction(name,function () { 45 45 var env=this; … … 62 62 return state; 63 63 }); 64 }); 64 }); 65 65 }, 66 66 eval:function (expr) { … … 70 70 var f=this.functions[fname]; 71 71 if (!f) throw fname+" is not function "; 72 return f.apply(env,expr); 73 } else return expr; 72 return f.apply(env,expr); 73 } else return expr; 74 74 }, 75 75 compile:function (expr) {return this.eval(expr);}, … … 83 83 JsonScript=new JsonScriptClass(); 84 84 85 -
lang/javascript/nohada/js/objEdit.js
r19985 r21586 13 13 setRelationFilter: function(filter) { 14 14 this.relationFilter=filter; 15 }, 15 }, 16 16 refresh: function () { 17 17 var t=this; … … 26 26 } 27 27 function attr(rel) { 28 return ["tr", 28 return ["tr", 29 29 ["td" , rel.name ], 30 30 ["td" , rel.val ] -
lang/javascript/nohada/js/objEdit2.js
r21329 r21586 3 3 initialize: function (target,objID) { 4 4 function inputField(attr) { 5 with (Reactor.Variable.use({N: attr.name, V: attr.val})) { 6 var b=elem(["button"]); 7 Reactor.addEvent(b,"onclick",[rel, {id:OBJID, name:N, val:V, t:attr.t}]); 8 return [ 9 ["input", {type:"text", value: N}], 10 ["input", {type:"text", value: V}], 11 b, 12 ["br"] 13 ]; 14 } 15 } 16 with (Reactor.Variable.setTo(this, "ATTRS","OBJID","T")) { 17 ATTRS.eq([rel, {id:OBJID, name: ["*"], val:["*"], t:["*"]} ]); 18 OBJID.setInitialValue(objID); 19 T.bind(target); 20 T.eq([map, inputField, ATTRS]); 5 with (Reactor.Variable.use({N: attr.name, V: attr.val})) { 6 var b=elem(["button"]); 7 Reactor.addEvent(b,"onclick",[rel, {id:OBJID, name:N, val:V, t:attr.t}]); 8 return [ 9 ["input", {type:"text", value: N}], 10 ["input", {type:"text", value: V}], 11 b, 12 ["br"] 13 ]; 14 } 21 15 } 22 this.target=target; 16 with (Reactor.Variable.setTo(this, "ATTRS","OBJID","T")) { 17 ATTRS.eq([rel, {id:OBJID, name: ["*"], val:["*"], t:["*"]} ]); 18 OBJID.setInitialValue(objID); 19 T.bind(target); 20 T.eq([map, inputField, ATTRS]); 21 } 22 this.target=target; 23 23 this.relationFilter=NOP; 24 24 if (this.target.appendChild==null) throw (id+" is not a element."); … … 26 26 test: function (target) { 27 27 with (Reactor.Variable.use("N","V","T","ATTRS","OBJID","TG")) { 28 var REL=[rel, {id:OBJID, name:N, val:V, t:T}];29 function inputField(attr) {30 var b=elem(["button"]);31 Reactor.addEvent(b,"onclick",REL);32 return [33 ["input", {type:"text", value: N}],34 ["input", {type:"text", value: V}],35 b, 36 ["br"]37 ];38 }39 ATTRS.eq(REL);40 OBJID.setInitialValue(objID);41 TG.bind(target);42 TG.eq([map, inputField, ATTRS]);43 } 28 var REL=[rel, {id:OBJID, name:N, val:V, t:T}]; 29 function inputField(attr) { 30 var b=elem(["button"]); 31 Reactor.addEvent(b,"onclick",REL); 32 return [ 33 ["input", {type:"text", value: N}], 34 ["input", {type:"text", value: V}], 35 b, 36 ["br"] 37 ]; 38 } 39 ATTRS.eq(REL); 40 OBJID.setInitialValue(objID); 41 TG.bind(target); 42 TG.eq([map, inputField, ATTRS]); 43 } 44 44 } 45 45 setObjectID: function (id) { … … 50 50 setRelationFilter: function(filter) { 51 51 this.relationFilter=filter; 52 }, 52 }, 53 53 refresh: function () { 54 54 var t=this; … … 63 63 } 64 64 function attr(rel) { 65 return ["tr", 66 ["td" , rel.name ],67 ["td" , rel.val ]65 return ["tr", 66 ["td", rel.name ], 67 ["td", rel.val ] 68 68 ]; 69 69 } -
lang/javascript/nohada/js/reactor/Variable.class.js
r21329 r21586 2 2 initialize:function (target) { 3 3 this.changeListeners=[]; 4 this.bind(target);4 this.bind(target); 5 5 }, 6 6 bind:function (target) { 7 if (target instanceof HTMLElement) {8 this.getter=function (){return target.value;} 9 this.setter=function (v){target.value=v;} 10 var t=this;11 addEventListener(target, "onchange", function () {12 t.notifyChange();13 });14 } else {15 setInitialValue(target);16 }7 if (target instanceof HTMLElement) { 8 this.getter=function (){return target.value;}; 9 this.setter=function (v){target.value=v;}; 10 var t=this; 11 addEventListener(target, "onchange", function () { 12 t.notifyChange(); 13 }); 14 } else { 15 setInitialValue(target); 16 } 17 17 }, 18 18 setInitialValue:function (target) { 19 this.getter=function (){return target;};20 this.setter=function (nv){target=nv;};19 this.getter=function (){return target;}; 20 this.setter=function (nv){target=nv;}; 21 21 }, 22 22 eq:function (expr) { 23 var func,argVars=[];24 var t=this;23 var func,argVars=[]; 24 var t=this; 25 25 var recalc=function () { 26 var argVals=argVars.map(function (e) {return e.getter();});27 t.setValue( func.apply(this,argVals) );28 };26 var argVals=argVars.map(function (e) {return e.getter();}); 27 t.setValue( func.apply(this,argVals) ); 28 }; 29 29 if (expr instanceof Array) { 30 expr.each(function (e,i) {31 if (i==0) {32 if (e instanceof Function) {33 func=e;34 } else {35 alert("NOT a function");36 } 37 } else {38 if (e instanceof Array) {39 var v=new Reactor.Variable();40 v.eq(e);41 e=v;42 }43 if (e instanceof Reactor.Variable) {44 e.addChangeListener(recalc);45 argVars.push(e);46 } else {47 argVars.push({getter:function (){return e;}});48 }49 }50 });51 recalc();52 } else alert("Not an array expr.");30 expr.each(function (e,i) { 31 if (i==0) { 32 if (e instanceof Function) { 33 func=e; 34 } else { 35 alert("NOT a function"); 36 } 37 } else { 38 if (e instanceof Array) { 39 var v=new Reactor.Variable(); 40 v.eq(e); 41 e=v; 42 } 43 if (e instanceof Reactor.Variable) { 44 e.addChangeListener(recalc); 45 argVars.push(e); 46 } else { 47 argVars.push({getter:function (){return e;}}); 48 } 49 } 50 }); 51 recalc(); 52 } else alert("Not an array expr."); 53 53 }, 54 54 addChangeListener: function (fun) { … … 56 56 }, 57 57 notifyChange: function () { 58 var v=this.getter();59 this.changeListeners.each(function (e) {60 e(v);61 });58 var v=this.getter(); 59 this.changeListeners.each(function (e) { 60 e(v); 61 }); 62 62 }, 63 63 setValue: function (v) { 64 64 if (v==this.getter()) return; 65 65 this.setter(v); 66 this.notifyChange();66 this.notifyChange(); 67 67 }, 68 68 next:function () { 69 // return V{n+1} 69 // return V{n+1}; 70 70 } 71 71 }); … … 75 75 elemNames.each(function (elemName) { 76 76 res[elemName]=new Reactor.Variable( $(elemName) ); 77 }) 77 }); 78 78 return res; 79 79 }; -
lang/javascript/nohada/js/reactor/main.js
r21329 r21586 3 3 } 4 4 function and() { 5 5 6 6 } 7 7 function eq(left,right) { -
lang/javascript/nohada/js/reactor/test2.js
r21329 r21586 4 4 function add(a,b){return (parseInt(a)+parseInt(b))+"";} 5 5 with ($bind("SRC","DST")) {
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)