PageSourceSearch

https://www.chesco.org/Assets/Scripts/SplashModal/SplashModalRender.js

js chesco.org collected 2026-09-24 09:09:44 UTC 4,600 bytes, 131 lines download raw bytes

1function SplashModalRender() {
2	var splashContentHash = null;
3
4	SplashModalRender.prototype.triggerRender = function (filter) {
5
6		var self = this;
7
8		this._bindModalClicks();
9		
10		const params = new URLSearchParams(filter);
11		params.set('requestMode', '0')
12
13		$.ajax({
14			url: '/api/v1/SplashModal/Get?' + params.toString(),
15			type: 'GET',
16			cache: false,
17			async: false,
18			success: function (response) {
19				self._setSplashContent(response);
20				$('#SplashMessage button.cp-Splash-Btn--NoShow').focus();
21			},
22			error: function (xhr, textStatus, exception) {
23				console.log("Error: " + xhr.statusText + "\nStatus: " + xhr.status);
24			},
25			beforeSend: function () {
26				ajaxPostBackStart('Loading');
27			},
28			complete: function () {
29				ajaxPostBackEnd();
30			}
31		});
32	};
33
34	SplashModalRender.prototype._bindModalClicks = function () {
35		function fadeOut() {
36			$("#SplashMessageWrapper").fadeOut(300, function () {
37				$(this).remove();
38				$('html, body').css('overflow', '');
39				$('#skipToContentLinks a.skipToContentLink').focus();
40			});
41		}
42
43		$('.cp-Splash-Btn--Close, .cp-Splash-close').click(function () {
44			fadeOut();
45		});
46
47		$('.cp-Splash-Btn--NoShow').click(function () {
48			localStorage.setItem("splashModalDontShowAgain" + splashContentHash, "true");
49			fadeOut();
50		});
51
52		$(document).keydown(function (event) {
53			if (event.keyCode === 27 && $('#SplashMessageWrapper').is(':visible') === true) {
54				fadeOut();
55				return;
56			}
57
58			if (event.keyCode === 9 && $('#SplashMessageWrapper').is(':visible') === true) {
59				var focusableSelectors = 'a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';
60				var focusableElements = $('#SplashMessage').find(focusableSelectors).filter(':visible').toArray();
61
62				if (focusableElements.length === 0) return;
63
64				var firstElement = focusableElements[0];
65				var lastElement = focusableElements[focusableElements.length - 1];
66
67				if (event.shiftKey) {
68					if (document.activeElement === firstElement) {
69						event.preventDefault();
70						lastElement.focus();
71					}
72				} else {
73					if (document.activeElement === lastElement) {
74						event.preventDefault();
75						firstElement.focus();
76					}
77				}
78			}
79		});
80	}
81
82	SplashModalRender.prototype._setSplashContent = function (splashModal) {
83		if (this._canBeRendered(splashModal)) {
84			$('#cp-Splash-title').text(splashModal.Title);
85			$('#editorContentDesc').html(splashModal.Content);
86			$('.cp-Splash-wrapper').css('display', 'flex');
87			$('html, body').css('overflow', 'hidden');
88			$('#SplashMessage').focus();
89
90			var modal = document.getElementById("SplashMessage");
91			modal.style.display = "block";
92
93			splashContentHash = this._getEditorContentHash(splashModal.Content + splashModal.Title);
94		}
95	};
96
97	SplashModalRender.prototype._validateStartAndEndDates = function (splashModal) {
98		if (!splashModal.DateFormat)
99			return false;
100
101		var today = moment();
102		var startDate = moment(splashModal.StartDate + ' ' + splashModal.StartTime, splashModal.DateFormat.toUpperCase() + ' hh:mm A');
103		var endDate = moment(splashModal.EndDate + ' ' + splashModal.EndTime, splashModal.DateFormat.toUpperCase() + ' hh:mm A');
104
105		return (!startDate.isValid() && !endDate.isValid()) || (startDate.isValid() && endDate.isValid() && startDate.isBefore(today) && endDate.isAfter(today))
106			|| (startDate.isValid() && !endDate.isValid() && startDate.isBefore(today)) || (!startDate.isValid() && endDate.isValid() && endDate.isAfter(today));
107	}
108
109	SplashModalRender.prototype._getEditorContentHash = function (editorContent) {
110		var hash = 0;
111
112		if (editorContent == null || editorContent.length === 0) return hash;
113
114		for (i = 0; i < editorContent.length; i++) {
115			char = editorContent.charCodeAt(i);
116			hash = ((hash << 5) - hash) + char;
117			hash = hash & hash;
118		}
119
120		return hash;
121	}
122
123	SplashModalRender.prototype._canBeRendered = function (splashModal) {
124		var contentHash = this._getEditorContentHash(splashModal.Content + splashModal.Title);
125		var cachedDontShowAgainConfig = localStorage.getItem("splashModalDontShowAgain" + contentHash);
126		var validDates = this._validateStartAndEndDates(splashModal);
127		var hasContent = splashModal.Content != null && splashModal.Content.length !== 0;
128		var visible = (splashModal.Visibility > 0 && splashModal.Visibility !== 2) || (splashModal.Visibility === 2 && $("#pagePageID").val() === "1");
129		return visible && hasContent && validDates && cachedDontShowAgainConfig == null;
130	}
131}

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.