From 8fdc5e20da327970521537ff16578ee1753a6d51 Mon Sep 17 00:00:00 2001 From: Sergey Ilinykh Date: Fri, 2 Nov 2018 04:50:11 +0300 Subject: [PATCH] Merged WebKit preview fixes from master branch --- themes/chatview/psi/classic/load.js | 2 +- themes/chatview/util.js | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/themes/chatview/psi/classic/load.js b/themes/chatview/psi/classic/load.js index d682053f8..d9de36852 100644 --- a/themes/chatview/psi/classic/load.js +++ b/themes/chatview/psi/classic/load.js @@ -3,5 +3,5 @@ srvLoader.setMetaData({ version: "1.0", authors: ["Sergey Ilinykh "], description: "Classic chat view as it was before themes support.", - url: "http://psi-im.org" + url: "https://psi-im.org" }); diff --git a/themes/chatview/util.js b/themes/chatview/util.js index 57be44334..7eaa5bd3b 100644 --- a/themes/chatview/util.js +++ b/themes/chatview/util.js @@ -157,7 +157,7 @@ function initPsiTheme() { } if (link) { - var iframe = chat.util.createHtmlNode('
'); linkEl.parentNode.insertBefore(iframe, linkEl.nextSibling); } @@ -165,20 +165,20 @@ function initPsiTheme() { replaceImage : function(linkEl) { - var img = chat.util.createHtmlNode(''); linkEl.parentNode.insertBefore(img, linkEl.nextSibling); }, replaceAudio : function(linkEl) { - var audio = chat.util.createHtmlNode('
'); + var audio = chat.util.createHtmlNode('
'); linkEl.parentNode.insertBefore(audio, linkEl.nextSibling); }, replaceVideo : function(linkEl) { - var audio = chat.util.createHtmlNode('
'); + var audio = chat.util.createHtmlNode('
'); linkEl.parentNode.insertBefore(audio, linkEl.nextSibling); }, @@ -189,7 +189,7 @@ function initPsiTheme() { },function(result) { //chat.console("result ready " + chat.util.props(result, true)); var ct = result['content-type']; - if (typeof(ct) == "string") { + if ((typeof(ct) == "string") && (ct != "application/octet-stream")) { ct = ct.split("/")[0].trim(); switch (ct) { case "image": @@ -204,10 +204,10 @@ function initPsiTheme() { } } else { // fallback when no content type //chat.console("fallback") - var imageExts = ["png", "jpg", "jpeg", "gif"]; - var audioExts = ["mp3", "ogg", "aac", "flac", "wav"]; - var videoExts = ["mp4", "webm", "mkv", "mov", "avi"]; - var lpath = linkEl.pathname.toLowerCase(); + var imageExts = ["png", "jpg", "jpeg", "gif", "webp"]; + var audioExts = ["mp3", "ogg", "aac", "flac", "wav", "m4a"]; + var videoExts = ["mp4", "webm", "mkv", "mov", "avi", "ogv"]; + var lpath = linkEl.pathname.toLowerCase().split('#')[0].split('?')[0]; function checkExt(exts, replacer) { for (var i = 0; i < exts.length; i++) { if (lpath.slice(lpath.length - exts[i].length - 1) == ("." + exts[i])) { @@ -228,12 +228,12 @@ function initPsiTheme() { if (!previewsEnabled) return; var links = el.querySelectorAll("a"); - var youtube = ["youtu.be", "www.youtube.com", "m.youtube.com"]; + var youtube = ["youtu.be", "www.youtube.com", "youtube.com", "m.youtube.com"]; for (var li = 0; li < links.length; li++) { var linkEl = links[li]; if (youtube.indexOf(linkEl.hostname) != -1) { chat.util.replaceYoutube(linkEl); - } else if ((linkEl.protocol == "http:" || linkEl.protocol == "https:") && linkEl.hostname != "psi") { + } else if ((linkEl.protocol == "http:" || linkEl.protocol == "https:" || linkEl.protocol == "file:") && linkEl.hostname != "psi") { chat.util.replaceLinkAsync(linkEl); } }