Source of clipboard.js
copyhint = true;
function clipboardcopy(val) {
if (window && window.clipboardData) {
return window.clipboardData.setData('text', val);
}
if (document.queryCommandSupported('copy')) {
var textArea = document.createElement('textarea');
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';
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;
}