PageSourceSearch

https://vegafoon.org/_static/--/wp-content/js/textarea-autosize.mi…/script_m-1641292264j.js

js vegafoon.org collected 2026-10-08 01:55:07 UTC 44,620 bytes, 1,408 lines download raw bytes

1// https://www.npmjs.com/package/autosize/v/5.0.1, with the global renamed to `textarea_autosize`.
2!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).textarea_autosize=t()}(this,function(){var e,t,n="function"==typeof Map?new Map:(e=[],t=[],{has:function(t){return e.indexOf(t)>-1},get:function(n){return t[e.indexOf(n)]},set:function(n,o){-1===e.indexOf(n)&&(e.push(n),t.push(o))},delete:function(n){var o=e.indexOf(n);o>-1&&(e.splice(o,1),t.splice(o,1))}}),o=function(e){return new Event(e,{bubbles:!0})};try{new Event("test")}catch(e){o=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}function r(e){var t=n.get(e);t&&t.destroy()}function i(e){var t=n.get(e);t&&t.update()}var l=null;return"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((l=function(e){return e}).destroy=function(e){return e},l.update=function(e){return e}):((l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return function(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!n.has(e)){var t,r=null,i=null,l=null,d=function(){e.clientWidth!==i&&c()},u=function(t){window.removeEventListener("resize",d,!1),e.removeEventListener("input",c,!1),e.removeEventListener("keyup",c,!1),e.removeEventListener("autosize:destroy",u,!1),e.removeEventListener("autosize:update",c,!1),Object.keys(t).forEach(function(n){e.style[n]=t[n]}),n.delete(e)}.bind(e,{height:e.style.height,resize:e.style.resize,overflowY:e.style.overflowY,overflowX:e.style.overflowX,wordWrap:e.style.wordWrap});e.addEventListener("autosize:destroy",u,!1),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",c,!1),window.addEventListener("resize",d,!1),e.addEventListener("input",c,!1),e.addEventListener("autosize:update",c,!1),e.style.overflowX="hidden",e.style.wordWrap="break-word",n.set(e,{destroy:u,update:c}),"vertical"===(t=window.getComputedStyle(e,null)).resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal"),r="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),isNaN(r)&&(r=0),c()}function a(t){var n=e.style.width;e.style.width="0px",e.style.width=n,e.style.overflowY=t}function s(){if(0!==e.scrollHeight){var t=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}(e),n=document.documentElement&&document.documentElement.scrollTop;e.style.height="",e.style.height=e.scrollHeight+r+"px",i=e.clientWidth,t.forEach(function(e){e.node.scrollTop=e.scrollTop}),n&&(document.documentElement.scrollTop=n)}}function c(){s();var t=Math.round(parseFloat(e.style.height)),n=window.getComputedStyle(e,null),r="content-box"===n.boxSizing?Math.round(parseFloat(n.height)):e.offsetHeight;if(r<t?"hidden"===n.overflowY&&(a("scroll"),s(),r="content-box"===n.boxSizing?Math.round(parseFloat(window.getComputedStyle(e,null).height)):e.offsetHeight):"hidden"!==n.overflowY&&(a("hidden"),s(),r="content-box"===n.boxSizing?Math.round(parseFloat(window.getComputedStyle(e,null).height)):e.offsetHeight),l!==r){l=r;var i=o("autosize:resized");try{e.dispatchEvent(i)}catch(e){}}}}(e)}),e}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],r),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],i),e}),l});
3;
4(function () {
5	'use strict';
6
7	function getPostAs() {
8		const postAs = document.querySelector('#hc_post_as');
9		return postAs && postAs.value;
10	}
11
12	function setPostAs(value) {
13		const postAs = document.querySelector('#hc_post_as');
14		if (postAs) {
15			postAs.value = value;
16		}
17	}
18
19	function isGuest() {
20		return getPostAs() === 'guest';
21	}
22
23	function hide(el) {
24		if (!el) {
25			return;
26		}
27
28		el.style.display = 'none';
29	}
30
31	function show(el, forceDisplay) {
32		if (!el) {
33			return;
34		}
35
36		el.style.removeProperty('display');
37		if (forceDisplay){
38			el.style.display = forceDisplay;
39		}
40	}
41
42	function applyStyles(el, styles) {
43		if (!el) {
44			return;
45		}
46
47		Object.keys(styles || {}
47).forEach(prop => (el.style[prop] = styles[prop]));
48	}
49
50	function getElementOffset(el) {
51		if (!el) {
52			return;
53		}
54
55		const rect = el.getBoundingClientRect();
56		return {
57			top: rect.top + window.pageYOffset,
58			left: rect.left + window.pageXOffset,
59		};
60	}
61
62	function getHeightWithMargins(el) {
63		if (!el) {
64			return 0;
65		}
66
67		const style = getComputedStyle(el);
68		return (
69			el.offsetHeight +
70			(parseInt(style.marginTop, 10) || 0) +
71			(parseInt(style.marginBottom, 10) || 0)
72		);
73	}
74
75	function getWidthWithMargins(el) {
76		if (!el) {
77			return 0;
78		}
79
80		const style = getComputedStyle(el);
81		return (
82			el.offsetWidth +
83			(parseInt(style.marginLeft, 10) || 0) +
84			(parseInt(style.marginRight, 10) || 0)
85		);
86	}
87
88	const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
89
90	function animate({ el, props = {}, duration = 100, cb = () => {} } = {}) {
91		if (!el) {
92			return;
93		}
94
95		// Convert property names to kebab case.
96		props = Object.fromEntries(
97			Object.entries(props).map(([prop, val]) => [
98				prop.replace(/[A-Z]/g, l => `-${l.toLowerCase()}`),
99				val,
100			])
101		);
102
103		const currentStyles = getComputedStyle(el);
104		const transitioningProperties = Object.keys(props);
105		const currentProps = Object.fromEntries(
106			Object.entries(props).map(([key]) => [key, currentStyles[key]])
107		);
108
109		let willAnythingChange = false;
110		Object.keys(props).forEach(key => {
111			willAnythingChange = willAnythingChange || currentProps[key] !== props[key];
112		});
113
114		if (prefersReducedMotion || !willAnythingChange) {
115			applyStyles(el, props);
116			cb();
117			return;
118		}
119
120		applyStyles(el, {
121			...currentProps,
122			transitionProperty: transitioningProperties.join(', '),
123			transitionDuration: `${duration}ms`,
124		});
125
126		let timeout;
127
128		// Double rAF after setting styles, for browser compatibility.
129		requestAnimationFrame(() => {
130			requestAnimationFrame(() => {
131				applyStyles(el, props);
132				const handler = e => {
133					if (!e || (e.target === el && transitioningProperties.includes(e.propertyName))) {
134						el.style.removeProperty('transition-property');
135						el.style.removeProperty('transition-duration');
136						el.removeEventListener('transitionend', handler);
137						el.removeEventListener('transitioncancel', handler);
138						clearTimeout(timeout);
139						cb();
140					}
141				};
142				el.addEventListener('transitionend', handler);
143				el.addEventListener('transitioncancel', handler);
144				timeout = setTimeout(handler, duration + 50); // Fail-safe, in case there is no transition.
145			});
146		});
147	}
148
149	function fadeIn({ el, duration, cb = () => {} } = {}) {
150		if (!el) {
151			return;
152		}
153
154		el.style.removeProperty('display');
155		el.style.opacity = '0';
156
157		animate({
158			el,
159			props: { opacity: '1' },
160			duration,
161			cb: () => {
162				el.style.removeProperty('opacity');
163				cb();
164			},
165		});
166	}
167
168	function fadeOut({ el, duration, cb = () => {} } = {}) {
169		if (!el) {
170			return;
171		}
172
173		el.style.removeProperty('display');
174		el.style.opacity = '1';
175
176		animate({
177			el,
178			props: { opacity: '0' },
179			duration,
180			cb: () => {
181				el.style.display = 'none';
182				el.style.removeProperty('opacity');
183				cb();
184			},
185		});
186	}
187
188	function slideDown({ el, duration, cb = () => {} } = {}) {
189		if (!el) {
190			return;
191		}
192
193		el.style.removeProperty('display');
194		const finalHeight = getComputedStyle(el).height;
195		el.style.height = '0';
196
197		animate({
198			el,
199			props: { height: finalHeight },
200			duration,
201			cb: () => {
202				el.style.removeProperty('height');
203				cb();
204			},
205		});
206	}
207
208	function slideUp({ el, duration, initialDisplay, cb = () => {} } = {}) {
209		if (!el) {
210			return;
211		}
212
213		if (initialDisplay !== undefined) {
214			el.style.display = initialDisplay;
215		} else {
216			el.style.removeProperty('display');
217		}
218
219		animate({
220			el,
221			props: { height: 0 },
222			duration,
223			cb: () => {
224				el.style.display = 'none';
225				el.style.removeProperty('height');
226				cb();
227			},
228		});
229	}
230
231	function createTooltip(
232		anchor,
233		tooltipId,
234		contents,
235		offset = { top: 0, left: 0 },
236		rtlOffset = { top: 0, left: 0 }
237	) {
238		if (anchor) {
239			anchor.addEventListener('mouseenter', () => {
240				const pos = getElementOffset(anchor);
241				let style;
242				if (HighlanderComments.text_direction === 'rtl') {
243					style = `top:${pos.top + rtlOffset.top}
243px; left:${pos.left + rtlOffset.left}px;`;
244				} else {
245					style = `top:${pos.top + offset.top}px; left:${pos.left + offset.left}px;`;
246				}
247
248				const popup = document.createElement('div');
249				popup.id = tooltipId;
250				popup.classList.add('highlander-tooltip');
251				document.body.appendChild(popup);
252				popup.innerHTML = contents;
253				popup.style = style;
254			});
255
256			anchor.addEventListener('mouseleave', () => {
257				const popup = document.querySelector(`#${tooltipId}`);
258				fadeOut({
259					el: popup,
260					cb: () => {
261						popup.remove();
262						document.querySelectorAll('.highlander-tooltip').forEach(el => el.remove);
263					},
264				});
265			});
266		}
267	}
268
269	function addIframe({ classes = [], src } = {}) {
270		const iframe = document.createElement('iframe');
271		if (classes.length) {
272			iframe.classList.add(...classes);
273		}
274		iframe.height = '1';
275		iframe.width = '1';
276		iframe.style.display = 'none';
277		iframe.src = src;
278		document.body.appendChild(iframe);
279	}
280
281	function getCommentList() {
282		const list = document.querySelectorAll(
283			'#thecomments, .thecomments, #commentlist, #comment-list, #comments-list, .commentlist, .comment-list, .comments-list, .com-list, #comments'
284		);
285		return list.length ? list[list.length - 1] : null;
286	}
287
288	const HighlanderComments = {
289		...(window.HighlanderComments || {}),
290		commentList: null,
291
292		initialHeight: 70,
293
294		cookies: {
295			facebook: 'wpc_fbc',
296			twitter: 'wpc_tc',
297			wordpress: 'wpc_wpc',
298			googleplus: 'wpc_gpc',
299		},
300		popups: {
301			facebook: ',height=400,width=600',
302			twitter: ',height=515,width=600',
303			wordpress: ',height=500,width=500',
304		},
305		temp_cookie_data: '',
306		currentParent: false,
307		currentParentId: false,
308		currentParentMargins: {},
309		keyCodeReturn: 13,
310
311		resizeCallback: function () {},
312
313		init: function () {
314			document.querySelectorAll('#respond').forEach(el => el.classList.add('js'));
315
316			HighlanderComments.commentList = getCommentList();
317
318			if ( HighlanderComments.isJetpack && HighlanderComments.readCookie( 'wpcom_highlander_3pc_check' ) === null ) {
319				document.querySelectorAll( '#comment-form-nascar' ).forEach(el => hide(el));
320			}
321
322			document
323				.querySelectorAll('#comment-form-nascar a')
324				.forEach(el => el.addEventListener('click', HighlanderComments.clickService));
325
326			document
327				.querySelectorAll('#postas-wordpress, #postas-facebook, #postas-twitter')
328				.forEach(el => el.addEventListener('click', HighlanderComments.clickExternalTab));
329
330			window.addEventListener('message', e => {
331				if (e.origin !== 'https://public-api.wordpress.com') {
332					return;
333				}
334
335				let message = e && e.data;
336				if (typeof message === 'string') {
337					try {
338						message = JSON.parse(message);
339					} catch (err) {
340						return;
341					}
342				}
343
344				const type = message && message.type;
345				if (type === 'googlePlusButtonClick') {
346					HighlanderComments.onGooglePlusButtonClick(message);
347				}
348
349				if (type === 'googlePlusSignIn') {
350					HighlanderComments.onGooglePlusSignIn(message);
351				}
352			});
353
354			document.querySelectorAll('.comment-form-field input, textarea#comment').forEach(el => {
355				if (el.value !== '') {
356					HighlanderComments.hideLabels(el);
357				}
358			});
359
360			document.querySelectorAll('div.comment-form-fields input').forEach(el => {
361				el.addEventListener('change', () => HighlanderComments.toggleLabel(el));
362				el.addEventListener('focus', () => HighlanderComments.hideLabels(el));
363				el.addEventListener('blur', () => HighlanderComments.showLabels(el));
364			});
365
366			document.querySelectorAll('div.comment-form-fields label').forEach(el =>
367				el.addEventListener('click', () => {
368					HighlanderComments.hideLabels(
369						el.parentElement && el.parentElement.querySelectorAll('.comment-form-input input')
370					);
371				})
372			);
373
374			document.querySelectorAll('#email').forEach(el =>
375				el.addEventListener('blur', () => {
376					HighlanderComments.updateAvatarWithGravatar('#email');
377
378					const author = document.querySelector('#author');
379
380					if (window.Gravatar && author && !author.value) {
381						Gravatar.autofill(el.value, {
382							displayName: 'author',
383							url: 'url', // Their first available link, or profile URL if none
384						});
385
386						const afd = Gravatar.autofill_data;
387						Gravatar.autofill_data = function (hash) {
388							afd.call(Gravatar, hash);
389							document
390								.querySelectorAll('input#url')
391								.forEach(el => el.dispatchEvent(new Event('change')));
392							author.dispatchEvent(new Event('change'));
393							author.dispatchEvent(new MouseEvent('click'));
394						};
395					}
396				})
397			);
398
399			const textArea = document.querySelector('textarea#comment');
400
401			if (!textArea) {
402				return;
403			}
404
405			if (window.textarea_autosize) {
406				textArea.addEventListener('autosize:resized', HighlanderComments.resizeCallback);
407				window.textarea_autosize(textArea);
408			}
409
410			textArea.style.resize = 'none';
411			textArea.dispatchEvent(new Event('change'));
412
413			textArea.addEventListener('focus', () => HighlanderComments.hideLabels(textArea));
414			textArea.addEventListener('blur', () => HighlanderComments.showLabels(textArea));
415
416			textArea.addEventListener('keydown', e => {
417				if (e.code === 'Tab') {
418					e.preventDefault();
419
420					let focusSel = '#comment-submit';
421					if (isGuest()) {
422						focusSel =
423							HighlanderComments.comment_registration === '1' ? '#postas-wordpress' : '#email';
424					}
425					document.querySelectorAll(focusSel).forEach(el => el.focus());
426				}
427
428				if (HighlanderComments.isCommandOrControlKeyDown(e) && e.code === 'Enter') {
429					document
430						.querySelectorAll('#comment-submit')
431						.forEach(el => el.dispatchEvent(new MouseEvent('click')));
432				}
433			});
434
435			textArea.addEventListener(
436				'focus',
437				() => {
438					const googlePlusSignIn = document.querySelector('#googleplus-sign-in');
439					if (!googlePlusSignIn) {
440						return;
441					}
442
443					const target = googlePlusSignIn.contentWindow;
444
445					if (target && typeof target.postMessage === 'function') {
446						try {
447							target.postMessage(JSON.stringify({ type: 'googlePlusLoadJS', data: 0 }), '*');
448						} catch (e) {
449							return;
450						}
451					}
452				},
453				{ once: true }
454			);
455
456			// Client-side form validation
457			const form = document.querySelector('#commentform');
458			form.addEventListener('submit', e => {
459				let verified = true;
460				// Comment text required
461				if (textArea.value === '') {
462					document.querySelectorAll('label[for="comment"]').forEach(el => {
463						fadeOut({
464							el,
465							cb: () => {
466								el.textContent = HighlanderComments.enterACommentError;
467								fadeIn({
468									el,
469									cb: () => {
470										el.classList.add('error');
471									},
472								});
473							},
474						});
475					});
476
477					document.querySelectorAll('#comment-form-comment').forEach(el => {
478						el.classList.add('error');
479						textArea.addEventListener('focus', () => el.classList.remove('error'), {
480							once: true,
481						});
482					});
483					verified = false;
484				}
485
486				// Only exists if email/name are required
487				if (
488					isGuest() &&
489					(document.querySelector('#comment-form-guest label span[class="required"]') ||
490						document.querySelector('#comment-form-guest label[class="error"]'))
491				) {
492					function handleMissingField(name, error) {
493						document.querySelectorAll(`label[for="${name}"]`).forEach(el => {
494							fadeOut({
495								el,
496								cb: () => {
497									el.innerHTML = error;
498									fadeIn({ el, cb: () => el.classList.add('error') });
499								},
500							});
501						});
502						document
503							.querySelectorAll(`div.comment-form-${name} .comment-form-input`)
504							.forEach(el => el.classList.add('error'));
505						document
506							.querySelectorAll(`input#${name}`)
507							.forEach(el =>
508								el.addEventListener(
509									'focus',
510									() => el.parentElement && el.parentElement.classList.remove('error'),
511									{ once: true }
512								)
513							);
514
515						verified = false;
516					}
517
518					const email = document.querySelector('#email') && document.querySelector('#email').value;
519					if (email === '' || !email.match(/^.*@.*\..*$/)) {
520						let error;
521						if (email === '') {
522							error = HighlanderComments.enterEmailError;
523						} else {
524							error = '<span class="nopublish">' + HighlanderComments.invalidEmailError + '</span>';
525						}
526						handleMissingField('email', error);
527					}
528
529					const author =
530						document.querySelector('#author') && document.querySelector('#author').value;
531					if (author === '') {
532						const error = HighlanderComments.enterAuthorError;
533						handleMissingField('author', error);
534					}
535				}
536
537				// Don't allow "guest" comments if auth is required
538				if (HighlanderComments.comment_registration === '1' && isGuest
538()) {
539					document.querySelectorAll('#comment-form-nascar > p').forEach(el => {
540						el.classList.add('error');
541						fadeOut({ el, cb: () => fadeIn(el) });
542					});
543					verified = false;
544				}
545
546				// Set a cookie to remember which was the last used tab
547				HighlanderComments.writeCookie('hc_post_as', getPostAs(), 7, '.wordpress.com');
548
549				if (!verified) {
550					e.preventDefault();
551					return;
552				}
553
554				HighlanderComments.clickSubmit();
555			});
556
557			// Set up the identity block based on WP options, logged in state, etc
558			if (HighlanderComments.comment_registration === '1') {
559				// Must be logged in to comment (guest commenting not allowed)
560				document.querySelectorAll('#comment-form-guest').forEach(el => hide(el));
561				if (!HighlanderComments.isJetpack && !HighlanderComments.userIsLoggedIn) {
562					// Force to guest posting if they're not logged in, which should actually not allow itself
563					HighlanderComments.clickGuestTab();
564					document
565						.querySelectorAll('#comment-form-wordpress')
566						.forEach(el => el.classList.remove('selected'));
567					setPostAs('guest');
568				}
569			} else {
570				// Guest commenting is allowed
571				if (
572					HighlanderComments.userIsLoggedIn &&
573					document.querySelector('#comment-form-wordpress.selected')
574				) {
575					// User is logged in and we're looking at the WP UI already, get rid of guest commenting
576					hide(document.querySelector('#comment-form-guest'));
577				}
578			}
579			const selected = document.querySelector('.comment-form-service.selected');
580			if (selected && !selected.matches('#comment-form-guest')) {
581				// Something other than Guest is selected, hide the auth strip
582				hide(document.querySelector('#comment-form-nascar'));
583			}
584
585			if (typeof addComment !== 'undefined') {
586				HighlanderComments._moveForm = addComment.moveForm;
587				addComment.moveForm = HighlanderComments.moveForm;
588			}
589
590			// Hover Tooltips
591			createTooltip(
592				document.querySelector('#comment-form-guest .comment-form-avatar'),
593				'hltt-grav',
594				HighlanderComments.gravatarFromEmail,
595				{ top: -10, left: 35 },
596				{ top: -10, left: -130 }
597			);
598
599			createTooltip(
600				document.querySelector('#comment-form-nascar ul'),
601				'hltt-auth',
602				HighlanderComments.logInToExternalAccount,
603				{ top: -12, left: -125 },
604				{ top: -12, left: 125 }
605			);
606		},
607
608		isCommandOrControlKeyDown: function (event) {
609			// event.metaKey will be true if Command key (⌘) or Windows key is down.
610			return event.ctrlKey || event.metaKey;
611		},
612
613		_moveForm: null,
614		moveForm: function (commId, parentId, respondId, postId) {
615			if (HighlanderComments._moveForm === null) {
616				return;
617			}
618
619			const respond = document.querySelector(`#${respondId}`);
620			if (!respond) {
621				return;
622			}
623
624			respond.style.marginLeft = 0;
625			respond.style.marginRight = 0;
626
627			const t = this;
628
629			let r = false;
630			let rHeight;
631
632			if (HighlanderComments.currentParent) {
633				if (parentId === HighlanderComments.currentParentId) {
634					return false;
635				}
636
637				const wTop = window.scrollY;
638				const commElOffset = getElementOffset(document.querySelector(`#${commId}`));
639				const cTop = commElOffset && commElOffset.top;
640				const rTop = getElementOffset(respond).top;
641
642				if (rTop <= cTop) {
643					rHeight = getHeightWithMargins(respond);
644					const placeholder = document.createElement('div');
645					placeholder.id = 'highlander-placeholder';
646					applyStyles(placeholder, {
647						margin: 0,
648						padding: 0,
649						border: 0,
650						height: `${rHeight}px`,
651						visibility: 'hidden',
652						position: getComputedStyle(respond).position,
653					});
654					respond.before(placeholder);
655				}
656
657				r = HighlanderComments._moveForm.call(t, commId, parentId, respondId, postId);
658				if (r !== false) {
659					return r;
660				}
661
662				applyStyles(HighlanderComments.currentParent, HighlanderComments.currentParentMargins);
663
664				document.querySelectorAll('#highlander-placeholder').forEach(el => el.remove());
665
666				if (rTop <= cTop) {
667					try {
668						window.scrollTo({ left: window.scrollX, top: wTop - rHeight, behavior: 'smooth' });
669					} catch (err) {
670						window.scrollTo(window.scrollX, wTop - rHeight);
671					}
672				}
673
674				HighlanderComments.moveFormNow.call(t, commId, parentId, respondId);
675			} else {
676				r = HighlanderComments._moveForm.call(t, commId, parentId, respondId, postId);
677				if (r === false) {
678					HighlanderComments.moveFormNow.call(t, commId, parentId, respondId);
679				}
680			}
681
682			return r;
683		},
684
685		moveFormNow: function (commId, parentId, respondId) {
686			const comment = document.querySelector(`#comment-${parentId}`);
687			let currentParent = comment && comment.closest('.highlander-comment');
688
689			if (!currentParent) {
690				currentParent = comment && comment.closest('.comment');
691			}
692			HighlanderComments.currentParentId = parentId;
693
694			const respond = document.querySelector(`#${respondId}`);
695
696			if (!currentParent || !respond) {
697				return;
698			}
699
700			if (!currentParent.querySelector(`#${respondId}`)) {
701				const el = currentParent.parentElement;
702				let betterParent = el.closest('.children');
703				if (!betterParent) {
704					betterParent = el.closest('.highlander-comment');
705					if (!betterParent) {
706						betterParent = el.closest('.comment');
707					}
708				}
709
710				if (betterParent) {
711					currentParent = betterParent;
712				}
713			}
714
715			const style = getComputedStyle(currentParent);
716			const currentParentMargins = {
717				backgroundColor: style.backgroundColor,
718				marginLeft: style.marginLeft,
719				marginRight: style.marginRight,
720			};
721
722			// Register the new values.
723			HighlanderComments.currentParent = currentParent;
724			HighlanderComments.currentParentMargins = currentParentMargins;
725
726			let autoWidth = false;
727
728			const offOrder =
729				HighlanderComments.text_direction === 'rtl' ? ['Left', 'Right'] : ['Right', 'Left'];
730
731			const parentOffset = getElementOffset(currentParent);
732
733			offOrder.forEach(v => {
734				const outerWidth = getWidthWithMargins(currentParent);
735
736				if (currentParentMargins[`margin${v}`] === '0px') {
737					const oldOff = parentOffset.left + v === 'Right' ? outerWidth : 0;
738					currentParent.style[`margin${v}`] = '0px';
739					let newOff = parentOffset.left + v === 'Right' ? outerWidth : 0;
740					if (oldOff !== newOff) {
741						newOff = v === 'Right' ? newOff - oldOff : oldOff - newOff;
742						currentParent.style[`margin${v}`] = newOff;
743						currentParentMargins[`margin${v}`] = newOff;
744						autoWidth = true;
745					}
746				}
747			});
748
749			if (autoWidth) {
750				currentParent.width = 'auto';
751				currentParentMargins.width = 'auto';
752			}
753
754			const rgbaTransparent = /rgba.*,\s*0\s*\)/;
755
756			if (
757				currentParentMargins.backgroundColor === 'transparent' ||
758				currentParentMargins.backgroundColor.match(rgbaTransparent)
759			) {
760				let el = currentParent;
761				let bg = 'transparent';
762				let bgi = getComputedStyle(el).backgroundImage;
763
764				while (
765					bgi === 'none' &&
766					el.parentNode &&
767					el.parentNode !== document &&
768					(bg === 'transparent' || bg.match(rgbaTransparent))
769				) {
770					el = el.parentNode;
771					bgi = getComputedStyle(el).backgroundImage;
772					bg = getComputedStyle(el).backgroundColor;
773				}
774
775				currentParent.style.backgroundColor = bg;
776			}
777
778			const cancel = document.getElementById('cancel-comment-reply-link');
779			let listOffsetSource = HighlanderComments.commentList;
780
781			let redoMargins = false;
782			let grandWidth;
783
784			// Re-initialize the commentList if it was not found during init
785			if (!listOffsetSource) {
786				listOffsetSource = HighlanderComments.commentList = getCommentList();
787			}
788
789			let cp = HighlanderComments.currentParent;
790			while (cp !== HighlanderComments.commentList && cp !== document) {
791				const style = getComputedStyle(cp);
792				if (style.overflow === 'hidden' || style.overflowX === 'hidden') {
793					listOffsetSource = cp;
794					break;
795				}
796
797				cp = cp.parentElement;
798			}
799
800			const listOffset = getElementOffset(listOffsetSource);
801
802			HighlanderComments._unmoveForm = cancel.onclick;
803			cancel.onclick = function () {
804				return HighlanderComments.unmoveForm.call(this);
805			};
806
807			if (currentParentMargins.marginLeft.toString().includes('%')) {
808				grandWidth = currentParent.parentElement.offsetWidth;
809				currentParentMargins.marginLeft =
810					(parseFloat(currentParentMargins.marginLeft) / 100) * grandWidth;
811				redoMargins = true;
812			}
813
814			if (currentParentMargins.marginRight.toString().includes('%')) {
815				grandWidth = currentParent.parentElement.offsetWidth;
816				currentParentMargins.marginRight =
817					(parseFloat(currentParentMargins.marginRight) / 100) * grandWidth;
818				redoMargins = true;
819			}
820
821			if (redoMargins) {
822				applyStyles(currentParent, currentParentMargins);
823			}
824
825			const currentMargins = {
826				left: parseInt(getComputedStyle(currentParent).marginLeft, 10),
827				right: parseInt(getComputedStyle(currentParent).marginRight, 10),
828			};
829
830			listOffset.right = listOffset.left + getWidthWithMargins(listOffsetSource);
831			parentOffset.left -= currentMargins.left;
832			parentOffset.right = parentOffset.left + getWidthWithMargins(currentParent);
833
834			hide(respond);
835			animate({
836				el: currentParent,
837				props: {
838					marginLeft: `${currentMargins.left - (parentOffset.left - listOffset.left)}px`,
839					marginRight: `${currentMargins.right - (listOffset.right - parentOffset.right)}px`,
840				},
841				duration: 300,
842				cb: () => {
843					slideDown({
844						el: respond,
845						duration: 300,
846						cb: () => {
847							document.querySelectorAll(`#${commId} .comment-reply-link`).forEach(el => el.focus());
848							document.querySelectorAll('#comment').forEach(el => el.focus());
849							HighlanderComments.resizeCallback();
850
851							const clearDiv = document.createElement('div');
852							clearDiv.classList.add('clear');
853							clearDiv.id = 'threaded-clear';
854							respond.querySelector('form').after(clearDiv);
855						},
856					});
857				},
858			});
859		},
860
861		_unmoveForm: null,
862		unmoveForm: function () {
863			const r = HighlanderComments._unmoveForm.call(this);
864			if (r !== false) {
865				return r;
866			}
867
868			animate({
869				el: HighlanderComments.currentParent,
870				props: HighlanderComments.currentParentMargins,
871				duration: 300,
872				cb: () => {
873					applyStyles(HighlanderComments.currentParent, HighlanderComments.currentParentMargins);
874					HighlanderComments.currentParent = false;
875					HighlanderComments.currentParentId = false;
876				},
877			});
878
879			show(document.querySelector('#respond'));
880			document.querySelectorAll('#respond div#threaded-clear').forEach(el => el.remove());
881			HighlanderComments.resizeCallback();
882
883			return r;
884		},
885
886		// Escape an input string.
887		HTMLToText: function (string) {
888			const temp = document.createElement('span');
889			temp.textContent = string;
890			return `${temp.innerHTML}`;
891		},
892
893		switchAccount: function () {
894			document.querySelectorAll('.comment-form-service').forEach(el => {
895				el.classList.remove('selected');
896				hide(el);
897			});
898
899			setPostAs('guest');
900			document
901				.querySelectorAll('#comment-form-nascar > p')
902				.forEach(el => el.classList.remove('error'));
903			show(document.querySelector('#comment-form-nascar'));
904
905			if (HighlanderComments.comment_registration === '1') {
906				hide(document.querySelector('#comment-form-guest')); // Guest commenting not allowed
907				HighlanderComments.resizeCallback();
908			} else {
909				slideDown({
910					el: document.querySelector('#comment-form-guest'),
911					cb: HighlanderComments.resizeCallback,
912				});
913				HighlanderComments.clickGuestTab();
914			}
915		},
916
917		setConnectingToText: function (serviceFriendlyName) {
918			document
919				.querySelectorAll('#comment-form-load-service p')
920				.forEach(
921					el =>
922						(el.textContent = HighlanderComments.connectingToText.replace(
923							'%s',
924							serviceFriendlyName
925						))
926				);
927		},
928
929		updateLoadServiceVisibility: function (tab) {
930			document.querySelectorAll('.comment-form-service').forEach(el => {
931				el.style.visibility = 'visible';
932				el.classList.remove('selected');
933
934				if (el.matches(tab)) {
935					show(el, 'block');
936				} else {
937					hide(el);
938				}
939			});
940		},
941
942		clickService: function (e) {
943			e.preventDefault();
944
945			const tab = this.href.replace(/^.*#/, '#').split(':');
946
947			if (tab[0] === '#comment-form-load-service' && tab[1]) {
948				HighlanderComments.setConnectingToText(tab[1]);
949			} else {
950				setPostAs(tab[0].split('-').pop());
951			}
952
953			HighlanderComments.updateLoadServiceVisibility('#comment-form-load-service');
954
955			document
956				.querySelectorAll('#comment-form-nascar li.selected')
957				.forEach(el => el.classList.remove('selected'));
958			e.target.closest('li').classList.add('selected');
959			HighlanderComments.resizeCallback();
960		},
961
962		setServiceSelected: function (service) {
963			HighlanderComments.updateLoadServiceVisibility('#comment-form-load-service');
964			document
965				.querySelectorAll('#comment-form-nascar li.selected')
966				.forEach(el => el.classList.remove('selected'));
967			document.querySelectorAll(`#postas-${service}`).forEach(el => el.parentElement.classList.add('selected'));
968			hide(document.querySelector('#comment-form-nascar'));
969			HighlanderComments.resizeCallback();
970		},
971
972		clickGuestTab: function (e) {
973			const guest = document.querySelector('#comment-form-guest');
974
975			if (HighlanderComments.comment_registration === '1') {
976				hide(guest);
977			} else {
978				guest.classList.add('selected');
979			}
980
981			const email = document.querySelector('#email');
982			if (email && email.value.includes('@twitter.example.com')) {
983				email.value = '';
984				email.blur();
985			}
986
987			HighlanderComments.updateAvatarWithGravatar(email);
988
989			// Reenable subscription options
990			document.querySelectorAll('#comment-form-subscribe').forEach(el => {
991				el.style.opacity = 1;
992				el.querySelectorAll('input').forEach(input => input.removeAttribute('disabled'));
993			});
994			HighlanderComments.resizeCallback();
995		},
996
997		updateAvatarWithGravatar: function (e) {
998			const gravBase =
999				('https:' === location.protocol ? 'https://secure' : 'http://www') +
1000				'.gravatar.com/avatar/';
1001			// When Avatars are disabled, Gravatar can be undefined, so we check against that first
1002			// and fall back to an unknown gravatar if it isn't
1003			let gravSource = gravBase + 'ad516503a11cd5ca435acc9bb6523536?s=54&forcedefault=1';
1004
1005			if (typeof Gravatar !== 'undefined' && e && e.value) {
1006				gravSource = gravBase + Gravatar.md5(e.value.toLowerCase().trim()) + '?s=25';
1007			}
1008
1009			if (HighlanderComments.gravDefault !== 'gravatar_default') {
1010				gravSource += '&d=' + encodeURIComponent(HighlanderComments.gravDefault);
1011			}
1012
1013			document
1014				.querySelectorAll('#comment-form-guest .comment-form-avatar img')
1015				.forEach(el => el.setAttribute('src', gravSource));
1016		},
1017
1018		getServiceData: function (service) {
1019			const data = HighlanderComments.readCookie(HighlanderComments.cookies[service]);
1020
1021			if (data === null || typeof data.access_token === 'undefined' || !data.access_token) {
1022				return false;
1023			}
1024			return data;
1025		},
1026
1027		ext_win: false,
1028		ext_win_check: false,
1029		pollExternalWindow: function (service, from_tab) {
1030			if (!HighlanderComments.ext_win || HighlanderComments.ext_win.closed) {
1031				// If the cookie is available, then we must have auth'd successfully
1032				const foo = HighlanderComments.getServiceData(service);
1033				if (HighlanderComments.getServiceData(service)) {
1034					HighlanderComments.doExternalLoggedIn(service);
1035					return;
1036				}
1037				HighlanderComments.doExternalCanceled(service, from_tab);
1038				HighlanderComments.ext_win = false;
1039				clearInterval(HighlanderComments.ext_win_check);
1040			}
1041		},
1042
1043		cancelExternalWindow: function () {
1044			if (HighlanderComments.ext_win) {
1045				HighlanderComments.ext_win.close();
1046			}
1047			HighlanderComments.doExternalCanceled(getPostAs(), true);
1048		},
1049
1050		clickExternalTab: function (e) {
1051			if (typeof e === 'undefined') {
1052				return;
1053			}
1054
1055			let fromTab = 1;
1056			let service;
1057			if (typeof e === 'string') {
1058				service = e;
1059			} else {
1060				service = e.currentTarget.id.split('-')[1];
1061				if (!e.currentTarget.matches('a')) {
1062					fromTab = 0;
1063				}
1064			}
1065
1066			slideUp({
1067				el: document.querySelector('#comment-form-guest'),
1068				initialDisplay: 'block',
1069				cb: () => {
1070					hide(document.querySelector('#comment-form-nascar'));
1071
1072					HighlanderComments.resizeCallback();
1073
1074					clearInterval(HighlanderComments.ext_win_check);
1075					document.querySelectorAll('.highlander-tooltip').forEach(el => el.remove());
1076
1077					if (
1078						// Found commenting cookies
1079						HighlanderComments.readCookie(HighlanderComments.cookies[service]) !== null &&
1080						// WordPress tab, and we're logged in
1081						((service === 'wordpress' && HighlanderComments.userIsLoggedIn) ||
1082							// Not WordPress tab
1083							service !== 'wordpress')
1084					) {
1085						if (fromTab) {
1086							HighlanderComments.doExternalLoggedIn(service);
1087						}
1088					} else if (service === 'googleplus') {
1089						// Nothing to do - we're already logged in at this point
1090					} else {
1091						HighlanderComments.ext_win = window.open(
1092							`${HighlanderComments.connectURL}&service=${service}`,
1093							'highconn',
1094							`status=0,toolbar=0,location=1,menubar=0,directories=0,resizable=1,scrollbars=0${HighlanderComments.popups[service]}`
1095						);
1096						HighlanderComments.ext_win_check = setInterval(
1097							() => HighlanderComments.pollExternalWindow(service, fromTab),
1098							100
1099						);
1100					}
1101				},
1102			});
1103		},
1104
1105		doExternalLoggedIn: function (service) {
1106			clearInterval(HighlanderComments.ext_win_check);
1107
1108			const data = HighlanderComments.getServiceData(service);
1109
1110			if (typeof data !== 'object') {
1111				return;
1112			}
1113
1114			if (service === 'wordpress') {
1115				// Allow subscription options
1116				document.querySelectorAll('#comment-form-subscribe').forEach(el => {
1117					el.style.opacity = '1';
1118					el.querySelectorAll('input').forEach(input => input.removeAttribute('disabled'));
1119				});
1120
1121				// Set up Gravatar and flag as logged in. Load a page to trigger cookies etc
1122				document
1123					.querySelectorAll(`#comment-form-${service} .comment-form-avatar img`)
1124					.forEach(el => el.setAttribute('src', data.avatar));
1125				HighlanderComments.userIsLoggedIn = true;
1126				if (!HighlanderComments.isJetpack) {
1127					addIframe({
1128						src: `${HighlanderComments.homeURL}highlander.login/`,
1129						classes: ['highlander-auth-init'],
1130					});
1131				}
1132			} else if (service === 'facebook') {
1133				document
1134					.querySelectorAll(`#comment-form-${service} .comment-form-avatar img`)
1135					.forEach(el => el.setAttribute('src', data.avatar));
1136			} else {
1137				if (service === 'twitter') {
1138					// Disable subscription options for Twitter since we don't have an email
1139					document.querySelectorAll('#comment-form-subscribe').forEach(el => {
1140						el.style.opacity = '0.5';
1141						el.querySelectorAll('input').forEach(input => {
1142							input.disabled = true;
1143							input.removeAttribute('checked');
1144						});
1145					});
1146				}
1147
1148				// Run all external avatars through ImgPress to resize them
1149				let url = data.avatar;
1150				try {
1151					if (data.avatar.match(/^(https?:)?\/\/i[012]\.wp\.com\//)) {
1152						url = data.avatar.replace(/^https?:/, location.protocol);
1153					} else if (data.avatar.match(/^(https?:)?\/\/(.*?\.)gravatar\.com\//)) {
1154						url = data.avatar.replace(/^https?:/, location.protocol);
1155					} else {
1156						const avatarURL = new URL(data.avatar, location);
1157
1158						url = `${location.protocol}//i0.wp.com/${avatarURL.host}${avatarURL.pathname}?`;
1159						if (host === 'graph.facebook.com' && query.length) {
1160							url += 'q=' + encodeURIComponent(query) + '&';
1161						}
1162						url += 'resize=25%2C25';
1163					}
1164				} catch (error) {
1165					url = data.avatar;
1166				}
1167
1168				document
1169					.querySelectorAll(`#comment-form-${service} .comment-form-avatar img`)
1170					.forEach(el => el.setAttribute('src', url));
1171			}
1172
1173			document.querySelectorAll('#email').forEach(el => {
1174				el.value = data.email;
1175				el.dispatchEvent(new Event('change'));
1176			});
1177			document.querySelectorAll('#author').forEach(el => {
1178				el.value = data.name;
1179				el.dispatchEvent(new Event('change'));
1180			});
1181			document.querySelectorAll('#url').forEach(el => {
1182				el.value = data.link;
1183				el.dispatchEvent(new Event('change'));
1184				el.dispatchEvent(new MouseEvent('click'));
1185			});
1186			document.querySelectorAll(`#${service}-avatar`).forEach(el => (el.value = data.avatar));
1187			document.querySelectorAll(`#${service}-user_id`).forEach(el => (el.value = data.uid));
1188			document
1189				.querySelectorAll(`#${service}-access_token`)
1190				.forEach(el => (el.value = data.access_token));
1191
1192			setPostAs(service);
1193
1194			// The child of the li.selected can be a <A> (WP, FB, Twitter) or an <IFRAME> (Google)
1195			const selectedLink = document.querySelector('#comment-form-nascar li.selected a');
1196			const selectedIFrame = document.querySelector('#comment-form-nascar li.selected iframe');
1197
1198			if (
1199				(selectedLink && service === selectedLink.id.replace('postas-', '')) ||
1200				(selectedIFrame && service === 'googleplus')
1201			) {
1202				hide(document.querySelector('#comment-form-load-service'));
1203				show(document.querySelector(`#comment-form-${service}`), 'block');
1204				document
1205					.querySelectorAll(`#comment-form-${service} .comment-form-posting-as strong`)
1206					.forEach(el => (el.textContent = data.name + ':'));
1207				HighlanderComments.resizeCallback();
1208			}
1209		},
1210
1211		doExternalCanceled: function (service, from_tab) {
1212			if (from_tab) {
1213				let gravSource = `${
1214					location.protocol === 'https:' ? 'https://secure' : 'http://www'
1215				}.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25`;
1216				if (HighlanderComments.gravDefault !== 'gravatar_default') {
1217					gravSource += '&d=' + encodeURIComponent(HighlanderComments.gravDefault);
1218				}
1219				document
1220					.querySelectorAll(`#comment-form-${service} .comment-form-avatar img`)
1221					.forEach(el => el.setAttribute('src', gravSource));
1222				document.querySelectorAll(`.comment-meta-${service}`).forEach(el => (el.value = ''));
1223				document
1224					.querySelectorAll(`#postas-${service} span`)
1225					.forEach(el => (el.innerHTML = '&nbsp; &nbsp; &nbsp;'));
1226				hide(document.querySelector(`#comment-form-${service}`));
1227				HighlanderComments.switchAccount();
1228			}
1229		},
1230
1231		doExternalLogout: function (service) {
1232			let hostname;
1233			if (document.location.hostname.includes('.wordpress.com')) {
1234				hostname = 'wordpress.com';
1235			} else {
1236				hostname = document.location.hostname;
1237			}
1238
1239			HighlanderComments.writeCookie(HighlanderComments.cookies[service], '', -10, hostname);
1240			HighlanderComments.doExternalCanceled(service, true);
1241
1242			if (service === 'wordpress') {
1243				HighlanderComments.userIsLoggedIn = false;
1244				addIframe({ src: HighlanderComments.logoutURL });
1245			}
1246
1247			if (service === 'googleplus') {
1248				addIframe({ src: 'https://accounts.google.com/logout' });
1249			}
1250		},
1251
1252		clickSubmit: function (e) {
1253			document.querySelectorAll('#respond input#comment-submit').forEach(el => {
1254				el.value = HighlanderComments.HTMLToText(HighlanderComments.submittingText);
1255				el.classList.add('disabled');
1256				el.disabled = true;
1257				const p = document.createElement('p');
1258				p.id = 'comment-form-submitting';
1259				el.before(p);
1260				el.remove();
1261				p.appendChild(el);
1262			});
1263		},
1264
1265		toggleLabel: function (inputs) {
1266			if (window.innerWidth && window.innerWidth <= 450) {
1267				return;
1268			}
1269
1270			inputs = inputs instanceof Node ? [inputs] : inputs;
1271			inputs.forEach(input => {
1272				const parent = input.closest('div.comment-form-field');
1273				if (parent) {
1274					parent
1275						.querySelectorAll('label')
1276						.forEach(label => (label.style.opacity = input.value.length ? 0.05 : 1));
1277				}
1278			});
1279		},
1280
1281		hideLabels: function (inputs) {
1282			inputs = inputs instanceof Node ? [input
1282s] : inputs;
1283			inputs.forEach(input => {
1284				if (window.innerWidth === 0 || (window.innerWidth > 450 && !input.placeholder)) {
1285					const parent = input.closest('div.comment-form-field');
1286					if (parent) {
1287						if (!input.value.length) {
1288							parent.querySelectorAll('label').forEach(label => fadeOut({ el: label }));
1289						} else {
1290							parent.querySelectorAll('label').forEach(label => hide(label));
1291						}
1292					}
1293				}
1294
1295				input.parentElement.classList.add('active');
1296			});
1297		},
1298
1299		showLabels: function (inputs) {
1300			inputs = inputs instanceof Node ? [inputs] : inputs;
1301			inputs.forEach(input => {
1302				if (window.innerWidth === 0 || (window.innerWidth > 450 && !input.placeholder)) {
1303					const parent = input.closest('div.comment-form-field');
1304					if (parent) {
1305						if (!input.value.length) {
1306							parent.querySelectorAll('label').forEach(label => fadeIn({ el: label }));
1307						} else {
1308							parent.querySelectorAll('label').forEach(label => show(label));
1309						}
1310					}
1311				}
1312
1313				input.parentElement.classList.remove('active');
1314			});
1315		},
1316
1317		// Google Sign-in is a little different than the other services
1318		// It uses its own JavaScript API loaded in its own iframe
1319		// (public.api/connect/?googleplus-sign-in=1)
1320		// We listen for messages from that iframe here
1321		onGooglePlusSignIn: function (message) {
1322			let hostname;
1323			if (document.location.hostname.includes('.wordpress.com')) {
1324				hostname = 'wordpress.com';
1325			} else {
1326				hostname = document.location.hostname;
1327			}
1328
1329			if (typeof message.data.error === 'undefined') {
1330				const value = new URLSearchParams(message.data).toString().replace(/\+/g, '%20');
1331				HighlanderComments.writeCookie('wpc_gpc', value, 1, hostname);
1332
1333				document
1334					.querySelectorAll('#comment-form-nascar li.selected')
1335					.forEach(el => el.classList.remove('selected'));
1336				document.querySelector('#googleplus-sign-in').parentElement.classList.add('selected');
1337
1338				HighlanderComments.doExternalLoggedIn('googleplus');
1339			} else {
1340				HighlanderComments.doExternalLogout('googleplus');
1341			}
1342		},
1343
1344		onGooglePlusButtonClick: function () {
1345			HighlanderComments.setConnectingToText('Google');
1346			HighlanderComments.updateLoadServiceVisibility('#comment-form-load-service');
1347			HighlanderComments.clickExternalTab('googleplus');
1348		},
1349
1350		/* Read the contents of a named cookie, assuming they are query-string-style
1351    delimited, and return them as a JS hash. */
1352		readCookie: function (c) {
1353			const nameEQ = c + '=';
1354			let cookieStrings = document.cookie.split(';');
1355
1356			if (c === 'wpc_gpc' && !document.cookie) {
1357				// Needed for IE because it doesn’t allow setting cookies in iframes from another domain, unless we send P3P headers
1358				cookieStrings = HighlanderComments.temp_cookie_data.split(';');
1359			}
1360			for (let i = 0; i < cookieStrings.length; i++) {
1361				let cookieString = cookieStrings[i];
1362				while (cookieString.charAt(0) === ' ') {
1363					cookieString = cookieString.substring(1, cookieString.length);
1364				}
1365				if (cookieString.indexOf(nameEQ) === 0) {
1366					const chunk = cookieString.substring(nameEQ.length, cookieString.length);
1367					const pairs = chunk.split('&');
1368					let cookie_data = {};
1369					for (let num = pairs.length - 1; num >= 0; num--) {
1370						const pair = pairs[num].split('=');
1371						cookie_data[pair[0]] = decodeURIComponent(pair[1]);
1372					}
1373					return cookie_data;
1374				}
1375			}
1376			return null;
1377		},
1378
1379		writeCookie: function (name, value, days, domain) {
1380			let expires;
1381			if (days) {
1382				const date = new Date();
1383				date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
1384				expires = '; expires=' + date.toGMTString();
1385			} else {
1386				expires = '';
1387			}
1388
1389			if (domain) {
1390				domain = '; domain=' + domain;
1391			} else {
1392				domain = '';
1393			}
1394
1395			HighlanderComments.temp_cookie_data = document.cookie =
1396				name + '=' + value + expires + '; path=/' + domain;
1397		},
1398	};
1399
1400	window.HighlanderComments = HighlanderComments;
1401
1402	if (document.readyState !== 'loading') {
1403		HighlanderComments.init();
1404	} else {
1405		document.addEventListener('DOMContentLoaded', HighlanderComments.init);
1406	}
1407})();
1408;

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.