PageSourceSearch

https://www.gordontilden.com/wp-content/themes/paperstreet/js/common.js?ver=1791166327

js gordontilden.com collected 2026-10-05 02:12:43 UTC 2,982 bytes, 96 lines download raw bytes

1//Global utility functions that may be used by different script files - loaded early
2var desktopScreenSize = 1025; //Mobile-desktop screen size cutoff in pixels
3
4//jQuery-based scroll position animation
5function animateScroll(animateScrollLocation, scrollTimeMilliseconds) {
6	//Set default value for time if none provided
7	scrollTimeMilliseconds = scrollTimeMilliseconds || 400;
8
9	jQuery('html, body').animate({
10		scrollTop: animateScrollLocation
11	}, scrollTimeMilliseconds);
12}
13
14//Returns true if window is above mobile size
15function isDesktopScreen() {
16	if (window.innerWidth >= desktopScreenSize) {
17		return true;
18	}
19	return false;
20}
21
22//Returns true if window is mobile size
23function isMobileScreen() {
24	if (window.innerWidth < desktopScreenSize) {
25		return true;
26	}
27	return false;
28}
29
30//Returns a random integer between a minimum and maximum
31//Minimum is INCLUSIVE, maximum is EXCLUSIVE (min. 1, max. 3 will returns 1s and 2s)
32function getRandomInt(min, max) {
33	min = Math.ceil(min);
34	max = Math.floor(max);
35	return Math.floor(Math.random() * (max - min) + min);
36}
37
38//Returns TRUE if page contains any of selected elements
39//Usage: if ($(selector).exists())
40jQuery.fn.exists = function() {
41	return this.length !== 0;
42}
43
44//Adds "active" class to an element
45//Usage: $(selector).addActive()
46jQuery.fn.addActive = function() {
47	jQuery(this).addClass('active');
48}
49
50//Removes "active" class from an element
51jQuery.fn.removeActive = function() {
52	jQuery(this).removeClass('active');
53}
54
55//Adds OR removes "active" class to an element, depending on current state
56//Usage: $(selector).toggleActive()
57jQuery.fn.toggleActive = function() {
58	if (jQuery(this).hasClass('active'))
59	{
60		jQuery(this).removeClass('active');
61		return;
62	}
63	jQuery(this).addClass('active');
64}
65
66//Returns TRUE if an element has the "active" class
67//Usage: if ($(selector).isActive())
68jQuery.fn.isActive = function() {
69	return jQuery(this).hasClass('active');
70}
71
72//Sorts elements based on data attribute after load
73//Call in document ready like so: $('.search-results-attorneys').sortItems("li", "relevance", true);
74//HTML setup has parent container with class "search-results-attorneys" and list items with custom data attribute, e.g. <li data-relevance="50">
75jQuery.fn.sortItems = function sortItems(elementType, dataAttribute, ascending) {
76	if (ascending)
77	{
78		jQuery("> " + elementType, this[0]).sort(asc_sort).appendTo(this[0]);
79	}
80	else
81	{
82		jQuery("> " + elementType, this[0]).sort(desc_sort).appendTo(this[0]);
83	}
84
85	function asc_sort(a, b){ return (jQuery(b).data(dataAttribute)) > (jQuery(a).data(dataAttribute)) ? 1 : -1; }
86	function desc_sort(a, b){ return (jQuery(b).data(dataAttribute)) < (jQuery(a).data(dataAttribute)) ? 1 : -1; }
87}
88
89//Returns value between 0-1 indicating how far down the page the user is scrolled
90function getScrollPercent() {
91	var h = document.documentElement,
92	b = document.body,
93	st = 'scrollTop',
94	sh = 'scrollHeight';
95	return (h[st]||b[st]) / ((h[sh]||b[sh]) - h.clientHeight);
96}

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.