PageSourceSearch

https://www.stjohnschelsea.org/Images/Content/3507/Templates/77055/js/SeekerBox.js

js stjohnschelsea.org collected 2026-10-09 01:28:27 UTC 5,271 bytes, 158 lines download raw bytes

1$(document).ready(function ()
2{ 'use strict';
3 
4var bTurnOffWidget = false; // change "false" to "true" to turn off the widget.
5if(bTurnOffWidget){return false;}
6 
7var iDeskTopWidth = 992;
8var iMobileScreenAllowence = 64; // Because of other stuff on a screen, you have to assume the browser window could get bigger on a rotation.
9var bDesktopScreenPossible = (screen.width + iMobileScreenAllowence) >= iDeskTopWidth;
10
11// Set up cookies code.
12  
13var bCookiesWork = true; // assume cookies work, so we can test them.
14
15function SetCookie(CookieName, Data, bSessionCookie) { 
16	if (bCookiesWork) {
17		var sExpires = ''; // There is no 'expires=', which ensures we have a session cookie.
18		if (!bSessionCookie) {sExpires = ' expires=Mon, 18 Jan 2038 00:00:01 UTC;';} // 1 day + 3 hours before the Unix end-of-the-world date.
19		document.cookie = CookieName + '=' + Data + ';' + sExpires + ' path=/';
20	}
21}
22
23function DeleteCookie(CookieName) { // Set to a date way in the past.
24	if (bCookiesWork) {
25		document.cookie = CookieName + '=; expires=Thu, 01 Jan 1970 00:00:01 UTC; path=/;'; // 1 second after Unix start-of-the-world date.
26	}
27}
28
29function getCookie(cname) { // Modified from W3C code.
30	if (bCookiesWork) {
31		var name = cname + "=";
32		var decodedCookie = decodeURIComponent(document.cookie);
33		var ca = decodedCookie.split(';');
34		for(var i = 0; i <ca.length; i++) {
35			var c = ca[i];
36			while (c.charAt(0) == ' ') {
37				c = c.substring(1);
38			}
39			if (c.indexOf(name) === 0) {
40				return c.substring(name.length, c.length);
41			}
42		}
43	}
44	return "";
45}
46
47function bCookieContainsData(CookieName, Data) {
48	return (getCookie(CookieName) === Data);
49}
50
51// Code to make the survey form work. 
52// See if cookies actually work.
53 SetCookie('TESTCOOKIE', 'TestValue', false); // test a permanent cookie.
54 bCookiesWork = bCookieContainsData('TESTCOOKIE', 'TestValue');
55 DeleteCookie('TESTCOOKIE');
56
57var BodyTag = $('body');
58var bIsLoggedIn = BodyTag.hasClass('logged_in_user');
59var SeekerBox = BodyTag.find('section.SeekerBox');
60var Footer = BodyTag.find('footer');
61
62// Work out whether to run or not.
63var PageName = window.location.hostname.toLowerCase();
64if (PageName === 'templates.churchinsight.com' || 
65    PageName === 'templates.hubb.church' || 
66    PageName === 'templates.hubb.digital') {bIsLoggedIn = false;} // Make sure widget appears 
67 
68function ActivateTopLevelPopUp(){
69	SeekerBox.addClass('Shrink');	
70	if(getCookie('SeekerPopUpSeen') === '') {
71		SetCookie('SeekerPopUpSeen', 'shrunk', true);
72	}
73}
74
75// Sort out the close icons
76var Close = SeekerBox.find('img.Close');
77Close.click(function(){
78  if(SeekerBox.hasClass('BigBox')){
79  	SeekerBox.removeClass('BigBox');
80	ActivateTopLevelPopUp();
81  } else {
82    SetCookie('SeekerPopUpSeen', 'closed', true); // save a session cookie so we don't show pop-up again. (might be permanent on a real site.)
83  	SeekerBox.hide();
84    Footer.removeClass('WidgetShowing');
85  }
86});
87
88// Sort out the see-more links
89var bClockElasped = false;
90 
91var SSA = SeekerBox.find('div.SmallSeekerArticle');
92var bSSApublished = (SSA.length !== 0);
93if(bSSApublished){
94  var A = SSA.find('a');
95  A.click(function(){
96      bClockElasped = true;
97    SeekerBox.removeClass('Shrink').addClass('BigBox');
98  });
99}
100
101if (!bIsLoggedIn && bSSApublished && bCookiesWork) {
102  if(getCookie('SeekerPopUpSeen') === '') {
103	var D = new Date(); // get current time.
104	var iD = D.getTime(); // turn into milliseconds.
105	var SurveyClock = getCookie('SurveyClock');
106	if(SurveyClock === ''){ // Clock not started yet.
107		var MS = iD.toString();
108		SetCookie('SurveyClock', MS, true); // save initial value
109	} else {
110		var iMS = parseInt(SurveyClock);
111		var iElasped = Math.floor((iD -  iMS)/1000);
112		bClockElasped = (iElasped > 20); // only true after 30 seconds.
113	}
114	if (bClockElasped) {
115		ActivateTopLevelPopUp();
116    }
117  }
118}
119
120// Poll routine
121function PollCheckClock(){
122	if(!bClockElasped){
123		var D = new Date(); // get current time.
124		var iD = D.getTime(); // turn into milliseconds.
125		var SurveyClock = getCookie('SurveyClock');
126		var iMS = parseInt(SurveyClock);
127		var iElasped = Math.floor((iD -  iMS)/1000);
128		bClockElasped = (iElasped > 20); // only true after 30 seconds.
129		if (bClockElasped) {
130			ActivateTopLevelPopUp();
131		}
132	}
133}
134
135// Code to make seeker box shrink after 30 seconds
136if(!bIsLoggedIn && bSSApublished && !bClockElasped && getCookie('SeekerPopUpSeen') === '' && getCookie('SurveyClock') !== '') {
137	window.setInterval(function(){PollCheckClock();}, 100); // poll
138}
139 
140var bShrinkAtOnce = !bDesktopScreenPossible || (getCookie('SeekerPopUpSeen') === 'shrunk');
141if(bShrinkAtOnce){
142  ActivateTopLevelPopUp();
143}
144 
145/* move the Recaptcha widget */
146var RC = SeekerBox.find('div.invisible-recaptcha');
147 if (RC.length > 0) {
148 	var FB = SeekerBox.find('input.sitebutton[type="button"]');
149   	RC.insertAfter(FB);
150 }
151 
152var bHideWidget = (BodyTag.find('section.slice_content_page div.main-content div.NoWidgetOnPage').length !== 0);
153if (!bIsLoggedIn && bSSApublished && !bHideWidget && getCookie('SeekerPopUpSeen') !== 'closed') {
154 	SeekerBox.removeClass('HideElement');
155  	Footer.addClass('WidgetShowing');
156}
157
158});

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.