1/** 2 * @package n3t Copylink 3 * @author Pavel Poles - n3t.cz 4 * @copyright (C) 2010 - 2022 - Pavel Poles - n3t.cz 5 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html 6 **/ 7 8document.addEventListener("copy", (e) => { 9 const options = Joomla.getOptions('plg_n3tcopylink'), 10 helper = document.createElement("div"); 11 12 // prepare suffixes 13 let suffix = options.suffix, 14 suffixHtml = options.suffixHtml; 15 16 suffix = suffix.replace('{url}', document.location.href); 17 suffix = suffix.replace('{title}', document.title); 18 19 suffixHtml = suffixHtml.replace('{url}', document.location.href); 20 suffixHtml = suffixHtml.replace('{title}', document.title); 21 22 // get clipboard contents 23 helper.appendChild(window.getSelection().getRangeAt(0).cloneContents()); 24 let text = document.getSelection().toString(), 25 html = helper.innerHTML; 26 helper.remove(); 27 28 // do not copylink small selections 29 if (text.length < options.min_selection) 30 return; 31 32 // set clipboard data 33 e.clipboardData.setData("text/plain", `${text}\n${suffix}`); 34 e.clipboardData.setData("text/html", `${html}${suffixHtml}`); 35 e.preventDefault(); 36});
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.