Source of clipboard.js

copyhint = true;
function clipboardcopy(val) {
	if (window && window.clipboardData) {
		// msie
		return window.clipboardData.setData('text', val);
	}

	if (document.queryCommandSupported('copy')) {
		var textArea = document.createElement('textarea');

		// minimise styling in case it is (briefly) rendered
		textArea.style.position = 'fixed';
		textArea.style.top = 0;
		textArea.style.left = 0;
		textArea.style.width = '2em';
		textArea.style.height = '2em';
		textArea.style.padding = 0;
		textArea.style.border = 'none';
		textArea.style.outline = 'none';
		textArea.style.boxShadow = 'none';
		textArea.style.background = 'transparent';

		// temporarily add input field to copy text from
		textArea.value = val;
		document.body.appendChild(textArea);
		try {
			textArea.select();
			document.execCommand('copy');
		} catch (e) {
			console.log('could not copy "'+val+'" to clipboard');
		}
		document.body.removeChild(textArea);
	}
}

charmatch = /^U\+([0-9A-F]{4,})/;
function copycellchars() {
	var unicode = charmatch.exec(this.title);
	var str = String.fromCharCode(parseInt(unicode[1], 16));
	return clipboardcopy(str);
}

var cells = document.getElementsByTagName('TD');
for (var i = 0; i < cells.length; i++) {
	if (!cells[i].title) continue;
	if (!charmatch.test(cells[i].title)) continue;
	cells[i].onclick = copycellchars;
}