123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['./EmbedMedia', 'text!./YoutubeVideo.html'], function (EmbedMedia, Template) {
- // YouTube Url patterns
- // these formats are also used in the IT Tests. If modified, make sure to update them as well in the file:
- // dashboard-it -> tests/utilities/Media.js
- var siteFormat = /.*\.youtube\.com\/watch\?v=([A-Za-z0-9-_]+).*/;
- var shortFormat = /.*\/youtu\.be\/([A-Za-z0-9-_]+).*/;
- var embedFormat = /.*\.youtube\.com\/embed\/([A-Za-z0-9-_]+).*/;
- var FORMATS = [siteFormat, shortFormat, embedFormat];
- var getYoutubeId = function getYoutubeId(url) {
- var match = void 0;
- for (var i = 0; i < FORMATS.length; i++) {
- match = FORMATS[i].exec(url);
- if (match) {
- return match[1];
- }
- }
- return null;
- };
- var YoutubeVideoLoader = function () {
- function YoutubeVideoLoader(type) {
- _classCallCheck(this, YoutubeVideoLoader);
- this.type = type;
- }
- YoutubeVideoLoader.prototype.tryToLoad = function tryToLoad(url) {
- var youtubeId = getYoutubeId(url);
- return youtubeId && new EmbedMedia(url, this.type, Template, {
- youtubeId: youtubeId
- });
- };
- return YoutubeVideoLoader;
- }();
- return YoutubeVideoLoader;
- });
- //# sourceMappingURL=YoutubeVideoLoader.js.map
|