diff options
author | 2017-07-16 01:18:50 +0300 | |
---|---|---|
committer | 2017-07-17 15:07:27 +0300 | |
commit | f6903148671437dd4a62c856f3561801f64a59fa (patch) | |
tree | c4446970b0a7824c4d9fb167e7939fd1f8224bdb /juick-www/src/main/js | |
parent | 8138f0d6a7ef65e760d6feeb2e61018f65cf0f55 (diff) |
www: update youtube embed
* update regex,
* readability
Diffstat (limited to 'juick-www/src/main/js')
-rw-r--r-- | juick-www/src/main/js/killy/index.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/juick-www/src/main/js/killy/index.js b/juick-www/src/main/js/killy/index.js index 142d08d9..fe249fae 100644 --- a/juick-www/src/main/js/killy/index.js +++ b/juick-www/src/main/js/killy/index.js @@ -190,16 +190,17 @@ function getEmbeddableLinkTypes() { id: 'embed_youtube_videos', onByDefault: false, ctsDefault: false, - re: /^(?:https?:)?\/\/(?:www\.|m\.)?(?:youtu(?:(?:\.be\/|be\.com\/(?:v|embed)\/)([-\w]+)|be\.com\/watch)((?:(?:\?|&(?:amp;)?)(?:\w+=[-\.\w]*[-\w]))*)|youtube\.com\/playlist\?list=([-\w]*)(&(amp;)?[-\w\?=]*)?)/i, + re: /^(?:https?:)?\/\/(?:www\.|m\.|gaming\.)?(?:youtu(?:(?:\.be\/|be\.com\/(?:v|embed)\/)([-\w]+)|be\.com\/watch)((?:(?:\?|&(?:amp;)?)(?:\w+=[-\.\w]*[-\w]))*)|youtube\.com\/playlist\?list=([-\w]*)(&(amp;)?[-\w\?=]*)?)/i, makeNode: function(aNode, reResult) { let [url, v, args, plist] = reResult; let iframeUrl; if (plist !== undefined) { iframeUrl = '//www.youtube-nocookie.com/embed/videoseries?list=' + plist; } else { - args = args.replace(/^\?/, ''); - let arr = args.split('&').map(s => s.split('=')); - let pp = {}; arr.forEach(z => pp[z[0]] = z[1]); + let pp = {}; args.replace(/^\?/, '') + .split('&') + .map(s => s.split('=')) + .forEach(z => pp[z[0]] = z[1]); let embedArgs = { rel: '0' }; if (pp.t != undefined) { const tre = /^(?:(\d+)|(?:(\d+)h)?(?:(\d+)m)?(\d+)s|(?:(\d+)h)?(\d+)m|(\d+)h)$/i; @@ -210,10 +211,13 @@ function getEmbeddableLinkTypes() { embedArgs['list'] = pp.list; } v = v || pp.v; - iframeUrl = '//www.youtube-nocookie.com/embed/' + v + '?' + Object.keys(embedArgs).map(k => `${k}=${embedArgs[k]}`).join('&'); + let argsStr = Object.keys(embedArgs) + .map(k => `${k}=${embedArgs[k]}`) + .join('&'); + iframeUrl = `//www.youtube-nocookie.com/embed/${v}?${argsStr}`; } let iframe = makeIframe(iframeUrl, '100%', '360px'); - setTimeout(() => makeResizableToRatio(iframe, 9.0/16.0), 10); + setTimeout(() => makeResizableToRatio(iframe, 9.0 / 16.0), 10); return wrapIntoTag(iframe, 'div', 'youtube resizableV'); } }, @@ -226,7 +230,7 @@ function getEmbeddableLinkTypes() { re: /^(?:https?:)?\/\/(?:www\.)?(?:player\.)?vimeo\.com\/(?:video\/|album\/[\d]+\/video\/)?([\d]+)/i, makeNode: function(aNode, reResult) { let iframe = makeIframe('//player.vimeo.com/video/' + reResult[1], '100%', '360px'); - setTimeout(() => makeResizableToRatio(iframe, 9.0/16.0), 10); + setTimeout(() => makeResizableToRatio(iframe, 9.0 / 16.0), 10); return wrapIntoTag(iframe, 'div', 'vimeo resizableV'); } } |