first simple inheritance function
[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(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(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
65
66 if (0 == 1) {
67 var thinF = function(){};
68 thinF.prototype = super.prototype;
69 sub.prototype = new thinF();
70 sub.prototype.constructor = sub;
71 sub.super = super.prototype;
72 if( super.prototype.constructor == Object.prototype.constructor ){
73     super.prototype.constructor = super;
74 }
75
76 var a = new Adamo();
77 var c = new Caino();
78
79
80 c.pname();
81 }
82
83 /*
84
85 var thinF = function(){};
86 thinF.prototype = super.prototype;
87 sub.prototype = new thinF();
88
89 05.    sub.prototype.constructor = sub;
90 06.    sub.super = super.prototype;
91 07.    if( super.prototype.constructor == Object.prototype.constructor ){
92 08.    super.prototype.constructor = super;
93 */
94
95 </script>
96
97 </head>
98 <body>
99 <!-- task:begin -->
100 <div id="board" style="width: 1600; height: 800px; background-color: #f0f0f0; border: 1px solid black; position: relative;">
101   <div id="r1" style="width: 1600; height: 40px; left: 0px; top: 0px; background-color: #e8e8e8; border: 0px solid red; position: absolute;">
102     <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>
103   </div>
104   
105   <div id="r2" style="width: 1600;  left: 0px; top: 40px; height: 40px; background-color: #e8e8ff; border: 0px solid red; position: absolute;">
106     <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>
107   </div>
108
109   <div id="r3" style="width: 1600; height: 40px; left: 0px; top: 80px; background-color: #e8e8e8; border: 0px solid red; position: absolute;">
110     <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>
111   </div>
112   
113   <div id="r4" style="width: 1600;  left: 0px; top: 120px; height: 40px; background-color: #e8e8ff; border: 0px solid red; position: absolute;">
114     <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>
115   </div>
116   
117   <!-- task:end -->
118   
119   
120 </div>
121 </body>
122 </html>