PageSourceSearch

https://www.zaaptv.com/wp-content/plugins/call-to-action-for-pwa/assets/js/calltoaction-for-pwa.js

js zaaptv.com collected 2026-09-24 13:28:05 UTC 9,995 bytes, 263 lines download raw bytes

1(function() {
2
3	var stickyBar = document.getElementById("pwaforwp-sticky-bar");
4	var stickyCtaButtonBox = document.getElementsByClassName("pwaforwp-add-via-class")[0];  
5  
6	function sticky_on_desktop() {
7	  if(pwa_cta_assets.call_to_action_on == 1 && pwa_cta_assets.add_to_home_sticky_cta == 1 && pwa_cta_assets.a2h_sticky_on_desktop_cta==0 && screen.availWidth>520){
8				stickyCtaButtonBox.style.display = 'none';
9		}	
10	  }
11  
12	  function ctaPWAApp_function() {
13		  if( window.matchMedia('(display-mode: standalone)').matches || window.matchMedia('(display-mode: fullscreen)').matches || window.matchMedia('(display-mode: minimal-ui)').matches) { 
14		  stickyCtaButtonBox.style.display = 'none';
15		} 
16	  }
17  
18	setTimeout(function(){  
19		if(stickyCtaButtonBox) {
20		  stickyCtaButtonBox.style.display="inline-block"; 
21		  if(stickyBar !== null && pwa_cta_assets.add_to_home_sticky_cta == 1 && pwa_cta_assets.a2h_banner_delay_cta == 1){
22				stickyBar.style.display="none";
23				 stickyCtaButtonBox.style.display = 'none';
24				var delayTime = pwa_cta_assets.a2h_banner_delay_sec_cta * 1000;
25			  setTimeout(function(){ 
26				  stickyBar.style.display="flex";
27				  var a2hsviashortcode = document.querySelectorAll(".pwaforwp-add-via-class");
28				  if(a2hsviashortcode){
29					  for (var i = 0; i < a2hsviashortcode.length; i++) {
30						a2hsviashortcode[i].style.display= "inline-block"; 
31						}
32				  }
33				  sticky_on_desktop();
34				  ctaPWAApp_function();
35			  }, delayTime);
36		  }
37	  }
38		  ctaPWAApp_function();
39		  sticky_on_desktop();
40	  }, 1000);
41  
42	  if(navigator.userAgent.match('CriOS') && window.navigator.standalone !== true){
43		  var a2hsviashortcode = document.getElementById("pwaforwp-sticky-bar");
44		  if(stickyBar !== null && pwa_cta_assets.add_to_home_sticky_cta == 1 && pwa_cta_assets.a2h_banner_delay_cta == 1){
45			  a2hsviashortcode.style.display = 'none';
46		   }else{
47			  if(a2hsviashortcode !== null && checkbarClosedOrNot()){
48				  var prestyle = a2hsviashortcode.getAttribute('data-style');
49				  a2hsviashortcode.style="display: flex;"+prestyle; 
50			  }
51  
52			  var a2hsviashortcode = document.querySelectorAll(".pwaforwp-add-via-class");
53			  if(a2hsviashortcode !== null && checkbarClosedOrNot()){
54				  for (var i = 0; i < a2hsviashortcode.length; i++) {
55				  a2hsviashortcode[i].style.display= "inline-block"; 
56				  }
57			  }
58		  }
59	  }
60	  //For all other browsers
61	  if (window.matchMedia('(display-mode: fullscreen)').matches || (navigator.userAgent.match('CriOS') && window.navigator.standalone === true)){
62		  var a2hsviashortcode = document.querySelectorAll(".pwaforwp-add-via-class");
63		  if(a2hsviashortcode !== null){
64			  for (var i = 0; i < a2hsviashortcode.length; i++) {
65				a2hsviashortcode[i].style.display= "none"; 
66				}
67		  }
68  
69		  var a2hsviashortcode = document.getElementById("pwaforwp-sticky-bar");
70		  if(a2hsviashortcode !== null){
71			  a2hsviashortcode.style="display: none;"; 
72		  }
73	  }
74  
75	  var isChrome = !!navigator.userAgent.match(/CriOS/);
76	  var chromeVersion = isChrome ? parseInt(navigator.userAgent.match(/CriOS\/(\d+)/)[1], 10) : null;
77	  var isSafari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
78	  var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
79	
80	// display_instruction_directly hiding in ios once clicked on close button
81	if((isSafari || iOS) && pwa_cta_assets.display_instruction_directly && !checkbarClosedOrNot()){
82		var close_ios_instruction = document.getElementById("iossafari-a2h-banner");
83		close_ios_instruction.style="display: none;"; 
84	}
85		  
86	  if (((isChrome && chromeVersion >= 87)  || isSafari) && iOS && window.navigator.standalone !== true) {
87		  console.log("You are using Safari on iOS!");
88		  var a2hsviashortcode = document.getElementById("pwaforwp-sticky-bar");
89		  if(a2hsviashortcode !== null && checkbarClosedOrNot()){
90			  var prestyle = a2hsviashortcode.getAttribute('data-style');
91			  a2hsviashortcode.style="display: flex;"+prestyle; 
92  
93			  a2hsviashortcode.addEventListener('click', function(){
94				  document.getElementById("iossafari-a2h-banner").classList.add('iossafari-popup-buzz');
95				  setTimeout(function(){ document.getElementById("iossafari-a2h-banner").classList.remove('iossafari-popup-buzz'); }, 1000);
96			  });
97		  }
98		  
99  
100		  var a2hsviashortcode = document.querySelectorAll(".pwaforwp-add-via-class");
101		  if(a2hsviashortcode !== null && checkbarClosedOrNot()){
102			  for (var i = 0; i < a2hsviashortcode.length; i++) {
103				  a2hsviashortcode[i].style.display= "inline-block"; 
104				   a2hsviashortcode[i].addEventListener("click", safaripopupshow); 
105			}
106		  }
107  
108		  //To resolve #502 issue
109		  if(window.innerHeight > window.innerWidth && window.matchMedia('(display-mode: fullscreen)').matches){
110			  //alert("Please use Landscape!");
111			  document.getElementsByTagName("html")[0].style.marginTop = "-5px";
112		  }
113  
114	  } else if(isSafari) {
115		  console.log("You are using Safari.");
116	  }
117  
118  
119      setTimeout(function(){
120		var iospopupbar = document.querySelectorAll(".pwaforwp_iossafari_close");
121		if(iospopupbar !== null){
122			for (var i = 0; i < iospopupbar.length; i++) {
123			iospopupbar[i].addEventListener("click", safaripopuphide); 
124			}
125		}
126	  }, 1000);
127
128	  if(pwa_cta_assets.a2h_banner_without_scroll_cta=="1"){
129		  var stickybar = document.getElementById("pwaforwp-sticky-bar");
130		  var iossafaribar = document.getElementById("iossafari-a2h-banner")
131		  if(stickybar) {
132			  var stickyPos = stickybar.getAttribute('data-position')
133			  if(stickyPos==='bottom'){
134				  stickybar.style.bottom = "0"; 
135			  }else if(stickyPos=='top'){
136				  stickybar.style.top = "0"; 
137			  }
138		  }
139		  if(iossafaribar){ iossafaribar.style.bottom = "14px"; }
140	  }else{
141  
142		  var prevScrollpos = window.pageYOffset;
143		  window.onscroll = function() {
144			  var currentScrollPos = window.pageYOffset;
145  
146			  if(!checkbarClosedOrNot()){
147				  return false;
148			  }
149			  var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);   
150			  if(pwa_cta_assets.a2h_sticky_on_desktop_cta==0 && !isMobile){
151				  return false; 
152			  }
153		  
154			  var stickybar = document.getElementById("pwaforwp-sticky-bar");
155			  var iossafaribar = document.getElementById("iossafari-a2h-banner")
156			  
157			  if (prevScrollpos > currentScrollPos) {
158				  if(stickybar) {
159					  var stickyPos = stickybar.getAttribute('data-position')
160					  if(stickyPos==='bottom'){
161						  stickybar.style.bottom = "0"; 
162					  }else if(stickyPos=='top'){
163						  stickybar.style.top = "0"; 
164					  }
165				  }
166				  if(iossafaribar){ iossafaribar.style.bottom = "14px"; }
167			  } else {
168				  if(stickybar) {
169					  var stickyPos = stickybar.getAttribute('data-position')
170					  if(stickyPos==='bottom'){
171						  stickybar.style.bottom = "-90px";
172					  }else if(stickyPos=='top'){
173						  stickybar.style.top = "-90px";
174					  }
175				  }
176				  if(iossafaribar){ iossafaribar.style.bottom = "-130px"; }
177			  }
178				prevScrollpos = currentScrollPos;
179		  }
180	  }
181  
182  setTimeout(function(){
183	  var banner = document.getElementsByClassName('pwaforwp-sticky-banner');
184	  if(banner[0]){
185		  if(banner[0].style.display!='none' && banner[0].style.top=='0px'){
186			  var height = banner[0].offsetHeight;
187			  var previousMargin = document.getElementsByTagName("html")[0].style.marginTop;
188			  previousMargin = previousMargin? previousMargin:0;
189			  document.getElementsByTagName("html")[0].style.marginTop =  (parseInt(height) + parseInt(previousMargin))+'px';
190		  }else{
191			  var height = banner[0].style.offsetHeight;
192			  var previousMargin = document.getElementsByTagName("html")[0].style.marginTop;
193			  document.getElementsByTagName("html")[0].style.marginTop = (parseInt(previousMargin) - parseInt(height))+'px';
194		  }
195	  }
196
197	    
198	  var crossButton = document.getElementsByClassName("pwaforwp_add_home_close");
199	  for(i=0; i<crossButton.length; i++ ){
200		  crossButton[i].addEventListener("click", function(e){
201			  this.parentNode.style.display='none';
202			  document.cookie = "pwaforwp_prompt_close="+new Date();
203			  document.getElementsByTagName("html")[0].style.marginTop = 0;
204			  e.stopPropagation();
205		  })
206	  }
207  }, 3000);
208	  
209
210  
211  
212  })();
213  function safaripopuphide(e){
214	  e.preventDefault();
215	  document.getElementById("iossafari-a2h-banner").style.display = 'none';
216	  var currentDate = new Date();
217	  var updatedDate = new Date(currentDate);
218	  updatedDate.setMonth(updatedDate.getMonth() + 1);
219	  document.cookie = "pwaforwp_prompt_close="+new Date()+";expires="+updatedDate.toUTCString()+";";
220  
221  }
222  
223  function safaripopupshow(e){
224	  e.preventDefault();
225	  if( !window.navigator.standalone  || !window.matchMedia('(display-mode: standalone)').matches ) {
226			document.getElementById("iossafari-a2h-banner").style.display = 'block';
227			var currentDate = new Date();
228			var updatedDate = new Date(currentDate);
229			updatedDate.setMonth(updatedDate.getMonth() + 1);
230			document.cookie = "pwaforwp_prompt_close="+new Date()+";expires="+updatedDate.toUTCString()+";";
231	  }
232  }
233  
234  function PWAforwpreadCookieCta(name) {
235	  var nameEQ = name + "=";
236	  var ca = document.cookie.split(";");
237	  for(var i=0;i < ca.length;i++) {
238		  var c = ca[i];
239		  while (c.charAt(0)==" ") c = c.substring(1,c.length);
240		  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
241	  }
242	  return null;
243  }
244  function checkbarClosedOrNot(){
245	  var closedTime = PWAforwpreadCookieCta("pwaforwp_prompt_close")
246	  if(closedTime){
247		var today = new Date();
248		var closedTime = new Date(closedTime);
249		var diffMs = (today-closedTime);
250		var diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes
251		if(diffMs){//diffMins<4
252		  return false;
253		}
254	  }
255	  return true;
256  }
257  
258  window.addEventListener("appinstalled", () => {
259	  var currentDate = new Date();
260	  var updatedDate = new Date(currentDate);
261	  updatedDate.setMonth(updatedDate.getMonth() + 1);
262	  document.cookie = "pwaforwp_prompt_close="+new Date()+";expires="+updatedDate.toUTCString()+";";
263	});

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.