de807ff96936a13cb5357986367fab7055b88802
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

1) /*
2) 	
3) 	IRC-Bot "Kvasir"
4)     Copyright (C) 2016	Fenris Wolf (fenris@folksprak.org)
5) 	
6)     This program is free software: you can redistribute it and/or modify
7)     it under the terms of the GNU General Public License as published by
8)     the Free Software Foundation, either version 3 of the License, or
9)     (at your option) any later version.
10) 	
11)     This program is distributed in the hope that it will be useful,
12)     but WITHOUT ANY WARRANTY; without even the implied warranty of
13)     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14)     GNU General Public License for more details.
15) 	
16)     You should have received a copy of the GNU General Public License
17)     along with this program.  If not, see <http://www.gnu.org/licenses/>.
18)        
19) */
20) 
21) var _fs = require("fs");
22) 
23) 	
24) /**
25)  * @author fenris
26)  */
27) class klaso_kromajxo_ekstera extends klaso_kromajxo
28) {
29) 	
30) 	/**
31) 	 * @author fenris
32) 	 */
33) 	protected vojo : string;
34) 	
35) 	
36) 	/**
37) 	 * @author fenris
38) 	 */
39) 	protected memoro : Object;
40) 	
41) 	
42) 	/**
43) 	 * @author fenris
44) 	 */
45) 	protected reagi_ : (enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void, memoro ?: Object)=>void;
46) 	
47) 	
Fenris Wolf 'starigi'-metodo por kromaj...

Fenris Wolf authored 7 years ago

48) 	/**
49) 	 * @author fenris
50) 	 */
51) 	protected starigi_ : (finado : (eraro ?: Error)=>void, memoro ?: Object)=>void;
52) 	
53) 	
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

54) 	/**
55) 	 * @author fenris
56) 	 */
57) 	public constructor
58) 	(
59) 		identigilo : string = null,
60) 		nomo : string = null,
61) 		priskribo : string = null,
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

62) 		uzo : string = null,
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

63) 		auxtoro : string = null,
Fenris Wolf 'starigi'-metodo por kromaj...

Fenris Wolf authored 7 years ago

64) 		starigi_ : (finado : (eraro ?: Error)=>void, memoro ?: Object)=>void = (finado => finado(null)),
65) 		reagi_ : (enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void)=>void = null
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

66) 	)
67) 	{
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

68) 		super(identigilo, nomo, priskribo, uzo, auxtoro);
Fenris Wolf 'starigi'-metodo por kromaj...

Fenris Wolf authored 7 years ago

69) 		this.starigi_ = starigi_;
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

70) 		this.reagi_ = reagi_;
71) 		this.vojo = null;
72) 		this.memoro = {};
73) 	}
74) 	
75) 	
76) 	/**
77) 	 * @author fenris
78) 	 */
79) 	public resxargi(fino : (eraro : Error)=>void = function (eraro : Error) : void {}) : void
80) 	{
81) 		let that : klaso_kromajxo_ekstera = this;
82) 		klaso_kromajxo_ekstera.sxargi
83) 		(
84) 			this.vojo,
85) 			function (eraro : Error, datumoj : Object) : void
86) 			{
87) 				if (eraro != null)
88) 				{
89) 					fino(eraro);
90) 				}
91) 				else
92) 				{
93) 					that.nomo = datumoj["nomo"];
94) 					that.priskribo = datumoj["priskribo"];
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

95) 					that.uzo = datumoj["uzo"];
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

96) 					that.auxtoro = datumoj["auxtoro"];
Fenris Wolf 'starigi'-metodo por kromaj...

Fenris Wolf authored 7 years ago

97) 					that.starigi_ = datumoj["starigi"];
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

98) 					that.reagi_ = datumoj["reagi"];
Fenris Wolf 'starigi'-metodo por kromaj...

Fenris Wolf authored 7 years ago

99) 					that.starigi
100) 					(
101) 						function (eraro_ : Error) : void
102) 						{
103) 							if (eraro_ != null)
104) 							{
105) 								fino(eraro_);
106) 							}
107) 							else
108) 							{
109) 								fino(null);
110) 							}
111) 						}
112) 					);
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

113) 				}
114) 			}
115) 		);
116) 	}
117) 	
118) 	
119) 	/**
120) 	 * @author fenris
Fenris Wolf 'starigi'-metodo por kromaj...

Fenris Wolf authored 7 years ago

121) 	 * @override
122) 	 */
123) 	public starigi(finado : (eraro ?: Error)=>void) : void
124) 	{
125) 		this.starigi_(finado, this.memoro);
126) 	}
127) 	
128) 	
129) 	/**
130) 	 * @author fenris
131) 	 * @override
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

132) 	 */
133) 	protected reagi(enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void) : void
134) 	{
135) 		this.reagi_(enigo_kruda, eligi, this.memoro);
136) 	}
137) 	
138) 
139) 	/**
140) 	 * @author fenris
141) 	 */
142) 	protected static sxargi(vojo : string, uzado : (eraro : Error, datumoj : Object)=>void) : void
143) 	{
144) 		_fs.readFile
145) 		(
146) 			vojo,
147) 			{"encoding": "utf8", "flag": "r"},
148) 			function (eraro : Error, enhavo : string) : void
149) 			{
150) 				if (eraro != null)
151) 				{
152) 					uzado(eraro, null);
153) 				}
154) 				else
155) 				{
156) 					try
157) 					{
158) 						let datumoj : Object = eval("(function () {return (" + enhavo + ");})()");
159) 						uzado(null, datumoj);
160) 					}
161) 					catch (escepto)
162) 					{
163) 						uzado(new Error(String(escepto)), null);
164) 					}
165) 				}
166) 			}
167) 		);
168) 	}
169) 	
170) 	
171) 	/**
172) 	 * @author fenris
173) 	 */
174) 	public static krei(vojo : string, uzado : (eraro : Error, kromajxo : klaso_kromajxo_ekstera)=>void) : void
175) 	{
176) 		klaso_kromajxo_ekstera.sxargi
177) 		(
178) 			vojo,
179) 			function (eraro : Error, datumoj : Object) : void
180) 			{
181) 				if (eraro != null)
182) 				{
183) 					uzado(eraro, null);
184) 				}
185) 				else
186) 				{
187) 					let kromajxo : klaso_kromajxo_ekstera = new klaso_kromajxo_ekstera
188) 					(
189) 						datumoj["identigilo"],
190) 						datumoj["nomo"],
191) 						datumoj["priskribo"],
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

192) 						datumoj["uzo"],
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

193) 						datumoj["auxtoro"],
Fenris Wolf 'starigi'-metodo por kromaj...

Fenris Wolf authored 7 years ago

194) 						datumoj["starigi"],