<commit_before>/*jslint browser: true, node: true */
/*global window */

/*!

   Thumbnail image plugin for Flowplayer HTML5

   Copyright (c) 2015-2017, <NAME>

   Released under the MIT License:
   http://www.opensource.org/licenses/mit-license.php

   requires:
   - Flowplayer HTML5 version 6.x or greater
   revision: $GIT_ID$

*/
(function () {
    "use strict";
    var extension = function (flowplayer) {

        flowplayer(function (api, root) {
            var common = flowplayer.common,
                bean = flowplayer.bean,
                extend = flowplayer.extend,
                support = flowplayer.support,
                timeline = common.find('.fp-timeline', root)[0],
                timelineTooltip = common.find('.fp-time' + (flowplayer.version.indexOf('6.') === 0
                    ? 'line-tooltip'
                    : 'stamp'), root)[0];

            if (support.touch || !support.inlineVideo) {
                return;
            }

            api.on('ready', function (_ev, a, video) {
                // cleanup
                bean.off(root, '.thumbnails');
                common.css(timelineTooltip, {
                    width: '',
                    height: '',
                    'background-image': '',
                    'background-repeat': '',
                    'background-size': '',
                    'background-position': '',
                    'border': '',
                    'text-shadow': ''
                });

                var c = extend({}, a.conf.thumbnails, video.thumbnails),
                    template = c.template,
                    sprite = template.indexOf('{time}') < 0;

                if (!template || (sprite && (!c.rows || !c.columns || !c.width || !c.height))) {
                    return;
                }

                var height = sprite
                        ? c.height / c.rows
                        : c.height || 80,
                    interval = c.interval || 1,
                    time_format = c.time_format || function (t) {
                        return t;
                    },
                    startIndex = typeof c.startIndex === 'number'
                        ? c.startIndex
                        : 1,
                    thumb = c.lazyload !== false
                        ? new Image()
                        : null,
                    engine = common.find('.fp-engine', root)[0],
                    ratio = (video.height || common.height(engine)) / (video.width || common.width(engine)),
                    preloadImages = function (max, start) {
                        max = Math.floor(max / interval + start);
                        function load() {
                            if (start > max) {
                                return;
                            }
                            var img = new Image();
                            img.src = template.replace('{time}', time_format(start));
                            img.onload = function () {
                                start += 1;
                                load();
                            };
                        }
                        load();
                    };

                if (c.preload) {
                    preloadImages(video.duration, startIndex);
                }

                bean.on(root, 'mousemove.thumbnails', '.fp-timeline', function (ev) {
                    var x = ev.pageX || ev.clientX,
                        delta = x - common.offset(timeline).left,
                        percentage = delta / common.width(timeline),
                        seconds = Math.round(percentage * api.video.duration),
                        url,
                        displayThumb = function () {
                            var css = {
                                'background-image': "url('" + url + "')",
                                'background-repeat': 'no-repeat',
                                border: '1px solid #333',
                                'text-shadow': '1px 1px #000'
                            };
                            if (sprite) {
                                var mod_width = c.width / c.columns,
                                    left = Math.floor(seconds % c.columns) * -mod_width,
                                    top = Math.floor(seconds / c.columns) * -height;
                                extend(css, {
                                    'background-position': left + 'px ' + top + 'px',
                                    height: height + 'px',
                                    width: mod_width + 'px'
                                });
                            } else {
                                extend(css, {
                                    width: (height / ratio) + 'px',
                                    height: height + 'px',
                                    'background-size': 'cover',
                                    'background-position': 'center'
                                });
                            }
                            common.css(timelineTooltip, css);
                        };

                    // 2nd condition safeguards at out of range retrieval attempts
                    if (seconds < 0 || seconds > Math.round(api.video.duration)) {
                        return;
                    }
                    // enables greater interval than one second between thumbnails
                    seconds = Math.floor(seconds / interval);

                    // {time} template expected to start at 1, video time/first frame starts at 0
                    url = template.replace('{time}', time_format(seconds + startIndex));

                    if (c.lazyload !== false) {
                        thumb.src = url;
                        bean.on(thumb, 'load', displayThumb);
                    } else {
                        displayThumb();
                    }
                });
            });

        });
    };

    if (typeof module === 'object' && module.exports) {
        module.exports = extension;
    } else if (window.flowplayer) {
        extension(window.flowplayer);
    }
}());
<commit_msg>Calculate thumb dimensions only once on ready<commit_after>/*jslint browser: true, node: true */
/*global window */

