{"version":3,"sources":["webpack:///src/assets/js/youtube-iframe-faster.js"],"names":[],"mappings":"AAAA;AACA,wDAAwD;AACxD;AACA;AACA;AACA,0CAA0C,UAAU;AACpD,YAAY;AACZ;AACA,gDAAgD,WAAW;AAC3D;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA,2CAA2C;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;AACH,EAAE;AACF;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,E","file":"scripts.js","sourcesContent":["// youtube-iframe-faster.js v1\r\nfunction youtubeIframeFaster(youtubeID, userOptions = {}, callback) {\r\n\tif (typeof youtubeID !== 'string'){\r\n\t\treturn console.error('The youtubeID argument is required and must be of the type string.');\r\n\t};\r\n\tlet element = document.querySelector(`#${youtubeID}`),\r\n\toptions = { // everyone is boolean\r\n\t\tautoplay: false,\r\n\t\tautoTitle: true,\t// iframe attribute title=\"${videoTitle}\"\r\n\t\tloop: false,\r\n\t\tmute: false,\r\n\t\tremoveSizes: true\t// remove height and width attributes\r\n\t};\r\n\tif (element && element.tagName !== 'IFRAME') {\r\n\t\tfor (key in userOptions) { // extend\r\n\t\t\toptions[key] = userOptions[key];\r\n\t\t};\r\n\t\tif (!document.querySelector('script[src*=\"youtube.com/iframe_api\"]')) {\r\n\t\t\tlet script = document.createElement('script'),\r\n\t\t\tprotocol = window.location.protocol;\r\n\t\t\tif(protocol.substring(0, 4) !== 'http'){ // only accepts http and https\r\n\t\t\t\tprotocol = 'https:';\r\n\t\t\t};\r\n\t\t\tscript.setAttribute('src', protocol + '//www.youtube.com/player_api');\r\n\t\t\tlet firstElement = document.querySelector('script') || document.querySelector('head');\r\n\t\t\tif(firstElement.tagName === 'SCRIPT'){\r\n\t\t\t\tfirstElement.parentNode.insertBefore(script, firstElement);\r\n\t\t\t}else{\r\n\t\t\t\tfirstElement.append(script);\r\n\t\t\t};\r\n\t\t};\r\n\t\tlet waitYT = setInterval(() => {\r\n\t\t\tif (window.YT && window.YT.loaded === 1) {\r\n\t\t\t\tclearInterval(waitYT);\r\n\t\t\t\tlet player = new YT.Player(youtubeID, {\r\n\t\t\t\t\tvideoId: youtubeID,\r\n\t\t\t\t\tevents: {\r\n\t\t\t\t\t\tonReady: function(event){\r\n\t\t\t\t\t\t\t// let title = event.target.getVideoData().title;\r\n\t\t\t\t\t\t\t// element = event.target.f; // updates the element reference\r\n\t\t\t\t\t\t\t// if(options.removeSizes == true){\r\n\t\t\t\t\t\t\t// \telement.removeAttribute('height');\r\n\t\t\t\t\t\t\t// \telement.removeAttribute('width');\r\n\t\t\t\t\t\t\t// };\r\n\t\t\t\t\t\t\t// if(options.autoTitle){\r\n\t\t\t\t\t\t\t// \telement.setAttribute('title', title);\r\n\t\t\t\t\t\t\t// };\r\n\t\t\t\t\t\t\t// if (options.mute == true) {\r\n\t\t\t\t\t\t\t// \tplayer.mute();\r\n\t\t\t\t\t\t\t// };\r\n\t\t\t\t\t\t\t// if (options.autoplay == true) {\r\n\t\t\t\t\t\t\t// \tplayer.playVideo();\r\n\t\t\t\t\t\t\t// };\r\n\t\t\t\t\t\t\t// if(callback){\r\n\t\t\t\t\t\t\t// \tcallback({\r\n\t\t\t\t\t\t\t// \t\telement,\r\n\t\t\t\t\t\t\t// \t\toptions,\r\n\t\t\t\t\t\t\t// \t\tplayer,\r\n\t\t\t\t\t\t\t// \t\ttitle,\r\n\t\t\t\t\t\t\t// \t\tyoutubeID\r\n\t\t\t\t\t\t\t// \t});\r\n\t\t\t\t\t\t\t// };\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t\tonStateChange: function(event){\r\n\t\t\t\t\t\t\tif (options.loop == true) {\r\n\t\t\t\t\t\t\t\tif (player.getCurrentTime() === player.getDuration()) {\r\n\t\t\t\t\t\t\t\t\tplayer.seekTo(0);\r\n\t\t\t\t\t\t\t\t\tplayer.playVideo();\r\n\t\t\t\t\t\t\t\t};\r\n\t\t\t\t\t\t\t};\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t};\r\n\t\t}, 50);\r\n\t}else{\r\n\t\tif(element){\r\n\t\t\tconsole.error('The element cannot be an iframe');\r\n\t\t}else{\r\n\t\t\tconsole.error('Element not found');\r\n\t\t};\r\n\t};\r\n};"],"sourceRoot":""}