mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 05:23:09 +02:00
Add external URL launching.
This commit is contained in:
parent
dc5418748d
commit
6c3340051e
2 changed files with 12 additions and 4 deletions
|
@ -172,13 +172,13 @@
|
||||||
case ext == "JPG":
|
case ext == "JPG":
|
||||||
case ext == "GIF":
|
case ext == "GIF":
|
||||||
case ext == "JPEG":
|
case ext == "JPEG":
|
||||||
elContent = elContent.replace(this, "<br/><img src='" + this + "'class=\"responsive z-depth-2\"><br/><a href=\"javascript:gotoClipboard('" + this + "');\" target='_blank'>" + this + "</a>");
|
elContent = elContent.replace(this, "<br/><img src='" + this + "'class=\"responsive z-depth-2\"><br/><a href=\"javascript:gotoClipboard('" + this + "');\" target='_blank'>" + this + "</a><a onclick=\"gotoExternalURL('" + this + "');return false;\"href=\"" + this + "\">📲</a>");
|
||||||
break;
|
break;
|
||||||
case ext == "iframe":
|
case ext == "iframe":
|
||||||
elContent = elContent.replace(this, "<br/><iframe class=\"z-depth-2\" src='" + this + "'width=\"440\" height=\"248\" frameborder=\"0\"></iframe>");
|
elContent = elContent.replace(this, "<br/><iframe class=\"z-depth-2\" src='" + this + "'width=\"440\" height=\"248\" frameborder=\"0\"></iframe>");
|
||||||
break;
|
break;
|
||||||
case ext == "webm":
|
case ext == "webm":
|
||||||
elContent = elContent.replace(this, "<br/><video controls class=\"z-depth-2 responsive\"><source src='" + this + "' type='video/" + ext + "'></video><br/><a href=\"javascript:gotoClipboard('" + this + "');\">" + this + "</a>");
|
elContent = elContent.replace(this, "<br/><video controls class=\"z-depth-2 responsive\"><source src='" + this + "' type='video/" + ext + "'></video><br/><a href=\"javascript:gotoClipboard('" + this + "');\">" + this + "</a><a onclick=\"gotoExternalURL('" + this + "');return false;\"href=\"" + this + "\">📲</a>");
|
||||||
break;
|
break;
|
||||||
case protocol === "HIFI":
|
case protocol === "HIFI":
|
||||||
case protocol === "hifi":
|
case protocol === "hifi":
|
||||||
|
@ -187,13 +187,14 @@
|
||||||
case !!this.match(/(https?:\/\/)?(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([^& \n<]+)(?:[^ \n<]+)?/g):
|
case !!this.match(/(https?:\/\/)?(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([^& \n<]+)(?:[^ \n<]+)?/g):
|
||||||
var youtubeMatch = this.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);
|
var youtubeMatch = this.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);
|
||||||
if (youtubeMatch && youtubeMatch[2].length == 11) {
|
if (youtubeMatch && youtubeMatch[2].length == 11) {
|
||||||
elContent = "<br/><iframe class=\"z-depth-2\" width='420' height='236' src='https://www.youtube.com/embed/" + youtubeMatch[2] + "' frameborder='0'></iframe><br/><a href=\"javascript:gotoURL('" + this + "');\">" + this + "</a>";
|
elContent = "<br/><iframe class=\"z-depth-2\" width='420' height='236' src='https://www.youtube.com/embed/" + youtubeMatch[2] + "' frameborder='0'></iframe><br/><a href=\"javascript:gotoURL('" + this + "');\">" + this + "</a><a onclick=\"gotoExternalURL('" + this + "');return false;\"href=\"" + this + "\">📲</a>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// else fall through to default
|
// else fall through to default
|
||||||
default:
|
default:
|
||||||
elContent = elContent.replace(this, "<br/><a onclick=\"gotoURL('" + this + "');return false;\" href=\"" + this + "\">" + this + "</a>");
|
elContent = elContent.replace(this, "<br/><a onclick=\"gotoURL('" + this + "');return false;\" href=\"" + this + "\">" + this + "</a><a onclick=\"gotoExternalURL('" + this + "');return false;\"href=\"" + this + "\">📲</a>");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -285,6 +286,10 @@
|
||||||
function gotoURL(url) {
|
function gotoURL(url) {
|
||||||
emitWebEvent({type: "CMD", cmd: "URL", url: url});
|
emitWebEvent({type: "CMD", cmd: "URL", url: url});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gotoExternalURL(url) {
|
||||||
|
emitWebEvent({type: "CMD", cmd: "EXTERNALURL", url: url});
|
||||||
|
}
|
||||||
|
|
||||||
function gotoClipboard(url) {
|
function gotoClipboard(url) {
|
||||||
M.toast({html: 'Copied URL to Clipboard', classes: 'rounded pink white-text'});
|
M.toast({html: 'Copied URL to Clipboard', classes: 'rounded pink white-text'});
|
||||||
|
|
|
@ -310,6 +310,9 @@ function onWebEventReceived(event) {
|
||||||
visible: true
|
visible: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (event.cmd === "EXTERNALURL") {
|
||||||
|
Window.openUrl(event.url);
|
||||||
|
}
|
||||||
if (event.cmd === "COPY") {
|
if (event.cmd === "COPY") {
|
||||||
Window.copyToClipboard(event.url);
|
Window.copyToClipboard(event.url);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue