Fetch youtube videoid from url

This commit is contained in:
Hadi Nategh 2021-02-25 11:19:26 +01:00
parent 776613b961
commit 2d4b0b8259
2 changed files with 6 additions and 3 deletions

View File

@ -24,7 +24,6 @@ var __extends = (this && this.__extends) || (function () {
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_video = void 0;
/*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js;
et2_core_interfaces;
@ -135,7 +134,7 @@ var et2_video = /** @class */ (function (_super) {
'iv_load_policy': 0,
'cc_load_policy': 0
},
videoId: _value.split('v=')[1],
videoId: _value.match(et2_video.youtubeRegexp)[4],
events: {
'onReady': jQuery.proxy(self._onReady, self),
'onStateChange': jQuery.proxy(self._onStateChangeYoutube, self)
@ -417,6 +416,7 @@ var et2_video = /** @class */ (function (_super) {
* @private
*/
et2_video.youtubePrefixId = "frame-";
et2_video.youtubeRegexp = new RegExp(/^https:\/\/((www\.|m\.)?youtube(-nocookie)?\.com|youtu\.be)\/.*(?:\/|%3D|v=|vi=)([0-9A-z-_]{11})(?:[%#?&]|$)/m);
return et2_video;
}(et2_core_baseWidget_1.et2_baseWidget));
exports.et2_video = et2_video;

View File

@ -136,6 +136,9 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode
* @private
*/
private static youtubePrefixId : string = "frame-";
private static youtubeRegexp: RegExp = new RegExp(/^https:\/\/((www\.|m\.)?youtube(-nocookie)?\.com|youtu\.be)\/.*(?:\/|%3D|v=|vi=)([0-9A-z-_]{11})(?:[%#?&]|$)/m);
constructor(_parent, _attrs? : WidgetConfig, _child? : object)
{
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_video._attributes, _child || {}));
@ -219,7 +222,7 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode
'iv_load_policy': 0,
'cc_load_policy': 0
},
videoId: _value.split('v=')[1], //TODO get youtube video id
videoId: _value.match(et2_video.youtubeRegexp)[4],
events: {
'onReady': jQuery.proxy(self._onReady, self),
'onStateChange': jQuery.proxy(self._onStateChangeYoutube, self)