PageSourceSearch

https://topkinisis.com/js/globalFunctions.js

js topkinisis.com collected 2026-10-02 11:38:28 UTC 13,457 bytes, 508 lines download raw bytes

1// Safely instantiate dataLayer
2var dataLayer = window.dataLayer = window.dataLayer || [];
3
4mainApp.run(function ($rootScope, $filter, localize, $location) {
5
6	$rootScope.$on('$routeChangeSuccess', function () {
7
8		dataLayer.push({
9			event: 'ngRouteChange',
10			attributes: {
11				route: $location.path()
12			}
13		});
14
15	});
16
17
18	$rootScope.filterTimeDisplay = function (value) {
19
20		var hours = parseInt(value / 3600) % 24;
21		var minutes = parseInt(value / 60) % 60;
22		var h = String(hours);
23		if (h < 10) {
24			h = "0" + String(hours);
25		}
26
27		var m = String(minutes);
28		if (m < 10) {
29			m = "0" + String(minutes);
30		}
31
32		return h + ":" + m;
33	};
34
35	$rootScope.filterActualTimeDisplay = function (value) {
36		if (value) {
37			var hh = value.substring(0, 2);
38			var dd = value.substring(2, 4);
39
40			return hh + ":" + dd;
41		}
42	};
43
44	$rootScope.filterCalendarTimeDisplay = function (value) {
45		if (value) {
46			var hh = value.substring(0, 2);
47			var dd = value.substring(2, 4);
48
49			return hh + ":" + dd;
50		}
51	};
52
53	$rootScope.filterDurationDsiplay = function (value) {
54
55		var hours = 0;
56		hours = Math.floor(value / 60);
57		var minutes = 0;
58		minutes = value % 60;
59		var days = 0;
60		if (hours >= 24) {
61			days = Math.floor(hours / 24);
62			hours = hours % 24;
63		}
64		var ret = "";
65		if (days > 0) {
66			ret += days + "d ";
67		}
68		if (hours > 0 || (days > 0 && hours === 0)) {
69			ret += hours + "h ";
70		}
71		ret += minutes + "m";
72		return ret;
73	};
74
75	$rootScope.filterActualDurationDsiplay = function (value) {
76		if (value) {
77			if (value.length === 2) {
78				return value + "m";
79			} else if (value.length === 3) {
80				var h = value.substring(0, 1);
81				var m = value.substring(1, 3);
82				return h + "h " + m + "m";
83			} else if (value.length === 4) {
84				var hh = value.substring(0, 2);
85				var mm = value.substring(2, 4);
86				var days = 0;
87				if (hh > 24) {
88					days = Math.floor(hh / 24);
89					hh = hh % 24;
90				}
91				var ret = "";
92				if (days > 0) {
93					ret += days + "d ";
94				}
95				if (hh > 0 || (days > 0 && hh === 0)) {
96					ret += hh + "h ";
97				}
98				ret += mm + "m";
99				return ret;
100			}
101		}
102	};
103
104	$rootScope.filterActualDurationDisplayByMinutes = function (durationOnMinutes) {
105
106		if (durationOnMinutes < 60) {
107			return durationOnMinutes + " m";
108		} else {
109			return parseInt(durationOnMinutes / 60) + " h " + durationOnMinutes % 60 + " m";
110		}
111
112
113	};
114
115	$rootScope.findDurationByDepArrItirenaryTime = function (depTime, ArrTime, nextDay) {
116
117		var nextDayHours = 0;
118
119		if (nextDay === 1) {
120			nextDayHours = 24;
121		}
122		var durationHours = (nextDayHours + parseInt(ArrTime.substring(0, 2))) - parseInt(depTime.substring(0, 2));
123
124		var durationMinutes = parseInt(ArrTime.substring(2, 4)) - parseInt(depTime.substring(2, 4));
125
126		if (durationMinutes < 0) {
127			durationMinutes = 60 - Math.abs(durationMinutes);
128			durationHours--;
129		}
130
131		return durationHours * 60 + durationMinutes;
132
133	};
134
135	$rootScope.findDurationBetweenItirenaryFlights = function (itirenary, flightSchedule, flightString) {
136
137		if (flightString === "roundTripDeparture") {
138			var itirenaryList = flightSchedule.departureItineraryFlights;
139		} else if (flightString === "roundTripArrival") {
140			var itirenaryList = flightSchedule.arrivalItineraryFlights;
141		} else if (flightString === "oneWay") {
142			var itirenaryList = flightSchedule.itineraryFlights;
143		}
144
145		for (var i = 0; i < itirenaryList.length; i++) {
146			if (itirenaryList[i] === itirenary) {
147				if (i !== 0) {
148					var arrivesNextDay = 0;
149					if (parseInt(itirenaryList[i - 1].arrivalTime) > parseInt(itirenary.departureTime)) {
150						arrivesNextDay = 1;
151					}
152					return $rootScope.findDurationByDepArrItirenaryTime(itirenaryList[i - 1].arrivalTime, itirenary.departureTime, arrivesNextDay);
153				}
154			}
155		}
156
157	};
158
159
160	$rootScope.filterFlightDate = function (input) {
161		var dd = input.substring(0, 2);
162		var mm = input.substring(2, 4);
163		var yy = input.substring(4, 6);
164		return dd + "/" + mm + "/20" + yy;
165	};
166
167	$rootScope.mouseOverIcon = function (evt, hovertext) {
168		var pos = getMousePos(evt);
169		$('#hoverdiv').text(hovertext).show();
170		$('#hoverdiv').css('top', pos.y - 10).css('left', pos.x + 10);
171	};
172
173	$rootScope.mouseOutIcon = function () {
174		$('#hoverdiv').hide();
175	};
176
177	function getMousePos(evt) {
178		var doc = document.documentElement || document.body;
179		var pos = {
180			x: evt ? evt.pageX : window.event.clientX + doc.scrollLeft - doc.clientLeft,
181			y: evt ? evt.pageY : window.event.clientY + doc.scrollTop - doc.clientTop
182		};
183		return pos;
184	}
185
186	$rootScope.filterFlightDateWithPatt = function (input, pattern) {
187		if (input) {
188			var dd = input.substring(0, 2);
189			var mm = input.substring(2, 4);
190			var yy = "20" + input.substring(4, 6);
191			var date = $filter('date')(new Date(yy, mm - 1, dd, 0, 0, 0), pattern);
192			return date;
193		}
194	};
195
196	$rootScope.filterFlightDateWithPattAndNextDay = function (input, pattern, nextDay) {
197		if (input) {
198			var dd = (parseInt(input.substring(0, 2)) + nextDay) + "";
199			var mm = input.substring(2, 4);
200			var yy = "20" + input.substring(4, 6);
201			var date = $filter('date')(new Date(yy, mm - 1, dd, 0, 0, 0), pattern);
202			return date;
203		}
204	};
205
206	$rootScope.convertFlightDateToDate = function (input) {
207		if (input) {
208			var dd = input.substring(0, 2);
209			var mm = input.substring(2, 4);
210			var yy = "20" + input.substring(4, 6);
211			return new Date(yy, mm - 1, dd, 0, 0, 0);
212		}
213	};
214
215	$rootScope.getDurationFromTwoDateTime = function (stDate, stTime, eDate, eTime) {
216
217		var sdd = stDate.substring(0, 2);
218		var smm = stDate.substring(2, 4);
219		var syy = "20" + stDate.substring(4, 6);
220		var stime = $rootScope.filterTimeDisplay(stTime).split(":");
221		var startTime = new Date(syy, smm - 1, sdd, stime[0], stime[1], 0);
222
223		var edd = eDate.substring(0, 2);
224		var emm = eDate.substring(2, 4);
225		var eyy = "20" + eDate.substring(4, 6);
226		var etime = $rootScope.filterTimeDisplay(eTime).split(":");
227
228		var endTime = new Date(eyy, emm - 1, edd, etime[0], etime[1], 0);
229		var difference = endTime.getTime() - startTime.getTime(); // This will give difference in milliseconds
230		var resultInMinutes = Math.round(difference / 60000);
231		return $rootScope.filterDurationDsiplay(resultInMinutes);
232	};
233
234	$rootScope.displayFlightType = function (flightType) {
235		if (flightType) {
236			if (flightType === 'oneWay') {
237				return localize.getLocalizedString("one.way");
238			} else {
239				return localize.getLocalizedString("return");
240			}
241		}
242	};
243
244	$rootScope.displayNoPassengers = function (flightPassengers) {
245		var ret = "";
246		if (flightPassengers) {
247			if (flightPassengers.numberOfAdults > 0) {
248				ret += " " + flightPassengers.numberOfAdults + " " + localize.getLocalizedString("flight.adults");
249			}
250
251			if (flightPassengers.numberOfInfants > 0) {
252				ret += " " + flightPassengers.numberOfInfants + " " + localize.getLocalizedString("flight.infants");
253			}
254
255			if (flightPassengers.numberOfChildren > 0) {
256				ret += " " + flightPassengers.numberOfChildren + " " + localize.getLocalizedString("flight.children");
257			}
258		}
259		return ret;
260	};
261
262	$rootScope.dsiplayCity = function (data) {
263		if (data) {
264			var arr = data.split(",");
265			return arr[1];
266		}
267		return "";
268	};
269
270	$rootScope.displayExtraLaguageDetails = function (data) {
271		var retStr = "";
272		retStr = data.numberOfAdditionalBags + " luggage ";
273		if (data.maxKilos.length > 0) {
274			retStr = retStr + "(";
275		}
276		for (var i = 0; i < data.maxKilos.length; i++) {
277			if (i > 0) {
278				retStr = retStr + ", ";
279			}
280			retStr = retStr + " lugguge of " + data.maxKilos[i] + " kg ";
281
282		}
283		if (data.maxKilos.length > 0) {
284			retStr = retStr + ")";
285		}
286		retStr = retStr + " price: € " + data.price;
287		return retStr;
288	};
289	$rootScope.displayExtraVehicleDetails = function (data) {
290		var retStr = "";
291		retStr = data.ssrCodes;
292//		if (data.maxKilos.length > 0) {
293//			retStr = retStr + "(";
294//		}
295//		for (var i = 0; i < data.maxKilos.length; i++) {
296//			if (i > 0) {
297//				retStr = retStr + ", ";
298//			}
299//			retStr = retStr + " Vehicle of " + data.maxKilos[i] + " kg ";
300//
301//		}
302//		if (data.maxKilos.length > 0) {
303//			retStr = retStr + ")";
304//		}
305      
306		retStr = retStr + " price: € " + data.price;
307		return retStr;
308	};
309
310	$rootScope.formatInsuranceDescription = function (data) {
311		for (var i = 0; i < data.length; i++) {
312			var cov = data[i].productDescription.split("/c");
313			var cList = cov[1].split("/l");
314			data[i].desccon = {cov: cov[0], list: cList};
315
316		}
317		return data;
318	};
319
320	$rootScope.filterRangeMaxPriceDsiplay = function (value) {
321		if (!value) {
322			return "";
323		}
324		var min = value[0];
325		var max = value[1];
326		return '€' + min + " to " + '€' + max;
327	};
328
329	$rootScope.deteminPackageAllomentImage = function (packageType) {
330		if (packageType === 16) {
331			return 'Assets/img/flightsAndCruises.png';
332		} else {
333			return 'Assets/img/fligthAndHotel.png';
334		}
335	};
336
337	$rootScope.isImageExist = function (imageUrl) {
338		var img = new Image();
339		img.src = imageUrl;
340		return img.height !== 0;
341
342	};
343
344
345	$rootScope.ccMaxValue = 19;
346	$rootScope.ccvMaxValue = 4;
347	$rootScope.changeCreditCardMaxLength = function (ccType) {
348		if (ccType === 'visa' || ccType === 'mm') {
349			$rootScope.ccMaxValue = 16;
350			$rootScope.ccvMaxValue = 3;
351		} else if (ccType === 'am') {
352			$rootScope.ccMaxValue = 15;
353			$rootScope.ccvMaxValue = 4;
354		} else {
355			$rootScope.ccMaxValue = 19;
356			$rootScope.ccvMaxValue = 4;
357		}
358	};
359
360	$rootScope.openInfoCvv = function () {
361		window.open('https://jccpg.jccsecure.com/EcomPayment/cvv2Info.htm', 'Cvv2 Info', 'height=600,width=700,location=0,menubar=0,titlebar=0,toolbar=0,left=300');
362
363	};
364
365	$rootScope.printFlightVoucher = function (printContents) {
366		if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
367			var popupWin = window.open('', '_blank', 'width=600,height=600,scrollbars=no,menubar=no,toolbar=no,location=no,status=no,titlebar=no');
368			popupWin.window.focus();
369			popupWin.document.write('<!DOCTYPE html><html><head>' +
370					'<link rel="stylesheet" type="text/css" href="style.css" />' +
371					'</head><body onload="window.print()"><div class="reward-body">' + printContents + '</div></html>');
372			popupWin.onbeforeunload = function (event) {
373				popupWin.close();
374				return '.\n';
375			};
376			popupWin.onabort = function (event) {
377				popupWin.document.close();
378				popupWin.close();
379			};
380		} else {
381			var popupWin = window.open('', '_blank', 'width=800,height=600');
382			popupWin.document.open();
383			popupWin.document.write('<html><head><link rel="stylesheet" type="text/css" href="style.css" /></head><body onload="window.print()">' + printContents + '</html>');
384			popupWin.document.close();
385		}
386		popupWin.document.close();
387
388		return true;
389
390	};
391
392	$rootScope.openAmaFligthVoucher = function (pnr, sname) {
393		var url = 'https://www.checkmytrip.com/cmt/apf/cmtng/pnr_retrieve?SITE=NCMTNCMT&LANGUAGE=GB&R=' + pnr + '&N=' + sname;
394		window.open(url, 'Amadeus Flight', 'height=600,width=700,resizable=1,scrollbars=1,left=20');
395	};
396
397	$rootScope.displayInsuranceTerms = function (insCode) {
398		console.log(insCode);
399		var url = '';
400		if (insCode === '6400' || insCode === '6497') {
401			url = '/pdf/TravelInsurance.pdf';
402		} else if (insCode === '6409' || insCode === '6538') {
403			url = '/pdf/Travel&Cancellation.pdf';
404		} else if (insCode === '6419' || insCode === '6537') {
405			url = '/pdf/CancellationInsurance.pdf';
406		}
407		window.open(url, 'Insurance Info', 'height=600,width=700,location=0,menubar=0,titlebar=0,toolbar=0,left=300');
408
409	};
410	
411	$rootScope.displayInsuranceProductInformationDocument = function (insCode) {
412		console.log(insCode);
413		var url = '';
414		if (insCode === '6400' || insCode === '6497') {
415			url = '/pdf/TravelInsurance-InformationDocument-'+ localize.language +'.pdf';
416		} else if (insCode === '6409' || insCode === '6538') {
417			url = '/pdf/Travel&Cancellation-InformationDocument-'+ localize.language +'.pdf';
418		} else if (insCode === '6419' || insCode === '6537') {
419			url = '/pdf/CancellationInsurance-InformationDocument-'+ localize.language +'.pdf';
420		}
421		window.open(url, 'Insurance Info', 'height=600,width=700,location=0,menubar=0,titlebar=0,toolbar=0,left=300');
422
423	};
424
425	$rootScope.convertStrToDate = function (dateStr) {
426		var date = dateStr.split("/");
427		var yy = date[2];
428		if (date[2].length === 2) {
429			yy = "20" + date[2];
430		}
431		return new Date(parseInt(yy), date[1] - 1, date[0]);
432	};
433	
434	$rootScope.convertDashStrToDate = function(dateStr) {
435		if(dateStr !== null){
436			var date = dateStr.split("-");
437			var yy = date[0];
438			if (date[0].length === 2) {
439				yy = "20"+date[0];
440			}
441			return ""+date[2]+" "+$rootScope.returnMonthName(date[1])+" "+parseInt(yy);
442		}
443	};
444    
445	$rootScope.returnMonthName = function (monthNo) {
446
447		if (monthNo === "01") {
448			return "January";
449		}
450		;
451		if (monthNo === "02") {
452			return "February";
453		}
454		;
455		if (monthNo === "03") {
456			return "March";
457		}
458		;
459		if (monthNo === "04") {
460			return "April";
461		}
462		;
463		if (monthNo === "05") {
464			return "May";
465		}
466		;
467		if (monthNo === "06") {
468			return "June";
469		}
470		;
471		if (monthNo === "07") {
472			return "July";
473		}
474		;
475		if (monthNo === "08") {
476			return "August";
477		}
478		;
479		if (monthNo === "09") {
480			return "September";
481		}
482		;
483		if (monthNo === "10") {
484			return "October";
485		}
486		;
487		if (monthNo === "11") {
488			return "November";
489		}
490		;
491		if (monthNo === "12") {
492			return "December";
493		}
494		;
495
496		return "";
497	};
498	
499	$rootScope.convertPackageDateToString = function (dateOfBirth) {
500	
501		var date = dateOfBirth.split("-");		
502		return parseInt(date[2])+" "+this.returnMonthName(date[1])+" "+date[0];
503		
504	};
505	
506	
507});
508

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.