PageSourceSearch

https://www.muslumankalpler.com/static/component_handler.js

js muslumankalpler.com collected 2026-10-02 15:24:56 UTC 4,353 bytes, 217 lines download raw bytes

1
2window.thrown_backend_exceptions = {};
3
4function SK_ComponentHandler(cmp_prototype) {
5	var prop;
6	for (prop in cmp_prototype) {
7		this[prop] = cmp_prototype[prop];
8	}
9	
10	this.children = [];
11	this.forms = [];
12}
13
14SK_ComponentHandler.prototype =
15{
16	DOMConstruct: function(cmp_class, auto_id)
17	{
18		this.cmp_class = cmp_class;
19		this.auto_id = auto_id;
20		
21		this.container_node = jQuery('#'+auto_id).get(0);
22	},
23
24    /**
25     * @return jQuery
26     */
27	$: function(selector, context) {
28		selector = selector.replace('#', '#'+this.auto_id+'-');
29		context = context || this.container_node;
30		return jQuery(selector, context);
31	},
32
33	/**
34	 * @return SK_BlockHandler
35	 */
36	$block: function(selector)
37	{
38		var $block = this.$(selector);
39
40		if (!$block.length) {
41			throw 'block element not found';
42		}
43		if (!$block.get(0).sk_block_handler) {
44			throw 'element has no block handler';
45		}
46
47		return $block.get(0).sk_block_handler;
48	},
49	
50	/**
51	 * @return XMLHttpRequest
52	 */
53	ajax: function(options)
54	{
55        var handler = this;
56
57		var _opt = {
58			url: URL_RESPONDER + "?r=" + Math.random() * Date.parse(new Date()),
59			type: 'POST',
60			cache: false,
61			data: {
62				apply_func: options.apply_func,
63				params: encodeURIComponent( JSON.stringify(options.params) ),
64				COM_node: encodeURIComponent(
65					JSON.stringify( this.getAjaxCOMNode(options.full_COM) )
66				)
67			},
68			dataType: 'json',
69			beforeSend: function(xmlHttp)
70			{
71				xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
72			},
73			success: function(response)
74			{
75				if (response.errors) {
76					$(response.errors).each(function() {
77						handler.error(this);
78					});
79				}
80				
81				if (response.exec) {
82					response.exec.call(handler);
83				}
84				
85				if (options.success) {
86					options.success(response.data);
87				}
88			},
89			error: function(xhr) {
90				if (options.error) {
91					options.error(xhr);
92				} else {
93					// handling backend exception
94					var json_e = xhr.getResponseHeader('SK-Exception');
95					if (json_e) {
96						if (window.thrown_backend_exceptions[json_e]) {
97							return;
98						}
99						
100						eval("var e = "+json_e);
101						
102						e.toString = function() {
103							return e.message+"\ntrace: "+e.trace_str+"\nfile: "+e.file+" in line: "+e.line;
104						}
105						
106						window.thrown_backend_exceptions[json_e] = e;
107						
108						if (e.class_name == 'SK_HttpRequestException' && e.code == 1) {
109							// handling "Authentication required" exception
110							SK_SignIn().bind('close', function() {
111								window.location.reload();
112							});
113						}
114						else {
115							alert('An uncaught exception thrown:\n'+e.toString());
116						}
117					}
118					else if (typeof console != 'undefined' && console !== null ) {
119						console.error('http request error');
120					}
121				}
122			}
123		};
124		
125		if (options.complete) {
126			_opt.complete = options.complete;
127		}
128		
129		return $.ajax(_opt);
130	},
131	
132	/**
133	 * @return XMLHttpRequest
134	 */
135	ajaxCall: function(apply_func, params, options)
136	{
137		options = options || {};
138		
139		options.apply_func = apply_func;
140		options.params = params;
141		
142		return this.ajax(options);
143	},
144	
145	/**
146	 * @return XMLHttpRequest
147	 */
148	reload: function(params, options) {
149		params = params || {};
150		options = options || {};
151		options.full_COM = true;
152		return this.ajaxCall('reload', params, options);
153	},
154
155	/**
156	 * @return object
157	 */
158	getAjaxCOMNode: function(full_COM)
159	{
160		var COM_node = {
161			cmp_class: this.cmp_class,
162			auto_id: this.auto_id,
163			forms: []
164		};
165
166		if (this.parent) {
167			COM_node.parent = {
168				cmp_class: this.parent.cmp_class,
169				auto_id: this.parent.auto_id
170			}
171		}
172
173		var i, child, form;
174
175		if (full_COM) {
176			COM_node.children = [];
177			for (i = 0, child; child = this.children[i]; i++)
178			{
179				// filtering httpdoc canvas components
180				if (this.auto_id === 'httpdoc' &&
181					!$('#'+child.auto_id, this.container_node).length) {
182					continue;
183				}
184
185				COM_node.children.push(child.getAjaxCOMNode(true, false));
186			}
187		}
188
189		for (i = 0, form; form = this.forms[i]; i++)
190		{
191			COM_node.forms[i] = {
192				form_class: form.form_class,
193				auto_id: form.auto_id
194			}
195		}
196
197		return COM_node;
198	},
199	
200	error: function(err_msg) {
201		SK_drawError(err_msg);
202	},
203	
204	
205	message: function(msg_text) {
206		SK_drawMessage(msg_text);
207	},
208	
209	debug: function(a) {
210		if (console) {
211			console.debug(a);
212		}
213		else {
214			alert(JSON.stringify(a));
215		}
216	}
217}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.