<commit_before>(function ( $ ) {

    var pluginName = "vimeoplaylist",
        defaults = {
            startFrom: 0,
            startTime: 0,
            videoList: [],
            volume : -1,
            onVideoFinish : function() {},
            onVideoStart: function() {},
        };

    function VimeoPlaylist ( element, options ) {
        this.element = element;
        this.settings = $.extend( {}, defaults, options );
        this._defaults = defaults;
        this._name = pluginName;
        this.init();
    }

    $.extend(VimeoPlaylist.prototype, {
        init: function () {
            var that = this;
            this._videos = [];
            this._firstPlay = true;
            var videoid = "";
            for(var i = 0 ; i < this.settings.videoList.length ; i++) {
                if(this.settings.videoList[i].hasOwnProperty("vimeoid")) {
                    videoid = this.settings.videoList[i].vimeoid;
                } else {
                    videoid = this.settings.videoList[i];
                }
                this._videos.push("//player.vimeo.com/video/" + videoid + "?api=1&player_id=" + that.element.id);
            }
            this._currentVideo = this.settings.startFrom;
            if (this._currentVideo >= this._videos.length) {
                this._currentVideo = this._videos.length - 1;
            }
            this._iframe = $(this.element);
            this._iframe.attr("src", this._videos[this._currentVideo % this._videos.length]);
            this._player = $f($(this.element)[0]);

            this._player.addEvent("ready", function() {
                that._player.addEvent("pause", onPause);
                that._player.addEvent("playProgress", onPlayProgress);
                that._player.addEvent("finish", onFinish);
                if (that.settings.volume !== -1) {
                    that._player.api("setVolume", that.settings.volume);
                }
                if (isOnMobile()) {
                    //TODO stuff in the future
                } else {
                    that._player.api("play");
                    if (that._firstPlay) {
                        that._player.api("seekTo", that.settings.startTime);
                    }
                    that.settings.onVideoStart.call(that.element, that._currentVideo % that._videos.length);
                }
            });

            function isOnMobile() {
                return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
            }

            function onPause() {
            }

            function onFinish() {
                that.settings.onVideoFinish.call(that.element, that._currentVideo % that._videos.length);
                that._currentVideo++;
                that._iframe.attr("src", that._videos[that._currentVideo % that._videos.length]);
                that._firstPlay = false;
            }

            function onPlayProgress() {
                if (isOnMobile()) {
                    if (that._firstPlay) {
                        that.settings.onVideoStart.call(that.element, that._currentVideo % that._videos.length);
                        that._player.api("seekTo", that.settings.startTime);
                        that._firstPlay = false;
                    }
                }
            }

        },

        startVideo: function (index) {
            this.settings.onVideoFinish.call(this.element, this._currentVideo % this._videos.length);
            this._currentVideo = index;
            this._iframe.attr("src", this._videos[index % this._videos.length]);
            this._firstPlay = false;
        },

        getPlayer: function () {
            return this._player;
        },

        getVolume: function () {
            return this.settings.volume;
        }
    });

    $.fn[ pluginName ] = function ( options ) {
        this.each(function() {
            if (!$.data(this, "plugin_" + pluginName)) {
                $.data(this, "plugin_" + pluginName, new VimeoPlaylist(this, options));
            }
        });
        return this;
    };
}( jQuery ));<commit_msg>Add videostart and videoend event triggers<commit_after>(function ( $ ) {

    var pluginName = "vimeoplaylist",
        defaults = {
            startFrom: 0,
            startTime: 0,
            videoList: [],
            volume : -1,
            onVideoFinish : function() {},
            onVideoStart: function() {},
        };

    function VimeoPlaylist ( element, options ) {
        this.element = element;
        this.settings = $.extend( {}, defaults, options );
        this._defaults = defaults;
        this._name = pluginName;
        this.init();
    }

    $.extend(VimeoPlaylist.prototype, {
        init: function () {
            var that = this;
            this._videos = [];
            this._firstPlay = true;
            var videoid = "";
            for(var i = 0 ; i < this.settings.videoList.length ; i++) {
                if(this.settings.videoList[i].hasOwnProperty("vimeoid")) {
                    videoid = this.settings.videoList[i].vimeoid;
                } else {
                    videoid = this.settings.videoList[i];
                }
                this._videos.push("//player.vimeo.com/video/" + videoid + "?api=1&player_id=" + that.element.id);
            }
            this._currentVideo = this.settings.startFrom;
            if (this._currentVideo >= this._videos.length) {
                this._currentVideo = this._videos.length - 1;
            }
            this._iframe = $(this.element);
            this._iframe.attr("src", this._videos[this._currentVideo % this._videos.length]);
            this._player = $f($(this.element)[0]);

            this._player.addEvent("ready", function() {
                that._player.addEvent("pause", onPause);
                that._player.addEvent("playProgress", onPlayProgress);
                that._player.addEvent("finish", onFinish);
                if (that.settings.volume !== -1) {
                    that._player.api("setVolume", that.settings.volume);
                }
                if (isOnMobile()) {
                    //TODO stuff in the future
                } else {
                    that._player.api("play");
                    if (that._firstPlay) {
                        that._player.api("seekTo", that.settings.startTime);
                    }
                    $(that.element).trigger("videostart", that._currentVideo % that._videos.length);
                    that.settings.onVideoStart.call(that.element, that._currentVideo % that._videos.length);
                }
            });

            function isOnMobile() {
                return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
            }

            function onPause() {
            }

            function onFinish() {
                $(that.element).trigger("videoend", that._currentVideo % that._videos.length);
                that.settings.onVideoFinish.call(that.element, that._currentVideo % that._videos.length);
                that._currentVideo++;
                that._iframe.attr("src", that._videos[that._currentVideo % that._videos.length]);
                that._firstPlay = false;
            }

            function onPlayProgress() {
                if (isOnMobile()) {
                    if (that._firstPlay) {
                        $(that.element).trigger("videostart", that._currentVideo % that._videos.length);
                        that.settings.onVideoStart.call(that.element, that._currentVideo % that._videos.length);
                        that._player.api("seekTo", that.settings.startTime);
                        that._firstPlay = false;
                    }
                }
            }

        },

        startVideo: function (index) {
            $(this.element).trigger("videoend", this._currentVideo % this._videos.length);
            this.settings.onVideoFinish.call(this.element, this._currentVideo % this._videos.length);
            this._currentVideo = index;
            this._iframe.attr("src", this._videos[index % this._videos.length]);
            this._firstPlay = false;
        },

        getPlayer: function () {
            return this._player;
        },

        getVolume: function () {
            return this.settings.volume;
        }
    });

    $.fn[ pluginName ] = function ( options ) {
        this.each(function() {
            if (!$.data(this, "plugin_" + pluginName)) {
                $.data(this, "plugin_" + pluginName, new VimeoPlaylist(this, options));
            }
        });
        return this;
    };
}( jQuery ));
{'fraction_non_alphanumeric': 0.1266551525618883, 'fraction_numerical': 0.0018422567645365573, 'mean_word_length': 1.5162224797219004, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5601293', 'n_tokens_mistral': 2391, 'n_tokens_neox': 2232, 'n_words': 361}