mirror of
https://git.proxmox.com/git/mirror_xterm.js
synced 2025-10-05 05:17:51 +00:00
27 lines
906 B
JavaScript
27 lines
906 B
JavaScript
(function (linkify) {
|
|
})(function (Xterm) {
|
|
Xterm.prototype.linkify = function () {
|
|
var rows = this.rowContainer.children,
|
|
buffer = document.createElement('span');
|
|
|
|
for (var i=0; i<rows.length; i++) {
|
|
var line = rows[i], nodes = line.childNodes;
|
|
|
|
for (var j=0; j<nodes.length; j++) {
|
|
var node = nodes[j];
|
|
|
|
if (node.nodeType == 3) {
|
|
var match = node.data.match(/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/);
|
|
|
|
if (match) {
|
|
var url=match[0],
|
|
newData = node.data.replace(url, '<a href="http://' + url + '" target="_blank" >' + url + '</a>');
|
|
buffer.textContent = node.data;
|
|
line.innerHTML = line.innerHTML.replace(buffer.innerHTML, newData);
|
|
this.emit('linkify:line', line);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}); |