<commit_before>import {Component, OnInit, ViewChild, OnDestroy} from '@angular/core';
import {ActivatedRoute, Params, Router} from "@angular/router";
import {MediaMetadata} from "../shared/model/media/media-metadata.model";
import {MetadataLookupService} from "../core/lookup/metadata-lookup.service";
import {QueryService} from "../core/queries/query.service";
import {MediaObject} from "../shared/model/media/media-object.model";
import {ResolverService} from "../core/basics/resolver.service";
import {SegmentScoreContainer} from "../shared/model/features/scores/segment-score-container.model";
import {Location} from "@angular/common";
import {MdSnackBar} from "@angular/material";

@Component({
    moduleId: module.id,
    selector: 'objectdetails',
    templateUrl: 'objectdetails.component.html'
})


export class ObjectdetailsComponent implements OnInit {
    /** */
    @ViewChild('audioplayer')
    private audioplayer: any;

    /** */
    @ViewChild('videoplayer')
    private videoplayer: any;

    /** ID of the media object that is currently examined. */
    private _objectId: string;

    /** ID of the media object that is currently examined. */
    private _mediaobject: MediaObject;

    /** List of MediaMetadata items for the current multimedia object. */
    private _metadata: MediaMetadata[] = [];

    /** List of SegmentScoreContainrs items for the current multimedia object. */
    private _segments: SegmentScoreContainer[] = [];

    /**
     *
     * @param _route
     * @param _location
     * @param _query
     * @param _metadataLookup
     * @param _resolver
     */
    constructor(private _route: ActivatedRoute,
                private _location: Location,
                private _query : QueryService,
                private _metadataLookup: MetadataLookupService,
                private _resolver: ResolverService,
                private _snackBar: MdSnackBar) {
    }

    /**
     * Invoked once when the component is initialized. Subscribes to the different services
     * and installs appropriate callback methods.
     */
    public ngOnInit() {
        /* Subscribes to changes of the Router class. Whenever the parameter becomes available,
         * the onParamsAvailable method is invoked. */
        this._route.params.first().subscribe((params: Params) => this.onParamsAvailable(params));
    }

    /**
     * Invoked when parameters from the ActiveRouter become available.
     *
     * @param params Parameters.
     */
    private onParamsAvailable(params: Params) {
        this._objectId = params['objectId'];
        if (this._objectId && this._query.has(this._objectId)) {
            this.refresh();
        } else {
            this._snackBar.open("The specified objectId '" + this._objectId + "' not found in the query results. Returning to gallery...", null, {duration: 3000}).afterDismissed().first().subscribe(() => {
                this._location.back()
            });
        }
    }


    /**
     *
     * @param start
     */
    public onSegmentClick(start: number) {
        if (this.audioplayer !== undefined) {
            this.audioplayer.nativeElement.currentTime = start;
            this.audioplayer.nativeElement.play();
        } else if (this.videoplayer !== undefined) {
            this.videoplayer.nativeElement.currentTime = start;
            this.videoplayer.nativeElement.play();
        }
    }

    /**
     * Triggered whenever someone clicks the 'Back' button. Returns to the last page,
     * i.e. usually the gallery.
     */
    public onBackClick() {<commit_msg>CHANGED: Adjusted the SnackBar message.<commit_after>import {Component, OnInit, ViewChild, OnDestroy} from '@angular/core';
import {ActivatedRoute, Params, Router} from "@angular/router";
import {MediaMetadata} from "../shared/model/media/media-metadata.model";
import {MetadataLookupService} from "../core/lookup/metadata-lookup.service";
import {QueryService} from "../core/queries/query.service";
import {MediaObject} from "../shared/model/media/media-object.model";
import {ResolverService} from "../core/basics/resolver.service";
import {SegmentScoreContainer} from "../shared/model/features/scores/segment-score-container.model";
import {Location} from "@angular/common";
import {MdSnackBar} from "@angular/material";

@Component({
    moduleId: module.id,
    selector: 'objectdetails',
    templateUrl: 'objectdetails.component.html'
})


export class ObjectdetailsComponent implements OnInit {
    /** */
    @ViewChild('audioplayer')
    private audioplayer: any;

    /** */
    @ViewChild('videoplayer')
    private videoplayer: any;

    /** ID of the media object that is currently examined. */
    private _objectId: string;

    /** ID of the media object that is currently examined. */
    private _mediaobject: MediaObject;

    /** List of MediaMetadata items for the current multimedia object. */
    private _metadata: MediaMetadata[] = [];

    /** List of SegmentScoreContainrs items for the current multimedia object. */
    private _segments: SegmentScoreContainer[] = [];

    /**
     *
     * @param _route
     * @param _location
     * @param _query
     * @param _metadataLookup
     * @param _resolver
     */
    constructor(private _route: ActivatedRoute,
                private _location: Location,
                private _query : QueryService,
                private _metadataLookup: MetadataLookupService,
                private _resolver: ResolverService,
                private _snackBar: MdSnackBar) {
    }

    /**
     * Invoked once when the component is initialized. Subscribes to the different services
     * and installs appropriate callback methods.
     */
    public ngOnInit() {
        /* Subscribes to changes of the Router class. Whenever the parameter becomes available,
         * the onParamsAvailable method is invoked. */
        this._route.params.first().subscribe((params: Params) => this.onParamsAvailable(params));
    }

    /**
     * Invoked when parameters from the ActiveRouter become available.
     *
     * @param params Parameters.
     */
    private onParamsAvailable(params: Params) {
        this._objectId = params['objectId'];
        if (this._objectId && this._query.has(this._objectId)) {
            this.refresh();
        } else {
            this._snackBar.open("The specified objectId '" + this._objectId + "' not found in the query results. Returning...", null, {duration: 3000}).afterDismissed().first().subscribe(() => {
                this._location.back()
            });
        }
    }


    /**
     *
     * @param start
     */
    public onSegmentClick(start: number) {
        if (this.audioplayer !== undefined) {
            this.audioplayer.nativeElement.currentTime = start;
            this.audioplayer.nativeElement.play();
        } else if (this.videoplayer !== undefined) {
            this.videoplayer.nativeElement.currentTime = start;
            this.videoplayer.nativeElement.play();
        }
    }

    /**
     * Triggered whenever someone clicks the 'Back' button. Returns to the last page,
     * i.e. usually the gallery.
     */
    public onBackClick() {
{'fraction_non_alphanumeric': 0.11637991327458386, 'fraction_numerical': 0.0011190376276402293, 'mean_word_length': 2.7278415015641295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2644331', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1882, 'n_words': 510}