PageSourceSearch

https://www.dabur.com/static/js/eurolandtoolsintegrationobject.js?s7avq6b

js dabur.com collected 2026-09-24 21:07:27 UTC 10,725 bytes, 250 lines download raw bytes

1/*! Developed by Illimar Pihlamäe | e-mail: [email protected] | Euroland Estonia © 2014 | e-mail: [email protected] */
2var EurolandToolIntegrationObject = new (function() {
3	
4	var This = this
5		,iFrameArr = [] //an array, that holds all of the iframes
6		,hasScrollBar = false
7		,IE_Version = getDocumentModeIE()
8		,hasListiners = false
9		,eurolandDomainRegex = /^(https?:\/\/)?([a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]\.)*(?:euroland(ir)?)(?:\.[a-zA-Z]{2,}){1,2}(:\d+)?$/i
10		,dummyCallback = function() {}
11	;
12	
13	function removeHash(url) {
14		var index = url.indexOf('#');
15		if(index > -1) {
16			url = url.substring(0, index);
17		}
18		return url
19	}
20
21	function messageCall(e) {
22		if(!e) e = window.event;
23		
24		if(!eurolandDomainRegex.test(e.origin)) {
25			return;
26		}
27		
28		var obj, item, offset;
29		try {
30			obj = JSON.parse(e.data);
31		} catch(e) {
32			return;
33		}
34		
35		if(obj.iFrame) {
36			if(typeof obj.iFrame.height == 'number') {
37				if(typeof obj.iFrame.index == 'number' && iFrameArr.length > obj.iFrame.index) {
38					item = iFrameArr[obj.iFrame.index];
39					if(item.height < 0) {
40						item.height = parseFloat(item.iFrame.offsetHeight);
41					}
42					offset = obj.iFrame.height - item.height;
43					item.iFrame.height = obj.iFrame.height;
44					item.height = obj.iFrame.height;
45					item.iFrame.style.height = obj.iFrame.height + 'px';
46					
47					if(item.callback != dummyCallback) {
48						item.callback(offset);
49					}
50				}
51			}
52		}
53		if(obj.scrollTo) {
54			if(typeof obj.scrollTo.index == 'number' && iFrameArr.length > obj.scrollTo.index)
55			{
56				item = iFrameArr[obj.scrollTo.index];
57				var posIsNumber = Object.prototype.toString.call(obj.scrollTo.scrollY) === '[object Number]';
58				var scrollTo = (Object.prototype.toString.call(obj.scrollTo.scrollY) === '[object String]'
59					&& ['top', 'bottom'].indexOf(obj.scrollTo.scrollY) !== -1)
60					? item.iFrame.scrollIntoView.bind(item.iFrame)
61					: posIsNumber
62					? window.scrollTo.bind(window)
63					: function(){};
64				var frameSrollY = item.iFrame.getBoundingClientRect().top + window.scrollY;
65				scrollTo({
66					behavior: 'smooth', 
67					block: obj.scrollTo.scrollY === 'top' ? 'start' : 'end', 
68					inline: 'nearest',
69					top: frameSrollY + (posIsNumber ? obj.scrollTo.scrollY : 0),
70					left: 0
71				});
72			}
73			
74		}
75	};
76
77	function getDocumentModeIE() {
78	/*
79		Returns the IE's DocumentMode for IE, for non IE 0 is returned.
80	*/
81		if(document.all) {
82			return typeof document.documentMode == 'undefined' ? getIE_Version() : Math.floor(parseFloat(document.documentMode));
83		} 		
84		return 0;
85	}
86	
87	function getIE_Version() {
88	/*
89		Returns the current IE version. Returns 0 if the browser is not a IE.
90	*/
91		if(!document.all) //if the browser is not a IE returns 0
92			return 0;
93		if(IE_Version != null) //if the browser version has already been found returns that
94			return IE_Version;
95		
96		//Finds out the IE version
97		var index
98			,browser = navigator.userAgent
99		;		
100		
101		index = browser.search('MSIE');
102		if(index == -1)
103			return 0;
104		
105		IE_Version = browser.substring(index + 4, browser.indexOf(';', index));
106		IE_Version = Math.floor(parseFloat(IE_Version));
107		return IE_Version;
108	}
109	
110	function setIFrame(iFrame, resizeCallback, isHeightToParent) {
111	/*
112		Sets the IFrame in the object
113		iFrame - the HTML DOM object of the IFrame
114		
115		reziseCallback - Function, the callback that will be called with the iframe's offset passed to it
116		isHeightToParent - Boolean, if set to TRUE the AutoHeight will ask the height to be sent to the parent and not into the top window
117	*/
118		var obj = {
119			iFrame : iFrame
120			,index : iFrameArr.length
121			,height : -1 //the current height of the iframe
122			,callback : resizeCallback
123		}, strActivationMessage;
124		
125		iFrame.width = "100%"; 
126		iFrame.allowTransparency = true;
127		iFrame.style.background = 'transparent';
128		// iFrame.style.border = '0px #000 solid';
129		// iFrame.style.overflow = 'hidden';
130		// iFrame.setAttribute('frameborder', '0');
131		iFrame.setAttribute('scrolling', 'no');
132		//iFrame.scrolling = 'no';
133		//iFrame.frameBorder = 0;
134		
135		//Usually it's a IE fix, but this is here actually to make sure that in iPhones the IFrmae actually takes the portrait width and not the landscape width.
136		if(IE_Version && IE_Version < 7) {
137			iFrame.style.width = "100%";
138		} else {
139			iFrame.style.minWidth = "100%";
140			iFrame.style.width = "1px";
141		}
142		
143		iFrame.style.maxHeight = 'none';
144		iFrame.style.minHeight = '0px';
145		
146		iFrameArr.push(obj);
147		
148		//makes the activation message
149		strActivationMessage = "ActivateEurolandToolAutoSizeObject-" + obj.index;
150		if(isHeightToParent) {
151			strActivationMessage += '-1';
152		}
153		
154		//sends the activation message to the tool
155		iFrame.contentWindow.postMessage(strActivationMessage, '*');
156		
157		//just to be safe sends the activation message to the Tool again onload
158		iFrame.onload = function() {
159			iFrame.contentWindow.postMessage(strActivationMessage, '*');
160		}
161	}
162	
163	this.set = function(iFrameID, reziseCallback, isHeightToParent) {
164	/*
165		Sets a tool to run in a spesific container
166		iFrameID - String/HTML DOM Object, aider the ID of the iframe in question or the iframe itself as HTML DOM Object
167		
168		reziseCallback - [Optional] Function, the callback that will be called with the iframe's offset passed to it
169		isHeightToParent - [Optional] Boolean, if set to TRUE the AutoHeight will ask the height to be sent to the parent and not into the top window
170	*/
171		var iFrame;
172		
173		if(!window.postMessage || IE_Version && IE_Version < 8) {
174			return;
175		}
176		
177		if(typeof reziseCallback != 'function') {
178			reziseCallback = dummyCallback;
179		}
180		if(typeof isHeightToParent != 'boolean') {
181			isHeightToParent = false;
182		}
183		
184		switch(typeof iFrameID) {
185			case 'string':
186				try {
187					iFrame = document.getElementById(iFrameID);
188				} catch(e) {
189					return false;
190				}
191				break;
192			case 'object': 
193				if(iFrameID == null)
194					return false;
195				iFrame = iFrameID;
196				break;
197			default:
198				return false;
199		}
200		
201		if(typeof iFrame != 'object' || iFrame == null || !iFrame.nodeName || iFrame.nodeName.toLowerCase() != 'iframe')
202			return;		
203		
204		if(!hasListiners) {
205			hasListiners = true;
206			if(window.addEventListener) {
207				window.addEventListener('message', messageCall);
208			} else {
209				window.attachEvent('onmessage', messageCall);
210			}
211		}		
212		
213		setIFrame(iFrame, reziseCallback, isHeightToParent);
214	};
215})();
216
217//Adds in JSON support if missing
218var JSON;if(!JSON){JSON={};}(function(){'use strict';function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){if(typeof rep[i]==='string'){k=rep[i];v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;
218function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}());
219
220//Adds in a jQuery plugin
221if (typeof jQuery == 'function') {
222	(function ($) {
223		/*
224			Creates the [EurolandCommoditiesPeersIndices] Object
225		*/
226			
227		// $.fn.EurolandIFrameAutoHeight = function() {
228			
229			// for(var i = 0; i < this.length; i++) {
230				// EurolandToolIntegrationObject.set(this[i]);
231			// }
232			// return this;
233		// };
234		
235		$.fn.extend({
236			EurolandIFrameAutoHeight : function(resizeCallback) {
237				
238				if(typeof resizeCallback != 'function') {
239					resizeCallback = null;
240				}
241				
242				for(var i = 0; i < this.length; i++) {
243					EurolandToolIntegrationObject.set(this[i], resizeCallback);
244				}
245				return this;
246			}
247		})
248
249	}(jQuery));
250}

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.