PageSourceSearch

https://egymonuments.gov.eg/App_Plugins/Terratype/scripts/terratype.renderer.js?cache=1.0.21

js egymonuments.gov.eg collected 2026-09-24 08:57:12 UTC 15,342 bytes, 462 lines download raw bytes

1(function (root) {
2	if (!root.terratype) {
3		root.terratype = {
4			_poll: 100,
5			_killSwitch: 1200,
6			providers: {},
7			_addProvider: function (id, obj) {
8				if (root.terratype.providers[id]) {
9					root.terratype.providers[id] = root.terratype._mergeJson(root.terratype.providers[id], obj);
10				} else {
11					root.terratype.providers[id] = obj;
12				}
13				root.terratype.providers[id]._status = 0;
14				root.terratype.providers[id]._domDetectionType = 99;
15			},
16			coordinateSystems: {},
17			_addCoordinateSystem: function (id, obj) {
18				if (root.terratype.coordinateSystems[id]) {
19					root.terratype.coordinateSystems[id] = root.terratype._mergeJson(root.terratype.coordinateSystems[id], obj);
20				} else {
21					root.terratype.coordinateSystems[id] = obj;
22				}
23			},
24			_events: [[],[],[],[],[],[]],
25			_addEvent: function (i, f) {
26				root.terratype._events[i].push(f);
27			},
28			_callEvent: function (i, a, b, c) {
29				root.terratype._forEach(root.terratype._events[i], function (index, func) {
30					(function (f, a, b, c){ f(a, b, c); })(func, a, b, c);
31				});
32			},
33			onInit: function (f) {
34				root.terratype._addEvent(0, f);
35			},
36			_callInit: function (provider) {
37				root.terratype._callEvent(0, provider);
38			},
39			onLoad: function (f) {
40				root.terratype._events[1].push(f);
41			},
42			_callLoad: function (provider, map) {
43				root.terratype._callEvent(1, provider, map);
44			},
45			onRender: function (f) {
46				root.terratype._events[2].push(f);
47			},
48			_callRender: function (provider, map) {
49				root.terratype._callEvent(2, provider, map);
50			},
51			onRefresh: function (f) {
52				root.terratype._events[3].push(f);
53			},
54			_callRefresh: function (provider, map) {
55				root.terratype._callEvent(3, provider, map);
56			},
57			onClick: function (f) {
58				root.terratype._events[4].push(f);
59			},
60			_callClick: function (provider, map, marker) {
61				root.terratype._callEvent(4, provider, map, marker);
62			},
63			onZoom: function (f) {
64				root.terratype._events[5].push(f);
65			},
66			_callZoom: function (provider, map, zoomLevel) {
67				root.terratype._callEvent(5, provider, map, zoomLevel);
68			},
69			_forEach: function (obj, func) {
70				for (var i = 0; i != obj.length; i++) {
71					(function (f, i, o) { f(i, o); })(func, i, obj[i]);
72				}
73			},
74			_mergeJson: function (aa, bb) {        //  Does not merge arrays
75				var mi = function (c) {
76					var t = {};
77					for (var k in c) {
78						if (c[k] && typeof c[k] === 'object' && c[k].constructor.name !== 'Array') {
79							t[k] = mi(c[k]);
80						} else {
81							t[k] = c[k];
82						}
83					}
84					return t;
85				}
86				var mo = function (a, b) {
87					var r = (a) ? mi(a) : {};
88					if (b) {
89						for (var k in b) {
90							if (r[k] && typeof r[k] === 'object' && r[k].constructor.name !== 'Array') {
91								r[k] = mo(r[k], b[k]);
92							} else {
93								r[k] = b[k];
94							}
95						}
96					}
97					return r;
98				}
99				return mo(aa, bb);
100			},
101			_configIconUrl: function (url) {
102				if (typeof (url) === 'undefined' || url == null) {
103					return '';
104				}
105				if (url.indexOf('//') != -1) {
106					//  Is an absolute address
107					return url;
108				}
109				//  Must be a relative address
110				if (url.substring(0, 1) != '/') {
111					url = '/' + url;
112				}
113
114				return root.location.protocol + '//' + root.location.hostname + (root.location.port ? ':' + root.location.port : '') + url;
115			},
116			_getAnchorHorizontal: function (text, width) {
117				if (typeof text == 'string') {
118					switch (text.charAt(0)) {
119						case 'l':
120						case 'L':
121							return 0;
122
123						case 'c':
124						case 'C':
125						case 'm':
126						case 'M':
127							return width / 2;
128
129						case 'r':
130						case 'R':
131							return width - 1;
132					}
133				}
134				return Number(text);
135			},
136			_getAnchorVertical: function (text, height) {
137				if (typeof text == 'string') {
138					switch (text.charAt(0)) {
139						case 't':
140						case 'T':
141							return 0;
142
143						case 'c':
144						case 'C':
145						case 'm':
146						case 'M':
147							return height / 2;
148
149						case 'b':
150						case 'B':
151							return height - 1;
152					}
153				}
154				return Number(text);
155			},
156			_parseLatLng: function (text) {
157				var args = text.trim().split(',');
158				if (args.length < 2) {
159					return false;
160				}
161				var lat = parseFloat(args[0].substring(0, 10));
162				if (isNaN(lat) || lat > 90 || lat < -90) {
163					return false;
164				}
165				var lng = parseFloat(args[1].substring(0, 10));
166				if (isNaN(lng) || lng > 180 || lng < -180) {
167					return false;
168				}
169				return {
170					latitude: lat,
171					longitude: lng
172				};
173			},
174			_isElementInViewport: function (el) {
175				var rect = el.getBoundingClientRect();
176				return (
177					(rect.top <= (window.innerHeight || document.documentElement.clientHeight)) && ((rect.top + rect.height) >= 0) &&
178					(rect.left <= (window.innerWidth || document.documentElement.clientWidth)) && ((rect.left + rect.width) >= 0)
179				);
180			},
181			_opacityShow: function (m) {
182				var el = document.getElementById(m._div);
183				el.style.opacity = '1.0';
184				el.style.filter = 'alpha(opacity=100)';
185			},
186			_idleJs: function (provider, map) {
187				//  Monitor dom changes via Javascript
188				var el = document.getElementById(map._div);
189				var newValue = el.parentElement.offsetTop + el.parentElement.offsetWidth;
190				var newSize = el.clientHeight * el.clientWidth;
191				var show = !(el.style.display && typeof el.style.display == 'string' && el.style.display.toLowerCase() == 'none');
192				var visible = show && root.terratype._isElementInViewport(el);
193				if (newValue != 0 && show == false) {
194					//console.log('A ' + m.id + ': in viewport = ' + visible + ', showing = ' + show);
195					//  Was hidden, now being shown
196					el.style.display = 'block';
197				} else if (newValue == 0 && show == true) {
198					//console.log('B ' + m.id + ': in viewport = ' + visible + ', showing = ' + show);
199					//  Was shown, now being hidden
200					el.style.display = 'none';
201					map.visible = false;
202				}
203				else if (visible == true && map._divoldsize != 0 && newSize != 0 && map._divoldsize != newSize) {
204					//console.log('C ' + m.id + ': in viewport = ' + visible + ', showing = ' + show);
205					//  showing, just been resized and map is visible
206					(function (p, m) { provider.refresh.call(p, m); })(provider, map);
207					map.visible = true;
208				} else if (visible == true && map.visible == false) {
209					//console.log('D ' + m.id + ': in viewport = ' + visible + ', showing = ' + show);
210					//  showing and map just turned visible
211					(function (p, m) { provider.refresh.call(p, m); })(provider, map);
212					map.visible = true;
213				} else if (visible == false && map.visible == true) {
214					//console.log('E ' + m.id + ': in viewport = ' + visible + ', showing = ' + show);
215					//  was visible, but now hiding
216					map.visible = false;
217				}
218				map._divoldsize = newSize;
219			},
220			_idleJquery: function (provider, map) {
221				//  Monitor dom changes via jQuery
222				var r = false;
223				var el = jQuery(document.getElementById(map.div));
224				var show = !(el.is(':hidden'));
225				var visible = el.is(':visible');
226				if (show == visible) {
227					if (show) {
228						var newSize = el.height() * el.width();
229						if (newSize != map._divoldsize) {
230							(function (p, m) { provider.refresh.call(p, m); })(provider, map);
231						}
232						map._divoldsize = newSize;
233					}
234					return;
235				}
236				if (show) {
237					el.hide();
238					map._divoldsize = 0;
239					(function (p, m) { provider.refresh.call(p, m); })(provider, map);
240					return;
241				}
242				el.show();
243				(function (p, m) { provider.refresh.call(p, m); })(provider, map);
244				map._divoldsize = el.height() * el.width();
245			},
246			_loadCss: function (css) {
247				for (var c = 0; c != css.length; c++) {
248					if (document.createStyleSheet) {
249						document.createStyleSheet(css[c]);
250					} else {
251						var l = document.createElement('link');
252						l.rel = 'stylesheet';
253						l.type = 'text/css';
254						l.href = css[c];
255						l.media = 'screen';
256						document.getElementsByTagName('head')[0].appendChild(l);
257					}
258				}
259			},
260			_getMap: function (maps, mapId) {
261				for (var i = 0; i != maps.length; i++) {
262					if (maps[i].id == mapId) {
263						return maps[i];
264					}
265				}
266				return null;
267			},
268			_jQueryMonitoring: false,
269			_jQueryMonitorTimer: null,
270			_jQueryMonitor: function () {
271				var providerCounter = 0;
272				var mapCounter = 0;
273				var providers = [];
274				for (var provider in root.terratype.providers) {
275					providers.push(provider.id);
276				}
277				if (root.terratype._jQueryMonitorTimer != null) {
278					root.clearInterval(root.terratype._jQueryMonitorTimer);
279				}
280				root.terratype._jQueryMonitorTimer = root.setInterval(function () {
281					if (providerCounter == providers.length) {
282						root.clearInterval(root.terratype._jQueryMonitorTimer);
283					} else {
284						var provider = root.terratype.providers[providers[providerCounter]];
285						if (mapCounter == provider.maps.length) {
286							providerCounter++;
287							mapCounter = 0;
288						} else {
289							root.terratype._idleJquery(provider, provider.maps[mapCounter++]);
290						}
291					}
292				}, root.terratype._poll);
293			},
294			_initTimer: null,
295			init: function () {
296				var kill = 0;
297				var providers = null;
298				var providerCounter = 0;
299				var activeCounter = 0;
300				var mapCounter = 0;
301				var mapRunning = 0;
302				if (root.terratype._initTimer != null) {
303					root.clearInterval(root.terratype._initTimer);
304					for (var provider in root.terratype.providers) {
305						provider._status = 0;
306						provider.maps = [];
307						//TODO: Need a way to remove existing maps
308					}
309				}
310				root.terratype._initTimer = root.setInterval(function () {
311					kill++;
312					if (providers == null) {
313						providers = [];
314						for (var provider in root.terratype.providers) {
315							providers.push(provider);
316						}
317						activeCounter = 0;
318						providerCounter = 0;
319						mapCounter = 0;
320						mapRunning = 0;
321					} else if (providerCounter == providers.length) {
322						providers = null;
323						if (activeCounter == 0 && kill > root.terratype._killSwitch) {
324							root.clearInterval(root.terratype._initTimer);
325						}	
326					} else {
327						var provider = root.terratype.providers[providers[providerCounter]];
328
329						if (provider._status == 3 && mapCounter < provider.maps.length) {
330							var m = provider.maps[mapCounter++];
331							switch (m._status) {
332								case 0:		//	Needs rendering
333									(function (p, m) { provider._render.call(p, m); })(provider, m);
334									m._status = 1;
335									activeCounter++;
336									mapRunning++;
337									break;
338
339								case 1:		//	Needs monitoring
340									if (root.jQuery && provider._domDetectionType == 1) {
341										if (root.terratype._jQueryMonitoring == false) {
342											root.jQuery(window).on('DOMContentLoaded load resize scroll touchend', root.terratype._jQueryMonitor);
343											root.terratype._jQueryMonitoring = true;
344										}
345									} else if (provider._domDetectionType != 2) {
346										activeCounter++;
347										root.terratype._idleJs(provider, m);
348									}
349									mapRunning++;
350									break;
351							}
352						} else {
353							switch (provider._status) {
354								case -1:	//	This provider currently has no maps to render
355									break;
356
357								case 0:		//	Waiting for support javascript libraries to load
358									activeCounter++;
359									if (provider.ready()) {
360										provider._status = 1;
361										root.terratype._callInit(provider);
362									}
363									break;
364
365								case 1:		//	Load maps
366									activeCounter++;
367									var matches = document.getElementsByClassName(provider.id);
368									if (matches.length == 0) {
369										provider._status = -1;
370									} else {
371										root.terratype._forEach(matches, function (i, match) {
372											var domDetectionType = parseInt(match.getAttribute('data-dom-detection-type'));
373											if (provider._domDetectionType > domDetectionType) {
374												provider._domDetectionType = domDetectionType;
375											}
376											mapId = match.getAttribute('data-map-id');
377											id = match.getAttribute('data-id');
378											var model = JSON.parse(unescape(match.getAttribute('data-model')));
379											var m = root.terratype._getMap(provider.maps, mapId);
380											if (m == null) {
381												match.style.display = 'block';
382												var loadMap = {};
383												if (provider._loadMap) {
384													(function (p, model, match) { loadMap = provider._loadMap.call(p, model, match); })(provider, model, match);
385												}
386												m = root.terratype._mergeJson(loadMap, {
387													zoom: model.zoom,
388													_ignoreEvents: 0,
389													_refreshes: 0,
390													id: mapId,
391													_div: id,
392													_divoldsize: 0,
393													_status: 0,
394													visible: false,
395													autoFit: match.getAttribute('data-auto-fit') ? true : false,
396													recenterAfterRefresh: match.getAttribute('data-recenter-after-refresh') ? true : false,
397													handle: null,
398													positions: [],
399													getPosition: function (tag) {
400														for (var i = 0; i != m._positions.length; i++) {
401															if (m._positions[i].tag == tag) {
402																return m._positions[i];
403															}
404														}
405														return null;
406													},
407													isVisible: function () {
408														var el = document.getElementById(m._div);
409														var newValue = el.parentElement.offsetTop + el.parentElement.offsetWidth;
410														var newSize = el.clientHeight * el.clientWidth;
411														var show = !(el.style.display && typeof el.style.display == 'string' && el.style.display.toLowerCase() == 'none');
412														var visible = show && root.terratype._isElementInViewport(document.getElementById(m._div));
413														return visible && newValue > 0 && newSize > 0;
414													},
415													refresh: function () {
416														(function (p, m) { provider.refresh.call(p, m); })(provider, m);
417													}
418												});
419												provider.maps.push(m);
420											}
421											if (provider._loadMarker) {
422												(function (p, m, model, match) { provider._loadMarker.call(p, m, model, match); })(provider, m, model, match);
423											}
424										});
425										root.terratype._forEach(provider.maps, function (i, m) {
426											root.terratype._callLoad(provider, m);
427										});
428										provider._status = 2;
429									}
430									break;
431
432								case 2:		//	Has loaded
433									activeCounter++;
434									var cont = true;
435									if (provider._prerender) {
436										(function (p) { cont = provider._prerender.call(p); })(provider);
437									}
438									if (cont) {
439										provider._status = 3;
440									}
441									break;
442
443								case 3:		//	Monitoring
444									activeCounter++;
445									if (mapRunning == 0) {
446										provider._status = -1;
447									}
448									break;
449							}
450							providerCounter++;
451							mapCounter = 0;
452							mapRunning = 0;
453						}
454
455					}
456				}, root.terratype._poll);
457			},
458		};
459
460		root.terratype.init();
461	}
462}(window));

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.