check on the is_last condition fixed
[xynt.git] / prova.html
1 <html>
2 <head>
3 <script type="text/javascript" src="commons.js"></script>
4 <script type="text/javascript" src="xynt-dd.js"></script>
5 <script type="text/javascript" src="xynt-link.js"></script>
6 <script type="text/javascript">
7
8 function Adamo() {
9     this.name = "adamo";
10 }
11
12 Adamo.prototype = {
13     alupa: null,
14
15     pname: function()
16     {
17         console.log("NAME: "+this.name);
18     }
19 }
20
21 function Caino() {
22     this.super.constructor.call(this);
23     this.nname = "caino";
24 }
25
26 Caino.prototype = {
27     gojira: null,
28
29     pname2: function()
30     {
31         console.log("NAME:  "+this.name);
32         console.log("NNAME: "+this.nname);
33     }
34 }
35
36 function Extends_simple(sub, super)
37 {
38     var thinF = function(){};
39     thinF.prototype = super.prototype;
40     var tmp = new thinF();
41
42     for( var f in sub.prototype) {
43         tmp[f] = sub.prototype[f];
44         tmp['constructor'] = sub;
45     }
46     if( super.prototype.constructor == Object.prototype.constructor ){
47         super.prototype.constructor = super;
48     }
49     tmp['super'] = super.prototype;
50     sub.prototype = tmp;
51 }
52
53 Extends_simple(Caino, Adamo);
54
55 var c = new Caino();
56
57 console.log("A "+c.alupa);
58 console.log("G "+c.gojira);
59 console.log("U "+c.unko);
60
61 c.pname();
62 c.pname2();
63
64 function PreA() {
65     this.a_din = "adamo";
66 }
67
68 PreA.prototype = {
69     a_attr: "a attr content",
70     name: "PreA",
71
72     a_func: function()
73     {
74         console.log("A_NAME: "+this.a_din);
75         console.log("A_ATTR: "+this.a_attr);
76     }
77 }
78
79 function A() {
80     PreA.call(this);
81 }
82 A.prototype = {
83     name: "A"
84 }
85 Extends(A, PreA);
86
87 function B() {
88     this.b_din = "bonobo";
89 }
90
91 B.prototype = {
92     name: "B",
93     b_attr: "b attr content",
94
95     b_func: function()
96     {
97         console.log("B_NAME: "+this.b_din);
98         console.log("B_ATTR: "+this.b_attr);
99     }
100 }
101
102 function C() {
103     this.c_din = "canuca";
104 }
105
106 C.prototype = {
107     name: "C",
108     c_attr: "c attr content",
109
110     c_func: function()
111     {
112         console.log("C_NAME: "+this.c_din);
113         console.log("C_ATTR: "+this.c_attr);
114     }
115 }
116
117
118 function Summo() {
119     this.s_name = "caino";
120     A.call(this);
121     B.call(this);
122     C.call(this);
123
124 }
125
126 Summo.prototype = {
127     name: "Summo",
128     s_attr: null,
129
130     c_func: function()
131     {
132          console.log("c_func overwrited");
133     },
134
135     s_func: function()
136     {
137          this.a_func();
138          this.b_func();
139          this.c_func();
140          console.log("name: "+this.name);
141     }
142 }
143
144 Extends(Summo, A, B, C);
145
146 function Extends(sub)
147 {
148     var supers = [];
149
150     thinF = function(){};
151     tmp = new thinF();
152
153     console.log("INIZIO EXT");
154
155     var multi = function(sub, super, is_last)
156     {
157         var proto = super.prototype;
158
159         for (var f in proto) {
160             console.log("LOOP: "+f);
161             if( f != "constructor" && typeof(proto[f]) == "function" && !is_last){
162                 console.log("PR: "+proto['name']+"  F: "+f);
163                 // sub[f] = proto[f];
164                 sub[f] = function(){
165                     console.log("INFU PR: " + proto['name'] + " FUNC: "+f);
166                     return proto[f].apply(this,arguments);
167                 }
168             }
169             else {
170                 console.log("PR: "+proto.name+"  A: "+f+" FUN: "+proto[f]);
171                 sub[f] = proto[f];
172             }
173         }
174     }
175
176     for( var i=1; i < arguments.length ; i++){
177         console.log("INIZIO LOOP");
178         multi(tmp, arguments[i], false);
179         supers.push(arguments[i].prototype);
180     }
181     multi(tmp, sub, true);
182     sub.prototype = tmp;
183 }
184
185 s_ist = new Summo();
186 s_ist.s_func();
187
188 </script>
189
190 </head>
191 <body>
192 <!-- task:begin -->
193 <div id="board" style="width: 1600; height: 800px; background-color: #f0f0f0; border: 1px solid black; position: relative;">
194   <div id="r1" style="width: 1600; height: 40px; left: 0px; top: 0px; background-color: #e8e8e8; border: 0px solid red; position: absolute;">
195     <div id="t1" style="z-index: 1; left: 10px; top: 10px; width: 100px; height: 21px; border: 1px solid gray; background-color: #c0c0ff; position: absolute;"></div>
196   </div>
197   
198   <div id="r2" style="width: 1600;  left: 0px; top: 40px; height: 40px; background-color: #e8e8ff; border: 0px solid red; position: absolute;">
199     <div id="t2" style="z-index: 1; left: 123px; top: 10px; width: 100px; height: 21px; border: 1px solid gray; background-color: #c0ffc0; position: absolute;"></div>
200   </div>
201
202   <div id="r3" style="width: 1600; height: 40px; left: 0px; top: 80px; background-color: #e8e8e8; border: 0px solid red; position: absolute;">
203     <div id="t3" style="z-index: 1; left: 10px; top: 10px; width: 100px; height: 21px; border: 1px solid gray; background-color: #c0c0ff; position: absolute;"></div>
204   </div>
205   
206   <div id="r4" style="width: 1600;  left: 0px; top: 120px; height: 40px; background-color: #e8e8ff; border: 0px solid red; position: absolute;">
207     <div id="t4" style="z-index: 1; left: 123px; top: 10px; width: 100px; height: 21px; border: 1px solid gray; background-color: #c0ffc0; position: absolute;"></div>
208   </div>
209   
210   <!-- task:end -->
211   
212   
213 </div>
214 </body>
215 </html>