Improve URL formatting and refactor.

This commit is contained in:
Kalila L 2020-09-20 00:44:40 -04:00
parent 2a5604a166
commit ecf3e67bdf

View file

@ -160,7 +160,7 @@
return elContent; return elContent;
} }
// For any URLs present, unless they are already identified within // For any URLs present, unless they are already identified within
// an `a` element, linkify them. // an `a` element, linkify them.
function _linkifyUrls(matches, $el) { function _linkifyUrls(matches, $el) {
@ -181,23 +181,28 @@
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 var replaceWith = "<br/>";
+ "'class=\"responsive z-depth-2\"><br/><a href=\"javascript:gotoClipboard('" + this + "');\" target='_blank'>" + this replaceWith += "<img src='" + this + "'class=\"responsive z-depth-2\"><br/>";
+ "</a><a onclick=\"gotoExternalURL('" + this replaceWith += "<a onclick=\"gotoClipboard('" + this + "');return false;\" href=\"" + this + "\" target=\"_blank\">" + this + "</a>";
+ "');return false;\"href=\"" + this replaceWith += "<a onclick=\"gotoExternalURL('" + this + "');return false;\"href=\"" + this + "\">&#x1F4F2;</a>";
+ "\">&#x1F4F2;</a>");
elContent = elContent.replace(this, replaceWith);
break; break;
case ext == "iframe": case ext == "iframe":
elContent = elContent.replace(this, "<br/><iframe class=\"z-depth-2\" src='" + this var replaceWith = "<br/>";
+ "'width=\"440\" height=\"248\" frameborder=\"0\"></iframe>"); replaceWith += "<iframe class=\"z-depth-2\" src='" + this;
replaceWith += "'width=\"440\" height=\"248\" frameborder=\"0\"></iframe>";
elContent = elContent.replace(this, replaceWith);
break; break;
case ext == "webm": case ext == "webm":
elContent = elContent.replace(this, "<br/><video controls class=\"z-depth-2 responsive\"><source src='" + this var replaceWith = "<br/>";
+ "' type='video/" + ext + "'></video><br/><a href=\"javascript:gotoClipboard('" + this replaceWith += "<video controls class=\"z-depth-2 responsive\"><source src='" + this;
+ "');\">" + this replaceWith += "' type='video/" + ext + "'></video><br/>";
+ "</a><a onclick=\"gotoExternalURL('" + this replaceWith += "<a onclick=\"gotoClipboard('" + this + "');return false;\" href=\"" + this + "\">" + this + "</a>";
+ "');return false;\"href=\"" + this replaceWith += "<a onclick=\"gotoExternalURL('" + this + "');return false;\"href=\"" + this + "\">&#x1F4F2;</a>";
+ "\">&#x1F4F2;</a>");
elContent = elContent.replace(this, replaceWith);
break; break;
case protocol === "HIFI": case protocol === "HIFI":
case protocol === "hifi": case protocol === "hifi":
@ -206,22 +211,25 @@
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] var replaceWith = "<br/>";
+ "' frameborder='0'></iframe><br/><a href=\"javascript:gotoURL('" + this replaceWith += "<video controls class=\"z-depth-2 responsive\"><source src='" + this;
+ "');\">" + this replaceWith += "<iframe class=\"z-depth-2\" width='420' height='236' src='https://www.youtube.com/embed/" + youtubeMatch[2];
+ "</a><a onclick=\"gotoExternalURL('" + this replaceWith += "' frameborder='0'></iframe><br/><a href=\"javascript:gotoURL('" + this ;
+ "');return false;\"href=\"" + this replaceWith += "');\">" + this;
+ "\">&#x1F4F2;</a>"; replaceWith += "</a><a onclick=\"gotoExternalURL('" + this;
replaceWith += "');return false;\"href=\"" + this;
replaceWith += "\">&#x1F4F2;</a>";
elContent = replaceWith;
break; break;
} }
// else fall through to default // else fall through to default
default: default:
elContent = elContent.replace(this, "<br/><a onclick=\"gotoURL('" + this var replaceWith = "<br/>";
+ "');return false;\" href=\"" + this replaceWith += "<a onclick=\"gotoURL('" + this + "');return false;\" href=\"" + this + "\">" + this + "</a>";
+ "\">" + this replaceWith += "<a onclick=\"gotoExternalURL('" + this + "');return false;\"href=\"" + this + "\">&#x1F4F2;</a>";
+ "</a><a onclick=\"gotoExternalURL('" + this
+ "');return false;\"href=\"" + this elContent = elContent.replace(this, replaceWith);
+ "\">&#x1F4F2;</a>");
break; break;
} }