/*!

   Thumbnail image plugin for Flowplayer HTML5

   Copyright (c) 2015-2017, Flowplayer Drive Oy

   Released under the MIT License:
   http://www.opensource.org/licenses/mit-license.php

   requires:
   - Flowplayer HTML5 version 6.x or greater
   revision: $GIT_ID$

*/
(function () {
    "use strict";
    var extension = function (flowplayer) {

        flowplayer(function (api, root) {
            var common = flowplayer.common,
                bean = flowplayer.bean,
                extend = flowplayer.extend,
                support = flowplayer.support,
                timeline = common.find('.fp-timeline', root)[0],
                timelineTooltip = common.find('.fp-time' + (flowplayer.version.indexOf('6.') === 0
                    ? 'line-tooltip'
                    : 'stamp'), root)[0];

            if (support.touch || !support.inlineVideo) {
                return;
            }

            api.on('ready', function (_ev, a, video) {
                // cleanup
                bean.off(root, '.thumbnails');
                common.css(timelineTooltip, {
                    width: '',
                    height: '',
                    'background-image': '',
                    'background-repeat': '',
                    'background-size': '',
                    'background-position': '',
                    'border': '',
                    'text-shadow': ''
                });

                var c = extend({}, a.conf.thumbnails, video.thumbnails),
                    template = c.template,
                    sprite = template.indexOf('{time}') < 0;

                if (!template || (sprite && (!c.rows || !c.columns || !c.width || !c.height))) {
                    return;
                }

                var height = sprite
                        ? c.height / c.rows
                        : c.height || 80,
                    engine = common.find('.fp-engine', root)[0],
                    ratio = (video.height || common.height(engine)) / (video.width || common.width(engine)),
                    width = sprite
                        ? c.width / c.columns
                        : height / ratio,
                    interval = c.interval || 1,
                    time_format = c.time_format || function (t) {
                        return t;
                    },
                    startIndex = typeof c.startIndex === 'number'
                        ? c.startIndex
                        : 1,
                    thumb = c.lazyload !== false
                        ? new Image()
                        : null,
                    preloadImages = function (max, start) {
                        max = Math.floor(max / interval + start);
                        function load() {
                            if (start > max) {
                                return;
                            }
                            var img = new Image();
                            img.src = template.replace('{time}', time_format(start));
                            img.onload = function () {
                                start += 1;
                                load();
                            };
                        }
                        load();
                    };

                if (c.preload) {
                    preloadImages(video.duration, startIndex);
                }

                bean.on(root, 'mousemove.thumbnails', '.fp-timeline', function (ev) {
                    var x = ev.pageX || ev.clientX,
                        delta = x - common.offset(timeline).left,
                        percentage = delta / common.width(timeline),
                        seconds = Math.round(percentage * api.video.duration),
                        url,
                        displayThumb = function () {
                            var css = {
                                width: width + 'px',
                                height: height + 'px',
                                'background-image': "url('" + url + "')",
                                'background-repeat': 'no-repeat',
                                border: '1px solid #333',
                                'text-shadow': '1px 1px #000'
                            };
                            if (sprite) {
                                var left = Math.floor(seconds % c.columns) * -width,
                                    top = Math.floor(seconds / c.columns) * -height;
                                css['background-position'] = left + 'px ' + top + 'px';
                            } else {
                                extend(css, {
                                    'background-size': 'cover',
                                    'background-position': 'center'
                                });
                            }
                            common.css(timelineTooltip, css);
                        };

                    // 2nd condition safeguards at out of range retrieval attempts
                    if (seconds < 0 || seconds > Math.round(api.video.duration)) {
                        return;
                    }
                    // enables greater interval than one second between thumbnails
                    seconds = Math.floor(seconds / interval);

                    // {time} template expected to start at 1, video time/first frame starts at 0
                    url = template.replace('{time}', time_format(seconds + startIndex));

                    if (c.lazyload !== false) {
                        thumb.src = url;
                        bean.on(thumb, 'load', displayThumb);
                    } else {
                        displayThumb();
                    }
                });
            });

        });
    };

    if (typeof module === 'object' && module.exports) {
        module.exports = extension;
    } else if (window.flowplayer) {
        extension(window.flowplayer);
    }
}());

{'fraction_non_alphanumeric': 0.11007751937984496, 'fraction_numerical': 0.005711954304365565, 'mean_word_length': 0.9045843045843046, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '481435', 'n_tokens_mistral': 2944, 'n_tokens_neox': 2685, 'n_words': 619}