From 6c3340051eec480233da9c214fc4e32f7515285b Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Sat, 27 Jun 2020 01:08:55 -0400 Subject: [PATCH] Add external URL launching. --- scripts/communityScripts/chat/FloofChat.html | 13 +++++++++---- scripts/communityScripts/chat/FloofChat.js | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/communityScripts/chat/FloofChat.html b/scripts/communityScripts/chat/FloofChat.html index b4a3f79978..3f45651581 100644 --- a/scripts/communityScripts/chat/FloofChat.html +++ b/scripts/communityScripts/chat/FloofChat.html @@ -172,13 +172,13 @@ case ext == "JPG": case ext == "GIF": case ext == "JPEG": - elContent = elContent.replace(this, "

" + this + ""); + elContent = elContent.replace(this, "

" + this + "📲"); break; case ext == "iframe": elContent = elContent.replace(this, "
"); break; case ext == "webm": - elContent = elContent.replace(this, "

" + this + ""); + elContent = elContent.replace(this, "

" + this + "📲"); break; case protocol === "HIFI": case protocol === "hifi": @@ -187,13 +187,14 @@ 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=)([^#\&\?]*).*/); if (youtubeMatch && youtubeMatch[2].length == 11) { - elContent = "

" + this + ""; + elContent = "

" + this + "📲"; break; } // else fall through to default default: - elContent = elContent.replace(this, "
" + this + ""); + elContent = elContent.replace(this, "
" + this + "📲"); break; + } }); @@ -285,6 +286,10 @@ function gotoURL(url) { emitWebEvent({type: "CMD", cmd: "URL", url: url}); } + + function gotoExternalURL(url) { + emitWebEvent({type: "CMD", cmd: "EXTERNALURL", url: url}); + } function gotoClipboard(url) { M.toast({html: 'Copied URL to Clipboard', classes: 'rounded pink white-text'}); diff --git a/scripts/communityScripts/chat/FloofChat.js b/scripts/communityScripts/chat/FloofChat.js index 5d7892e2dd..6dcbda8df2 100644 --- a/scripts/communityScripts/chat/FloofChat.js +++ b/scripts/communityScripts/chat/FloofChat.js @@ -310,6 +310,9 @@ function onWebEventReceived(event) { visible: true }); } + if (event.cmd === "EXTERNALURL") { + Window.openUrl(event.url); + } if (event.cmd === "COPY") { Window.copyToClipboard(event.url); }