import {Component, Input, OnDestroy, OnInit} from "@angular/core"; import {AnnotationService} from "./annotation.service"; import {DomSanitizer} from "@angular/platform-browser"; import {ResultLandingInfo} from "../../utils/entities/resultLandingInfo"; @Component({ selector: 'b2note', template: `
`, styleUrls: ['annotation.css'] }) export class AnnotationComponent implements OnInit, OnDestroy { @Input() public landingInfo: ResultLandingInfo = null; @Input() public id: string = null; public url: string = null; public pid: string = null; public keywords: string[] = []; public visible: boolean = false; constructor(private annotationService: AnnotationService, private sanitizer: DomSanitizer) { } ngOnInit(): void { if (typeof window !== "undefined") { let id = this.id; this.url = window.location.href; if (this.landingInfo.deletedByInferenceIds) { id = this.landingInfo.deletedByInferenceIds[0]; this.url = this.url.replace(this.id, id); } if (this.landingInfo.identifiers.size > 0) { if (this.landingInfo.identifiers.get('doi')) { this.pid = this.landingInfo.identifiers.get('doi')[0]; } else { const key: string = this.landingInfo.identifiers.keys().next().value; if (key) { this.pid = this.landingInfo.identifiers.get(key)[0]; } } } else { this.pid = id; } console.log(this.pid); console.log(this.url); } } ngOnDestroy(): void { } public toggleAnnotation(event) { if (this.visible) { event.preventDefault() } this.visible = !this.visible; } }