<commit_before>/// <reference path="../../../../typings/index.d.ts" />

import * as THREE from "three";

import {Observable} from "rxjs/Observable";
import {Subject} from "rxjs/Subject";

import {
    IPopupOptions,
    PopupAlignment,
} from "../../../Component";
import {Transform} from "../../../Geo";
import {
    ISize,
    RenderCamera,
} from "../../../Render";

export class Popup {
    protected _notifyChanged$: Subject<Popup>;

    private _container: HTMLDivElement;
    private _content: HTMLDivElement;
    private _parentContainer: HTMLElement;
    private _options: IPopupOptions;
    private _tip: HTMLDivElement;

    private _point: number[];
    private _rect: number[];

    constructor(options?: IPopupOptions) {
        this._options = {};

        if (!!options) {
            this._options.float = options.float;
            this._options.position = options.position;
            this._options.visuals = options.visuals;
        }

        this._notifyChanged$ = new Subject<Popup>();
    }

    public get changed$(): Observable<Popup> {
        return this._notifyChanged$;
    }

    public remove(): void {
        if (this._content && this._content.parentNode) {
            this._content.parentNode.removeChild(this._content);
        }

        if (this._container) {
            this._container.parentNode.removeChild(this._container);
            delete this._container;
        }

        if (this._parentContainer) {
            delete this._parentContainer;
        }
    }

    public setBasicPoint(basicPoint: number[]): void {
        this._point = basicPoint.slice();
        this._rect = null;

        this._notifyChanged$.next(this);
    }

    public setBasicRect(basicRect: number[]): void {
        this._rect = basicRect.slice();
        this._point = null;

        this._notifyChanged$.next(this);
    }

    public setDOMContent(htmlNode: Node): void {
        if (this._content && this._content.parentNode) {
            this._content.parentNode.removeChild(this._content);
        }

        const className: string = this._options.visuals === true ? "mapillaryjs-popup-content" : "mapillaryjs-clean-popup-content";
        this._content = <HTMLDivElement>this._createElement("div", className, this._container);

        this._content.appendChild(htmlNode);

        this._notifyChanged$.next(this);
    }

    public setParentContainer(parentContainer: HTMLElement): void {<commit_msg>Add methods for setting content to text or html string<commit_after>/// <reference path="../../../../typings/index.d.ts" />

import * as THREE from "three";

import {Observable} from "rxjs/Observable";
import {Subject} from "rxjs/Subject";

import {
    IPopupOptions,
    PopupAlignment,
} from "../../../Component";
import {Transform} from "../../../Geo";
import {
    ISize,
    RenderCamera,
} from "../../../Render";

export class Popup {
    protected _notifyChanged$: Subject<Popup>;

    private _container: HTMLDivElement;
    private _content: HTMLDivElement;
    private _parentContainer: HTMLElement;
    private _options: IPopupOptions;
    private _tip: HTMLDivElement;

    private _point: number[];
    private _rect: number[];

    constructor(options?: IPopupOptions) {
        this._options = {};

        if (!!options) {
            this._options.float = options.float;
            this._options.position = options.position;
            this._options.visuals = options.visuals;
        }

        this._notifyChanged$ = new Subject<Popup>();
    }

    public get changed$(): Observable<Popup> {
        return this._notifyChanged$;
    }

    public remove(): void {
        if (this._content && this._content.parentNode) {
            this._content.parentNode.removeChild(this._content);
        }

        if (this._container) {
            this._container.parentNode.removeChild(this._container);
            delete this._container;
        }

        if (this._parentContainer) {
            delete this._parentContainer;
        }
    }

    public setBasicPoint(basicPoint: number[]): void {
        this._point = basicPoint.slice();
        this._rect = null;

        this._notifyChanged$.next(this);
    }

    public setBasicRect(basicRect: number[]): void {
        this._rect = basicRect.slice();
        this._point = null;

        this._notifyChanged$.next(this);
    }

    public setDOMContent(htmlNode: Node): void {
        if (this._content && this._content.parentNode) {
            this._content.parentNode.removeChild(this._content);
        }

        const className: string = this._options.visuals === true ? "mapillaryjs-popup-content" : "mapillaryjs-clean-popup-content";
        this._content = <HTMLDivElement>this._createElement("div", className, this._container);

        this._content.appendChild(htmlNode);

        this._notifyChanged$.next(this);
    }

    public setHTML(html: string): void {
        const frag: DocumentFragment = document.createDocumentFragment();
        const temp: HTMLBodyElement = document.createElement("body");
        let child: Node;
        temp.innerHTML = html;

        while (true) {
            child = temp.firstChild;
            if (!child) {
                break;
            }

            frag.appendChild(child);
        }

        this.setDOMContent(frag);
    }

    public setText(text: string): void {
        this.setDOMContent(document.createTextNode(text));
    }

    public setParentContainer(parentContainer: HTMLElement): void {
{'fraction_non_alphanumeric': 0.1282612661923007, 'fraction_numerical': 0.0, 'mean_word_length': 2.4477987421383647, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3292062', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1480, 'n_words': 312}