<commit_before>/* global APP, $, interfaceConfig, JitsiMeetJS  */
const logger = require("jitsi-meet-logger").getLogger(__filename);

import {
    getPinnedParticipant,
    pinParticipant
} from '../../../react/features/base/participants';

import Filmstrip from "./Filmstrip";
import UIEvents from "../../../service/UI/UIEvents";
import UIUtil from "../util/UIUtil";

import RemoteVideo from "./RemoteVideo";
import LargeVideoManager  from "./LargeVideoManager";
import {VIDEO_CONTAINER_TYPE} from "./VideoContainer";
import LocalVideo from "./LocalVideo";

const ParticipantConnectionStatus
    = JitsiMeetJS.constants.participantConnectionStatus;

var remoteVideos = {};
var localVideoThumbnail = null;

var currentDominantSpeaker = null;

var eventEmitter = null;

/**
 * flipX state of the localVideo
 */
let localFlipX = null;

/**
 * On contact list item clicked.
 */
function onContactClicked (id) {
    if (APP.conference.isLocalId(id)) {
        $("#localVideoContainer").click();
        return;
    }

    let remoteVideo = remoteVideos[id];
    if (remoteVideo && remoteVideo.hasVideo()) {
        // It is not always the case that a videoThumb exists (if there is
        // no actual video).
        if (remoteVideo.hasVideoStarted()) {
            // We have a video src, great! Let's update the large video
            // now.
            VideoLayout.handleVideoThumbClicked(id);
        } else {

            // If we don't have a video src for jid, there's absolutely
            // no point in calling handleVideoThumbClicked; Quite
            // simply, it won't work because it needs an src to attach
            // to the large video.
            //
            // Instead, we trigger the pinned endpoint changed event to
            // let the bridge adjust its lastN set for myjid and store
            // the pinned user in the lastNPickupId variable to be
            // picked up later by the lastN changed event handler.
            this.pinParticipant(remoteVideo.id);
        }
    }
}

/**
 * Handler for local flip X changed event.
 * @param {Object} val
 */
function onLocalFlipXChanged (val) {
    localFlipX = val;
    if(largeVideo) {
        largeVideo.onLocalFlipXChange(val);
    }
}

/**
 * Returns the corresponding resource id to the given peer container
 * DOM element.
 *
 * @return the corresponding resource id to the given peer container
 * DOM element
 */
function getPeerContainerResourceId (containerElement) {
    if (localVideoThumbnail.container === containerElement) {
        return localVideoThumbnail.id;
    }

    let i = containerElement.id.indexOf('participant_');

    if (i >= 0) {
        return containerElement.id.substring(i + 12);
    }
}

let largeVideo;

