<commit_before>declare var google:any;

import {
    Component,
    Input,
    AfterViewChecked,
    OnInit,
    OnDestroy,
} from 'angular2/core';


@Component({
    selector: 'subscription',
    templateUrl: 'app/components/subscription/subscription.html'
})
export class SubscriptionComponent implements OnInit, AfterViewChecked {
    @Input() search:any;
    @Input() socket;
    public tweets:Object[];
    private tweet:any;
    private channel;
    private isPaused:boolean = false;
    private subscribed:boolean = false;
    private className:String;
    private markers:any[] = [];
    private googleMap:any;
    private heatMap:any;
    private points:any[] = new google.maps.MVCArray();

    isVisibleMarkers:boolean = true;
    isVisibleHeatMap:boolean = true;

    public ngOnInit() {
        this.className = this.search.term.replace(' ', '-');
        this.channel = btoa(this.search.term);
        this.tweets = [];
        this.activateSocket();
    }

    private activateSocket() {
        this.socket.on('twitter-stream', (tweet) => {
            this.tweet = tweet;
            this.subscribeToChannel(tweet);
        });
    }

    private newTweet(data:Object) {
        this.tweets.push(data);
    }

    public subscribeToChannel(tweet) {
        console.log("paused", this.isPaused);
        if (this.isPaused) {
            return;
        }

        let lat = tweet.geo.coordinates[0],
            long = tweet.geo.coordinates[1],
            marker = new google.maps.Marker({
                position: {lat: lat, lng: long},
                map: this.isVisibleMarkers ? this.googleMap : null,
                icon: tweet.user.profile_image_url,
                animation: google.maps.Animation.DROP
            }),
            contentString =
                `<h5>${tweet.user.name}</h5>
                <h6><a href="http://twitter.com/${tweet.user.screen_name}">@${tweet.user.screen_name}</a></h6>
                 <p><small>${tweet.text}</small></p>;`,
            infowindow = new google.maps.InfoWindow({
                content: contentString,
                maxWidth: 200
            });


        this.markers.push(marker);
        this.points.push(new google.maps.LatLng(lat, long));

        google.maps.event.addListener(marker, 'click', () => {
            infowindow.open(this.googleMap, marker);
        });
        this.googleMap.setCenter(marker.getPosition());
    }

    public ngAfterViewInit() {
        let mapId = document.querySelector("#map-" + this.className),
            listItem = document.querySelector(".channel-" + this.className);

        if (mapId) {
            this.createGoogleMap(mapId);
        }
        if (listItem) {
            listItem.scrollTop = listItem.scrollHeight;
        }
    }

    public createGoogleMap(mapId) {
        this.googleMap = new google.maps.Map(mapId, {
            center: {lat: 37.4316, lng: 78.6569},
            minZoom: 2,
            maxZoom: 15,
            zoom: 2
        });

        this.heatMap = new google.maps.visualization.HeatmapLayer({
            data: this.points,
            map: this.googleMap
        });
    }

    private setMapOnAll(map) {
        for (var i = 0; i < this.markers.length; i++) {
            this.markers[i].setMap(map);
        }
    }

    private toggleMarkers() {
        this.isVisibleMarkers = !this.isVisibleMarkers;
        this.isVisibleMarkers ? this.setMapOnAll(this.googleMap) : this.setMapOnAll(null);
    }

    private toggleHeatMap() {
        this.isVisibleHeatMap = !this.isVisibleHeatMap;
        this.heatMap.setMap(this.isVisibleHeatMap ? this.googleMap : null);
    }

    public ngAfterViewChecked() {
        if (!this.search.active) {
            this.isPaused = true;
        } else if (this.search.active) {
            this.isPaused = false;
        }

    }

}
<commit_msg>update map<commit_after>declare var google:any;

import {
    Component,
    Input,
    AfterViewChecked,
    OnInit,
    OnDestroy,
} from 'angular2/core';


