Source of latinsample.js

function appendsample() {
	var rows = document.getElementsByClassName('glyphs')[0].rows;
	for (var row of rows) {
		// append sample column
		var samplecol = row.getElementsByClassName('sample');
		if (!this.value.length) {
			row.removeChild(samplecol[0]);
			continue;
		}
		if (samplecol.length) {
			samplecol = samplecol[0];
		}
		else {
			samplecol = row.appendChild(document.createElement('TD'));
			samplecol.className = 'sample';
		}

		// prepare alphabet lookup table
		cols = [ row.cells[0] ];
		for (var col = 1; col <= samplecol.cellIndex; col++) {
			var next = cols[col - 1].nextSibling;
			if (next == samplecol) break;
			cols[col] = next;
			for (var span = 1; span < cols[col].colSpan; span++) {
				var same = cols[col];
				cols[++col] = same;
			}
		}
		for (var col = 0; col < cols.length; col++) {
			cols[col] = cols[col].innerHTML.trimRight();
		}

		// copy letters into sample
		var output = '';
		var input = this.value.toUpperCase();
		for (var i = 0; i < input.length; i++) {
			var col = input.charCodeAt(i) - 64;
			if (col < 1) col = 27; // space
			else if (cols[28] && i && col == input.charCodeAt(i - 1) - 64) {
				col = 28; // repetition char
			}
			if (row.id == 'suetterlin' && col == 19) {
				var final = input.length == i + 1 || input[i + 1] == ' ';
				output += cols[col].split('&nbsp;')[final ? 1 : 0];
			}
			else if (col < cols.length) {
				var final = cols[col] || ' ';
				if (!/^<svg/.test(cols[col])) final = `<span>${final}</span>`;
				output += final;
			}
			else {
				output += '<b> </b>';
			}
			if (row.parentNode.tagName == 'THEAD') {
				output += col < 26 ? ' ' : '· '; // number separator
			}
		}
		if (cols[29] && !cols[28]) {
			// circumfix sign if no repetition
			output = cols[29] + output + (cols[30] || cols[29]);
		}
		samplecol.innerHTML = output;
	}
};

function getrequest(name) {
	// find GET variable in page request
	var match = new RegExp('[?&]'+name+'=([^&]*)');
	var param = match.exec(window.location.search);
	return param ? decodeURIComponent(param[1]) : '';
}

function prependinput(target) {
	var form = document.createElement('FORM');
	form.id = 'search';
	form.className = 'aside';
	form.onsubmit = function () { return false };

	var input = document.createElement('INPUT');
	input.oninput = appendsample;
	input.placeholder = 'Sample';
	input.type = 'search';
	input.name = 'q';
	if (input.value = getrequest('q')) {
		input.oninput();
	}

	form.appendChild(input);
	target.parentNode.insertBefore(form, target);
}