var VideoLayout = {
    init (emitter) {
        eventEmitter = emitter;

        // Unregister listeners in case of reinitialization
        this.unregisterListeners();

        localVideoThumbnail = new LocalVideo(VideoLayout, emitter);
        // sets default video type of local video
        // FIXME container type is totally different thing from the video type
        localVideoThumbnail.setVideoType(VIDEO_CONTAINER_TYPE);
        // if we do not resize the thumbs here, if there is no video device
        // the local video thumb maybe one pixel
        this.resizeThumbnails(false, true);

        this.registerListeners();
    },

    /**
     * Cleans up any existing largeVideo instance.
     *
     * @returns {void}
     */
    resetLargeVideo() {
        if (largeVideo) {
            largeVideo.destroy();
        }
        largeVideo = null;
    },

    /**
     * Registering listeners for UI events in Video layout component.
     *
     * @returns {void}
     */
    registerListeners() {
        eventEmitter.addListener(UIEvents.LOCAL_FLIPX_CHANGED,
            onLocalFlipXChanged);
        eventEmitter.addListener(UIEvents.CONTACT_CLICKED, onContactClicked);
    },

    /**
     * Unregistering listeners for UI events in Video layout component.
     *
     * @returns {void}
     */
    unregisterListeners() {
        eventEmitter.removeListener(UIEvents.CONTACT_CLICKED, onContactClicked);
    },

    initLargeVideo () {
        this.resetLargeVideo();

        largeVideo = new LargeVideoManager(eventEmitter);
        if(localFlipX) {
            largeVideo.onLocalFlipXChange(localFlipX);
        }
        largeVideo.updateContainerSize();
    },

    /**
     * Sets the audio level of the video elements associated to the given id.
     *
     * @param id the video identifier in the form it comes from the library
     * @param lvl the new audio level to update to
     */
    setAudioLevel(id, lvl) {
        let smallVideo = this.getSmallVideo(id);
        if (smallVideo)<commit_msg>fix(pinning): bind the callback for contact list clicking<commit_after>/* global APP, $, interfaceConfig, JitsiMeetJS  */
const logger = require("jitsi-meet-logger").getLogger(__filename);

import {
    getPinnedParticipant,
    pinParticipant
} from '../../../react/features/base/participants';

import Filmstrip from "./Filmstrip";
import UIEvents from "../../../service/UI/UIEvents";
import UIUtil from "../util/UIUtil";

import RemoteVideo from "./RemoteVideo";
import LargeVideoManager  from "./LargeVideoManager";
import {VIDEO_CONTAINER_TYPE} from "./VideoContainer";
import LocalVideo from "./LocalVideo";

const ParticipantConnectionStatus
    = JitsiMeetJS.constants.participantConnectionStatus;

var remoteVideos = {};
var localVideoThumbnail = null;

var currentDominantSpeaker = null;

var eventEmitter = null;

/**
 * flipX state of the localVideo
 */
let localFlipX = null;

/**
 * On contact list item clicked.
 */
function onContactClicked (id) {
    if (APP.conference.isLocalId(id)) {
        $("#localVideoContainer").click();
        return;
    }

    let remoteVideo = remoteVideos[id];
    if (remoteVideo && remoteVideo.hasVideo()) {
        // It is not always the case that a videoThumb exists (if there is
        // no actual video).
        if (remoteVideo.hasVideoStarted()) {
            // We have a video src, great! Let's update the large video
            // now.
            VideoLayout.handleVideoThumbClicked(id);
        } else {

            // If we don't have a video src for jid, there's absolutely
            // no point in calling handleVideoThumbClicked; Quite
            // simply, it won't work because it needs an src to attach
            // to the large video.
            //
            // Instead, we trigger the pinned endpoint changed event to
            // let the bridge adjust its lastN set for myjid and store
            // the pinned user in the lastNPickupId variable to be
            // picked up later by the lastN changed event handler.
            this.pinParticipant(remoteVideo.id);
        }
    }
}

/**
 * Handler for local flip X changed event.
 * @param {Object} val
 */
function onLocalFlipXChanged (val) {
    localFlipX = val;
    if(largeVideo) {
        largeVideo.onLocalFlipXChange(val);
    }
}

/**
 * Returns the corresponding resource id to the given peer container
 * DOM element.
 *
 * @return the corresponding resource id to the given peer container
 * DOM element
 */
function getPeerContainerResourceId (containerElement) {
    if (localVideoThumbnail.container === containerElement) {
        return localVideoThumbnail.id;
    }

    let i = containerElement.id.indexOf('participant_');

    if (i >= 0) {
        return containerElement.id.substring(i + 12);
    }
}

let largeVideo;

var VideoLayout = {
    init (emitter) {
        eventEmitter = emitter;

        // Unregister listeners in case of reinitialization
        this.unregisterListeners();

        localVideoThumbnail = new LocalVideo(VideoLayout, emitter);
        // sets default video type of local video
        // FIXME container type is totally different thing from the video type
        localVideoThumbnail.setVideoType(VIDEO_CONTAINER_TYPE);
        // if we do not resize the thumbs here, if there is no video device
        // the local video thumb maybe one pixel
        this.resizeThumbnails(false, true);

        this._onContactClicked = onContactClicked.bind(this);

        this.registerListeners();
    },

    /**
     * Cleans up any existing largeVideo instance.
     *
     * @returns {void}
     */
    resetLargeVideo() {
        if (largeVideo) {
            largeVideo.destroy();
        }
        largeVideo = null;
    },

    /**
     * Registering listeners for UI events in Video layout component.
     *
     * @returns {void}
     */
    registerListeners() {
        eventEmitter.addListener(UIEvents.LOCAL_FLIPX_CHANGED,
            onLocalFlipXChanged);
        eventEmitter.addListener(UIEvents.CONTACT_CLICKED,
            this._onContactClicked);
    },

    /**
     * Unregistering listeners for UI events in Video layout component.
     *
     * @returns {void}
     */
    unregisterListeners() {
        if (this._onContactClicked) {
            eventEmitter.removeListener(UIEvents.CONTACT_CLICKED,
                this._onContactClicked);
        }
    },

    initLargeVideo () {
        this.resetLargeVideo();

        largeVideo = new LargeVideoManager(eventEmitter);
        if(localFlipX) {
            largeVideo.onLocalFlipXChange(localFlipX);
        }
        largeVideo.updateContainerSize();
    },

    /**
     * Sets the audio level of the video elements associated to the given id.
     *
     * @param id the video identifier in the form it comes from the library
     * @param lvl the new audio level to update to
     */
    setAudioLevel(id, lvl) {
        let smallVideo = this.getSmallVideo(id);
        if (smallVideo)
{'fraction_non_alphanumeric': 0.09520865533230294, 'fraction_numerical': 0.0006182380216383308, 'mean_word_length': 2.455322178711285, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7134121', 'n_tokens_mistral': 2711, 'n_tokens_neox': 2661, 'n_words': 806}