@Component({
    selector: 'subscription',
    templateUrl: 'app/components/subscription/subscription.html'
})
export class SubscriptionComponent implements OnInit, AfterViewChecked {
    @Input() search:any;
    @Input() socket;
    public tweets:Object[];
    private tweet:any;
    private channel;
    private isPaused:boolean = false;
    private subscribed:boolean = false;
    private className:String;
    private markers:any[] = [];
    private googleMap:any;
    private heatMap:any;
    private points:any[] = new google.maps.MVCArray();

    isVisibleMarkers:boolean = true;
    isVisibleHeatMap:boolean = true;

    public ngOnInit() {
        this.className = this.search.term.replace(' ', '-');
        this.channel = btoa(this.search.term);
        this.tweets = [];
        this.activateSocket();
    }

    private activateSocket() {
        this.socket.on('twitter-stream', (tweet) => {
            this.tweet = tweet;
            this.subscribeToChannel(tweet);
        });
    }

    private newTweet(data:Object) {
        this.tweets.push(data);
    }

    public subscribeToChannel(tweet) {
        console.log("paused", this.isPaused);
        if (this.isPaused) {
            return;
        }

        let lat = tweet.geo.coordinates[0],
            long = tweet.geo.coordinates[1],
            marker = new google.maps.Marker({
                position: {lat: lat, lng: long},
                map: this.isVisibleMarkers ? this.googleMap : null,
                icon: tweet.user.profile_image_url,
                animation: google.maps.Animation.DROP
            }),
            contentString =
                `<h5>${tweet.user.name}</h5>
                <h6><a href="http://twitter.com/${tweet.user.screen_name}">@${tweet.user.screen_name}</a></h6>
                 <p style="font-size: 15px">${tweet.text}</p>`,
            infowindow = new google.maps.InfoWindow({
                content: contentString,
                maxWidth: 220
            });
        console.debug(tweet);
        this.markers.push(marker);
        this.points.push(new google.maps.LatLng(lat, long));

        google.maps.event.addListener(marker, 'click', () => {
            infowindow.open(this.googleMap, marker);
        });
        this.googleMap.setCenter(marker.getPosition());
    }

    public ngAfterViewInit() {
        let mapId = document.querySelector("#map-" + this.className),
            listItem = document.querySelector(".channel-" + this.className);

        if (mapId) {
            this.createGoogleMap(mapId);
        }
        if (listItem) {
            listItem.scrollTop = listItem.scrollHeight;
        }
    }

    public createGoogleMap(mapId) {
        this.googleMap = new google.maps.Map(mapId, {
            center: {lat: 37.4316, lng: 78.6569},
            minZoom: 2,
            maxZoom: 15,
            zoom: 2
        });

        this.heatMap = new google.maps.visualization.HeatmapLayer({
            data: this.points,
            map: this.googleMap
        });
    }

    private setMapOnAll(map) {
        for (var i = 0; i < this.markers.length; i++) {
            this.markers[i].setMap(map);
        }
    }

    private toggleMarkers() {
        this.isVisibleMarkers = !this.isVisibleMarkers;
        this.isVisibleMarkers ? this.setMapOnAll(this.googleMap) : this.setMapOnAll(null);
    }

    private toggleHeatMap() {
        this.isVisibleHeatMap = !this.isVisibleHeatMap;
        this.heatMap.setMap(this.isVisibleHeatMap ? this.googleMap : null);
    }

    public ngAfterViewChecked() {
        if (!this.search.active) {
            this.isPaused = true;
        } else if (this.search.active) {
            this.isPaused = false;
        }

    }

}

{'fraction_non_alphanumeric': 0.1291283512498381, 'fraction_numerical': 0.007252946509519492, 'mean_word_length': 2.0401574803149605, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '3012217', 'n_tokens_mistral': 2417, 'n_tokens_neox': 2292, 'n_words': 394}