PageSourceSearch

https://www.kaleidahealth.org/js/common.js

js kaleidahealth.org collected 2026-09-24 18:47:23 UTC 9,480 bytes, 238 lines download raw bytes

1/* --------- GPS LOCATION DETECTION AND IN VENUE CHECKING ---------- */ 
2function checkInVenue(deviceCoords) {
3	var bnmcCoords = {'lat':42.901271,'lng':-78.865848}
4	var mfsCoords = {'lat':42.9906827,'lng':-78.729334}
5	if (isInArea(deviceCoords, 650, bnmcCoords)) { // set to 650 for PROD
6			venueIDval = 147
7	} else if (isInArea(deviceCoords, 650, mfsCoords)) {
8			venueIDval = 134
9	} else {
10			venueIDval = 0
11	}
12	console.log(venueIDval)
13	window.sessionStorage.setItem("inVenue",venueIDval); // ACTIVE VENUE
14
15	if (checkConnection()) {
16		if (mobileAndTabletcheck()) {
17			// console.log('Indoors Starting')
18			// indoorsApp.start(venueIDval); // TURN OFF FOR DESKTOP TESTING
19		}
20	} 
21}
22
23function isInArea(center, radius, loc) {
24	var R = 6371;
25	var lat1 = loc.lat;
26	var lon1 = loc.lng;
27	var lat2 = center.lat;
28	var lon2 = center.lng;
29	var dLat = (lat2 - lat1) * Math.PI / 180;
30	var dLon = (lon2 - lon1) * Math.PI / 180;
31	var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
32	Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
33	Math.sin(dLon / 2) * Math.sin(dLon / 2);
34	var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
35	var d = R * c;
36	return (d * 1000 <= radius)
37};
38
39/* --------- CHECK FOR KALEIDA-WIFI ----------- */
40function onKaleidaWiFI() {
41	if (isCordova()) {
42		var params = {};
43		addressimpl.request("getIPAddress", JSON.stringify(params), function(ipAddress) {
44		var ipCheck = ipAddress.includes("172.28")	// CHECK for 172.28...	
45			if (ipCheck) {
46				window.sessionStorage.setItem("OnKaleidaWiFI", true)
47			}
48		}, function() {
49			return;
50		});
51	}
52}
53
54/* --------- FUNCTIONAL FUNCTIONS ----------- */
55function checkConnection() {
56	if (typeof window.orientation !== 'undefined') {
57		var networkState = navigator.network.connection.type;	
58		var states = {};
59		states[Connection.UNKNOWN]  = 'Unknown connection';
60		states[Connection.ETHERNET] = 'Ethernet connection';
61		states[Connection.WIFI]     = 'WiFi connection';
62		states[Connection.CELL_2G]  = 'Cell 2G connection';
63		states[Connection.CELL_3G]  = 'Cell 3G connection';
64		states[Connection.CELL_4G]  = 'Cell 4G connection';
65		states[Connection.CELL]     = 'Cell generic connection';
66		states[Connection.NONE]     = 'No network connection';
67		
68		if (states[networkState] == 'No network connection') {
69			return false
70		} else {
71			return true
72		}
73	} else { return true }
74}
75
76function formateDate(date) {
77	var newDate = date.replace(/-/g, "/");
78	var d = new Date(newDate);
79	var curr_date = d.getDate();
80	var curr_month = d.getMonth();
81	curr_month++;
82	var curr_year = d.getFullYear();
83	return curr_month + "/" + curr_date + "/" + curr_year;
84}
85
86function formatTime(date) {
87	var time = new Date(date);	
88	var ftime = time.toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, "$1$3")
89	return ftime;
90}
91
92function mobileAndTabletcheck() {
93    var check = false;
94    (function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
94sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
95    return check;
96};
97
98function isMobile() {
99	var isMobileCheck = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i)
100	return isMobileCheck;
101}
102
103function getOS() {
104	var userAgent = window.navigator.userAgent,
105		platform = window.navigator.platform,
106		macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
107		windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
108		iosPlatforms = ['iPhone', 'iPad', 'iPod'],
109		os = null;
110
111	if (macosPlatforms.indexOf(platform) !== -1) {
112		os = 'Mac OS';
113	} else if (iosPlatforms.indexOf(platform) !== -1) {
114		os = 'iOS';
115	} else if (windowsPlatforms.indexOf(platform) !== -1) {
116		os = 'Windows';
117	} else if (/Android/.test(userAgent)) {
118		os = 'Android';
119	} else if (!os && /Linux/.test(platform)) {
120		os = 'Linux';
121	}
122	return os;
123}
124
125/* --------- LOG IN FUNCTIONS ----------- */
126function updateLogInUseSession() {
127	var currentDate = new Date();
128	var extendedMinutes = new Date(currentDate.getTime() + (15*60*1000)); // ADD 15 MINUTES
129	window.sessionStorage.setItem("KHLogIn",extendedMinutes); // UPDATE SESSION STORAGE
130}
131
132function checkLogInUseTime() {
133	var sessionTime = new Date(window.sessionStorage.getItem("KHLogIn"));
134	var currentDate = new Date();
135	var timeNow = new Date(currentDate.getTime());
136	if (sessionTime > timeNow) {
137		return true
138	} else {
139		return false
140	}
141}
142
143/* --------- FORMAT DATE ----------- */
144// RETURNS "Monday, April 19, 2021" WHEN PASSED "04/21/2021"
145function formatDate(passedDate) {
146	var formattedDate = "";
147	var d_names = new Array("Sunday", "Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday");
148	var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
148November", "December");
149	var d = new Date(passedDate);
150	var curr_day = d.getDay();
151	var curr_date = d.getDate();
152	var curr_month = d.getMonth();
153	var curr_year = d.getFullYear();
154	formattedDate = d_names[curr_day] + ", " + m_names[curr_month] + " " + curr_date + ", " + curr_year;
155	return formattedDate;
156}
157
158/* --------- AJAX ERROR CODES AND MESSAGES ----------- */
159function ajaxErrorCheck(jqXHR, exception) {
160	var msg = '';
161		if (jqXHR.status === 0) {
162			msg = 'Not connect.\n Verify Network.';
163		} else if (jqXHR.status == 404) {
164			msg = 'Requested page not found. [404]';
165		} else if (jqXHR.status == 500) {
166			msg = 'Internal Server Error [500].';
167		} else if (exception === 'parsererror') {
168			msg = 'Requested JSON parse failed.';
169		} else if (exception === 'timeout') {
170			msg = 'Time out error.';
171		} else if (exception === 'abort') {
172			msg = 'Ajax request aborted.';
173		} else {
174			msg = 'Uncaught Error.\n' + jqXHR.responseText;
175		}
176	return msg;
177}
178
179/* --------- GET QUERY VARIABLE VALUE ----------- */
180function getQueryVariable(variable) {
181	var query = window.location.search.substring(1);
182	var vars = query.split("&");
183	for (var i=0;i<vars.length;i++) {
184		var pair = vars[i].split("=");
185		if(pair[0] == variable){return pair[1];}
186	}
187	return(false);
188}
189
190// OR THIS ONE
191
192// GET QUERYSTRING VALUES
193var qs = (function(a) {
194    if (a == "") return {};
195    var b = {};
196    for (var i = 0; i < a.length; ++i)
197    {
198        var p=a[i].split('=', 2);
199        if (p.length == 1)
200            b[p[0]] = "";
201        else
202            b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
203    }
204    return b;
205})(window.location.search.substr(1).split('&'));
206
207
208/* --------- FORMAT PHONE NUMBER ----------- */
209function formatPhoneNumber(phoneNumberString) {
210	var cleaned = ('' + phoneNumberString).replace(/\D/g, '');
211	var match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/);
212	if (match) {
213		var intlCode = (match[1] ? '+1 ' : '');
214		return [intlCode, '(', match[2], ') ', match[3], '-', match[4]].join('');
215	}
216	return null;
217}
218
219
220// This fixes a bug where Yext is adding a utm_source parameter to the URL without a preceding /
221function ensureUtmSourceHasSlash(url) {
222  // Check if ?utm_source exists and doesn't have a / before it, then add a /
223  if (url.indexOf('?utm_source') !== -1 && url.indexOf('/?utm_source') === -1) {
224    // Split the URL into two parts, insert the /, and then rejoin them
225    const parts = url.split('?utm_source');
226    return `${parts[0]}/?utm_source${parts[1]}`;
227  }
228  return url;
229}
230
231document.addEventListener('DOMContentLoaded', function() {
232    // Run the function when the DOM is ready
233    const originalUrl = window.location.href;
234    const modifiedUrl = ensureUtmSourceHasSlash(originalUrl);
235
236    // Update the URL with the modified version
237    history.replaceState({}, document.title, modifiedUrl);
238});

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.