add facebook as video provider for the video node type
authorymh <ymh.work@gmail.com>
Fri, 15 Sep 2017 14:04:42 +0200
changeset 657 50f5e8d2c839
parent 656 95e2c6d21b5f
child 658 cac26275af31
add facebook as video provider for the video node type
client/js/i18n.js
client/templates/nodeeditor_video.html
--- a/client/js/i18n.js	Wed Sep 13 18:31:33 2017 +0200
+++ b/client/js/i18n.js	Fri Sep 15 14:04:42 2017 +0200
@@ -101,5 +101,6 @@
         "Fullscreen not supported by your browser": "Le plein écran n'est pas supporté par votre navigateur",
         "Title size:": "Taille :",
         "Title color:": "Couleur :",
+        "Video link": "Lien vidéo"
     }
 };
--- a/client/templates/nodeeditor_video.html	Wed Sep 13 18:31:33 2017 +0200
+++ b/client/templates/nodeeditor_video.html	Fri Sep 15 14:04:42 2017 +0200
@@ -35,6 +35,17 @@
     return false;
 }
 
+function get_facebook_id(url) {
+    var regExp = /^https?:\/\/www\.facebook\.com\/(?:video\.php\?v=\d+|.*?\/videos\/\d+)\/?$/;
+    
+    var match = url.match(regExp);
+
+    if (match) {
+        return encodeURIComponent(url);
+    }
+    return false;
+}
+
 %>
 <h2>
     <span class="Rk-CloseX">&times;</span>
@@ -63,6 +74,10 @@
         <iframe frameborder="0" width="255" height="143" src="https://www.dailymotion.com/embed/video/<%=video_id%>?autoPlay=0" allowfullscreen=""></iframe>
         <p><a href="<%-node.uri%>" target="_blank"><%-renkan.translate("Link")%></a></p>
     <%  }
+    else if(video_id = get_facebook_id(node.uri)) { %>
+        <iframe src="https://www.facebook.com/plugins/video.php?href=<%=video_id%>&width=255&show_text=false&height=143&appId" width="255" height="143" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allowFullScreen="true"></iframe>
+        <p><a href="<%-node.uri%>" target="_blank"><%-renkan.translate("Video link")%></a></p>
+    <%  }
     else { %> 
         <video width="320" height="240" controls>
             <source src="<%-node.uri%>" type="video/mp4">