client/templates/nodeeditor_video.html
changeset 654 b2789b4cd389
parent 647 eaaa1efce396
child 657 50f5e8d2c839
equal deleted inserted replaced
653:bc81800e587b 654:b2789b4cd389
       
     1 <%
       
     2 function get_youtube_id(url) {
       
     3     var regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
       
     4     var match = url.match(regExp);
       
     5     if (match && match[2].length == 11) {
       
     6         return match[2];
       
     7     } else {
       
     8         return false;
       
     9     }
       
    10 }
       
    11 
       
    12 function get_vimeo_id(url) {
       
    13     var regExp = /https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;
       
    14     
       
    15     var match = url.match(regExp);
       
    16     
       
    17     if (match){
       
    18         return match[2];
       
    19     } else {
       
    20         return false;
       
    21     }
       
    22 }
       
    23 
       
    24 function get_dailymotion_id(url) {
       
    25     var regExp = /^(?:(?:http|https):\/\/)?(?:www.)?(dailymotion\.com|dai\.ly)\/((video\/([^_]+))|(hub\/([^_]+)|([^\/_]+)))$/;
       
    26 
       
    27     var match = url.match(regExp);
       
    28 
       
    29     if (match) {
       
    30         if(match[4] !== undefined) {
       
    31             return match[4];
       
    32         }
       
    33         return match[2];
       
    34     }
       
    35     return false;
       
    36 }
       
    37 
       
    38 %>
     1 <h2>
    39 <h2>
     2     <span class="Rk-CloseX">&times;</span>
    40     <span class="Rk-CloseX">&times;</span>
     3     <% if (options.show_node_tooltip_color) { %>
    41     <% if (options.show_node_tooltip_color) { %>
     4         <span class="Rk-UserColor" style="background: <%-node.color%>;"></span>
    42         <span class="Rk-UserColor" style="background: <%-node.color%>;"></span>
     5     <% } %>
    43     <% } %>
     9         <% } %>
    47         <% } %>
    10         <%=node.title%>
    48         <%=node.title%>
    11         <% if (node.uri) { %></a><% } %>
    49         <% if (node.uri) { %></a><% } %>
    12     </span>
    50     </span>
    13 </h2>
    51 </h2>
    14 <% if (node.uri && options.show_node_tooltip_uri) { %>
    52 <% if (node.uri && options.show_node_tooltip_uri) {
    15      <video width="320" height="240" controls>
    53     var video_id = false;
    16         <source src="<%-node.uri%>" type="video/mp4">
    54     if(video_id = get_youtube_id(node.uri)) { %>
    17      </video> 
    55         <iframe width="255" height="143" src="https://www.youtube.com/embed/<%=video_id%>" frameborder="0"></iframe>
    18 <% } %>
    56         <p><a href="<%-node.uri%>" target="_blank"><%-renkan.translate("Link")%></a></p>
       
    57     <%  }
       
    58     else if(video_id = get_vimeo_id(node.uri)) { %>
       
    59         <iframe src="https://player.vimeo.com/video/<%=video_id%>" width="255" height="143" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
       
    60         <p><a href="<%-node.uri%>" target="_blank"><%-renkan.translate("Link")%></a></p>
       
    61     <%  }
       
    62     else if(video_id = get_dailymotion_id(node.uri)) { %>
       
    63         <iframe frameborder="0" width="255" height="143" src="https://www.dailymotion.com/embed/video/<%=video_id%>?autoPlay=0" allowfullscreen=""></iframe>
       
    64         <p><a href="<%-node.uri%>" target="_blank"><%-renkan.translate("Link")%></a></p>
       
    65     <%  }
       
    66     else { %> 
       
    67         <video width="320" height="240" controls>
       
    68             <source src="<%-node.uri%>" type="video/mp4">
       
    69         </video>
       
    70     <%  }
       
    71     }
       
    72 %>
    19     <a href="#?idnode=<%-node._id%>"><%-renkan.translate("Link to the node")%></a>
    73     <a href="#?idnode=<%-node._id%>"><%-renkan.translate("Link to the node")%></a>