PageSourceSearch

https://thecommunityguide.org/TemplatePackage/contrib/sites/communityguide/js/app.js?_=7935

js thecommunityguide.org collected 2026-10-02 03:00:27 UTC 2,238 bytes, 79 lines download raw bytes

1
2class CGPage {
3	constructor() {
4		window.addEventListener('load', () => this.init())
5	}
6
7	init() {
8		this.handleReadMoreBoxes();
9		this.updateFooter();
10	}
11
12	handleReadMoreBoxes() {
13		const heightThreshold = 800;
14		$('main .cg-box').not('.read-more').each( (i, e) => {
15			let $el = $(e);
16			if ( heightThreshold > $el.height() ) {
17				return;
18			}
19			$el.addClass('read-more closed');
20			let $button = $('<button class="read-more">Read More</button>');
21			$button.on( 'click', () => {
22				$el.removeClass('closed').addClass('open');
23			} );
24			$el.append( $button );
25		} );
26	}
27
28	// update static footer v2
29	updateFooter() {
30		const footer = document.querySelector('footer.cg-footer');
31		footer.dates = footer.querySelector('[data-dates]');
32		footer.source = footer.querySelector('.contentsource a');
33		footer.citation = footer.querySelector('[data-citation]');
34
35		// leave previous footer version alone
36		if (!footer.dataset.version) {
37			return;
38		}
39
40		const dates = {
41			reviewed: document.querySelector('meta[property="cdc:last_reviewed"]')?.getAttribute('content') || '',
42			updated: document.querySelector('meta[property="cdc:last_updated"]')?.getAttribute('content') || '',
43		}
44
45		Object.entries(dates).forEach(([key, date]) => {
46			if (date) {
47				let p = document.createElement('p');
48				p.innerHTML =  CDC.Common.cleanHTML(`Page last ${key}: ${date}`)
49				footer.dates.append(p);
50			}
51		});
52
53		// homepage stays blank
54		if ('/' === CDC.parseUrl().pathname || document.documentElement?.classList.contains('cdc-page-type-home')) {
55			return;
56		}
57
58		if (footer.source?.href) {
59			footer.source.href = document.location.href;
60		}
61
62		// build citation
63		let title = document.querySelector('h1.page-title, .page-title')?.innerHTML || '';
64		if (footer.citation && title) {
65			let citation = [
66				'<b>Sample Citation:</b>',
67				`${title}.`,
68				document.location.href,
69				dates.updated ? ` - Updated: ${dates.updated}.` : '',
70			].map(item => String(item).trim()).filter(item => item);
71			let p = document.createElement('p');
72			p.innerHTML = CDC.Common.cleanHTML(citation.join(' '));
73			footer.citation.append(p);
74		}
75	}
76
77}
78
79window.CGPage = new CGPage();

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.