<commit_before>{% extends "player/base.html" %}

{% block title %}
{{ block.super }}
{% endblock %}

{% block head %}
{{ block.super }}
{% endblock %}

{% block jquery %}
{{ block.super }}
        var timer = null;
        var url = null;
        var timer = null;

        function parse_url(url) {
            var code = url;
            if(code[code.length-1] == '/') {
                code = code.substring(0, code.length-1);
            }
            code = code.substring(code.lastIndexOf('/')+1);
            return code;
        }
        
        function clear_timer() {
            if(timer != null) {
                window.clearTimeout(timer);
            }
            timer = null;
        }

        function wait() {
            clear_timer();
            timer = setTimeout($.proxy(next, this), 1000);
        }

        function fetch_success(data) {
            if(data['state'] == 0) {
                console.log("No further videos, waiting ...");
                wait();
            } else {
                url = data['url'];
                console.log("Got video "+ url);
                $('body').tubeplayer('play', parse_url(url));
            }
        }
        
        function fetch_failure() {
            console.log("FETCH FAILURE!");
            wait();
        }

        function next() {
            console.log("Fetching next!");
            $.ajax({ 
                url: '{% url 'player:next' %}', 
                dataType: 'json', 
                success: $.proxy(fetch_success, this),
                timeout: 5000,
                type: 'GET',
                error: $.proxy(fetch_failure, this)
            });
        }

        function on_resize() {
            $('body').tubeplayer("size", {
                width: $(window).width(), 
                height: $(window).height()
            });
        }

        function init() {
            $(window).resize(on_resize);
            $('body').tubeplayer({
                width: $(window).width(),
                height: $(window).height(),
                allowFullScreen: "false",
                initialVideo: "5Glh282lTrg",
                preferredQuality: "hd720",
                iframed: true,
                autoplay: false,
                onPlayerEnded: $.proxy(function() {
                    console.log("Playback ended, loading next.");
                    next();
                }, this),
                onErrorNotEmbeddable: $.proxy(function() {
                    console.log("Error: Not embeddable!");
                    next();
                }, this),
                onErrorNotFound: $.proxy(function() {
                    console.log("Error: Not found!");
                    next();
                }, this),
                onErrorInvalidParameter: $.proxy(function() {
                    console.log("Error: Invalid parameter!");
                    next();
                }, this),
            });
            wait();
        }
        
        init();
{% endblock %}

{% block content %}
{{ block.super }}
{% endblock %}<commit_msg>Set default video when there is nothing else to play<commit_after>{% extends "player/base.html" %}

{% block title %}
{{ block.super }}
{% endblock %}

{% block head %}
{{ block.super }}
{% endblock %}

{% block jquery %}
{{ block.super }}
        var timer = null;
        var url = null;
        var timer = null;
        var default_video = "5Glh282lTrg";

        function parse_url(url) {
            var code = url;
            if(code[code.length-1] == '/') {
                code = code.substring(0, code.length-1);
            }
            code = code.substring(code.lastIndexOf('/')+1);
            return code;
        }
        
        function clear_timer() {
            if(timer != null) {
                window.clearTimeout(timer);
            }
            timer = null;
        }

        function wait() {
            clear_timer();
            timer = setTimeout($.proxy(next, this), 1000);
        }

        function fetch_success(data) {
            if(data['state'] == 0) {
                console.log("No further videos, waiting ...");
                $('body').tubeplayer('play', default_video);
                wait();
            } else {
                url = data['url'];
                console.log("Got video "+ url);
                $('body').tubeplayer('play', parse_url(url));
            }
        }
        
        function fetch_failure() {
            console.log("FETCH FAILURE!");
            $('body').tubeplayer('play', default_video);
            wait();
        }

        function next() {
            console.log("Fetching next!");
            $.ajax({ 
                url: '{% url 'player:next' %}', 
                dataType: 'json', 
                success: $.proxy(fetch_success, this),
                timeout: 5000,
                type: 'GET',
                error: $.proxy(fetch_failure, this)
            });
        }

        function on_resize() {
            $('body').tubeplayer("size", {
                width: $(window).width(), 
                height: $(window).height()
            });
        }

        function init() {
            $(window).resize(on_resize);
            $('body').tubeplayer({
                width: $(window).width(),
                height: $(window).height(),
                allowFullScreen: "false",
                initialVideo: default_video,
                preferredQuality: "hd720",
                iframed: true,
                autoplay: false,
                onPlayerEnded: $.proxy(function() {
                    console.log("Playback ended, loading next.");
                    next();
                }, this),
                onErrorNotEmbeddable: $.proxy(function() {
                    console.log("Error: Not embeddable!");
                    next();
                }, this),
                onErrorNotFound: $.proxy(function() {
                    console.log("Error: Not found!");
                    next();
                }, this),
                onErrorInvalidParameter: $.proxy(function() {
                    console.log("Error: Invalid parameter!");
                    next();
                }, this),
            });
            wait();
        }
        
        init();
{% endblock %}

{% block content %}
{{ block.super }}
{% endblock %}
{'fraction_non_alphanumeric': 0.144251968503937, 'fraction_numerical': 0.006299212598425197, 'mean_word_length': 1.219077568134172, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2128962', 'n_tokens_mistral': 1722, 'n_tokens_neox': 1548, 'n_words': 322}