<commit_before>(function(root) {
    navigator.getUserMedia = navigator.getUserMedia ||
                       navigator.webkitGetUserMedia ||
                       navigator.mozGetUserMedia;

    var Portal = function(peer, video, opts) {
        this._opts = extend({
            recallInterval: 10000,
            callOpts: {
                video: {
                    mandatory: {
                        minWidth: 1900,
                        minHeight: 1000
                    }
                },
                audio: false
            }
        }, opts);

        this._peer = peer;
        this._video = document.querySelector(video);

        this._localStream = null;
        this._getLocalStream();

        this._setupAutoAnswer();
    };

    Portal.prototype.call = function call(portalId) {
        var self = this;

        console.info('Call to', portalId);
        var call = this._peer.call(portalId, this._localStream);
        call.on('stream', function(stream) {
            self._video.setAttribute('src', URL.createObjectURL(stream));
        });

        this._setupRefresh(call);
    };

    Portal.prototype.open = function open(percent, opts) {
        this.setToPosition(100, opts);
    };

    Portal.prototype.close = function close(percent, opts) {
        this.setToPosition(0, opts);
    };

    Portal.prototype.setToPosition = function setToPosition(percent, opts) {
        var circle = document.querySelector(this._opts.selector);
        //
    };

    Portal.prototype._setupAutoAnswer = function _setupAutoAnswer() {
        var self = this;

        this._peer.on('call', function(call) {
            console.info('Incoming call');

            call.answer(self._localStream);

            call.on('stream', function(stream) {
                self._video.setAttribute('src', URL.createObjectURL(stream));
            });
        });
    };

    Portal.prototype._setupRefresh = function _setupRefresh(call) {
        var self = this;

        function refreshAfterInterval() {
            setTimeout(function() {
                window.location.reload();
            }, self._opts.recallInterval);
        }

        call.on('close', function() {
            refreshAfterInterval();
        });

        call.on('error', function(err) {
            refreshAfterInterval();
        });
    };

    Portal.prototype._getLocalStream = function _getLocalStream() {
        var self = this;

        navigator.getUserMedia(this._opts.callOpts, function(stream) {
            self._localStream = stream;
            self._opts.ready(stream);
            self._video.setAttribute('src', URL.createObjectURL(stream));
        }, function(err) {
            console.error('Failed to get local video stream', err);
            self._opts.error(err);
        });
    };

    // Utility functions

    // Copy all attributes from source object to destination object.
    // destination object is mutated.
    function extend(destination, source) {
        destination = destination || {};

        for (var attrName in source) {<commit_msg>Remove debugging which shows own video source<commit_after>(function(root) {
    navigator.getUserMedia = navigator.getUserMedia ||
                       navigator.webkitGetUserMedia ||
                       navigator.mozGetUserMedia;

    var Portal = function(peer, video, opts) {
        this._opts = extend({
            recallInterval: 10000,
            callOpts: {
                video: {
                    mandatory: {
                        minWidth: 1900,
                        minHeight: 1000
                    }
                },
                audio: false
            }
        }, opts);

        this._peer = peer;
        this._video = document.querySelector(video);

        this._localStream = null;
        this._getLocalStream();

        this._setupAutoAnswer();
    };

    Portal.prototype.call = function call(portalId) {
        var self = this;

        console.info('Call to', portalId);
        var call = this._peer.call(portalId, this._localStream);
        call.on('stream', function(stream) {
            self._video.setAttribute('src', URL.createObjectURL(stream));
        });

        this._setupRefresh(call);
    };

    Portal.prototype.open = function open(percent, opts) {
        this.setToPosition(100, opts);
    };

    Portal.prototype.close = function close(percent, opts) {
        this.setToPosition(0, opts);
    };

    Portal.prototype.setToPosition = function setToPosition(percent, opts) {
        var circle = document.querySelector(this._opts.selector);
        //
    };

    Portal.prototype._setupAutoAnswer = function _setupAutoAnswer() {
        var self = this;

        this._peer.on('call', function(call) {
            console.info('Incoming call');

            call.answer(self._localStream);

            call.on('stream', function(stream) {
                self._video.setAttribute('src', URL.createObjectURL(stream));
            });
        });
    };

    Portal.prototype._setupRefresh = function _setupRefresh(call) {
        var self = this;

        function refreshAfterInterval() {
            setTimeout(function() {
                window.location.reload();
            }, self._opts.recallInterval);
        }

        call.on('close', function() {
            refreshAfterInterval();
        });

        call.on('error', function(err) {
            refreshAfterInterval();
        });
    };

    Portal.prototype._getLocalStream = function _getLocalStream() {
        var self = this;

        navigator.getUserMedia(this._opts.callOpts, function(stream) {
            self._localStream = stream;
            self._opts.ready(stream);
        }, function(err) {
            console.error('Failed to get local video stream', err);
            self._opts.error(err);
        });
    };

    // Utility functions

    // Copy all attributes from source object to destination object.
    // destination object is mutated.
    function extend(destination, source) {
        destination = destination || {};

        for (var attrName in source) {
{'fraction_non_alphanumeric': 0.11465489041543997, 'fraction_numerical': 0.005561007523716062, 'mean_word_length': 1.8310185185185186, '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': '3662882', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1539, 'n_words': 300}