# HG changeset patch # User ymh # Date 1505320250 -7200 # Node ID b2789b4cd389cbaafc09dac10d280cb95ae173d8 # Parent bc81800e587b057ab540077eeaf0aeb82ecd18a9 add video embed for dailymotion, youtube, vimeo diff -r bc81800e587b -r b2789b4cd389 client/templates/nodeeditor_video.html --- a/client/templates/nodeeditor_video.html Thu Jan 12 14:22:21 2017 +0100 +++ b/client/templates/nodeeditor_video.html Wed Sep 13 18:30:50 2017 +0200 @@ -1,3 +1,41 @@ +<% +function get_youtube_id(url) { + var regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/; + var match = url.match(regExp); + if (match && match[2].length == 11) { + return match[2]; + } else { + return false; + } +} + +function get_vimeo_id(url) { + var regExp = /https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/; + + var match = url.match(regExp); + + if (match){ + return match[2]; + } else { + return false; + } +} + +function get_dailymotion_id(url) { + var regExp = /^(?:(?:http|https):\/\/)?(?:www.)?(dailymotion\.com|dai\.ly)\/((video\/([^_]+))|(hub\/([^_]+)|([^\/_]+)))$/; + + var match = url.match(regExp); + + if (match) { + if(match[4] !== undefined) { + return match[4]; + } + return match[2]; + } + return false; +} + +%>

× <% if (options.show_node_tooltip_color) { %> @@ -11,9 +49,25 @@ <% if (node.uri) { %><% } %>

-<% if (node.uri && options.show_node_tooltip_uri) { %> - -<% } %> +<% if (node.uri && options.show_node_tooltip_uri) { + var video_id = false; + if(video_id = get_youtube_id(node.uri)) { %> + +

<%-renkan.translate("Link")%>

+ <% } + else if(video_id = get_vimeo_id(node.uri)) { %> + +

<%-renkan.translate("Link")%>

+ <% } + else if(video_id = get_dailymotion_id(node.uri)) { %> + +

<%-renkan.translate("Link")%>

+ <% } + else { %> + + <% } + } +%> <%-renkan.translate("Link to the node")%>