HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/Velosophe/carparkcannonball.cc/wwwroot/source/scripts/modules/modules.video.js
/*------------------------------------------------------------------------*/
/*  Rodesk video module
/*------------------------------------------------------------------------*/

var rodeskVideo = (function () {

    var settings;

    var defaults = {
        videoPlay:        '.js-video .c-video__play',
    };

    /**
     * Setup the module
     *
     */
    var _videoType = function( event ) {

        $videoId        = $( this ).attr( 'data-id' );
        $videoType      = $( this ).attr( 'data-type' );
        $videoWrapper   = $( this ).parent();

        if( $videoType === 'vimeo' ) {

            jQuery.ajax({
                url: 'https://vimeo.com/api/v2/video/' + $videoId + '.json',
                dataType: 'jsonp',
                type: 'GET',
                success: function( response ) {

                    $videoWrapper.html( '<iframe src="https://player.vimeo.com/video/'+$videoId+'?autoplay=1" width="685" height="386" frameborder="0" webkitAllowFullScreen mozallowfullscreen autoPlay allowFullScreen></iframe>' );
                    $videoWrapper.fitVids();
                }
            });

        } else if( $videoType === 'youtube' ) {

            jQuery.ajax({
                url: "https://www.googleapis.com/youtube/v3/videos?part=id,snippet&id=" + $videoId + "&key=AIzaSyAXBfQgG0HgqLQmJW97m0ru9AOUXaM5O0I",
                dataType: "jsonp",
                type: 'GET',
                success: function( response ) {

                    $videoWrapper.html('<iframe src="https://www.youtube.com/embed/'+$videoId+'?autoplay=1" width="685" height="386" frameborder="0" allowfullscreen webkitAllowFullScreen mozallowfullscreen autoPlay allowFullScreen></iframe>');
                    $videoWrapper.parent().fitVids();
                }
            });

        } else {
            return false;
        }

    };

    /**
     * Bind reveal events
     * Close the cookie bar on click of the close button
     *
     */
    var _bindEvents = function() {

        $( settings.videoPlay ).on( 'click', _videoType );

    };

    /**
     * Init module
    */
    var _init = function( options ) {

        // Setup settings.
        options = options || {};
        settings = $.extend({}, defaults, options);

        _bindEvents();

    };

    // Return public functions
    return {
        init: _init // Init this function
    };

})(jQuery); // Fully reference jQuery after this point.