-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresponse-page-iframe.component.ts
More file actions
64 lines (61 loc) · 1.84 KB
/
response-page-iframe.component.ts
File metadata and controls
64 lines (61 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { style } from "@angular/animations";
import { MessageService } from "./../../services/message.service";
import { Component, OnInit, ElementRef, ViewChild } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
@Component({
selector: "app-response-page-iframe",
templateUrl: "./response-page-iframe.component.html",
styleUrls: ["./response-page-iframe.component.css"],
})
export class ResponsePageIframeComponent implements OnInit {
public siteUrl: any;
public origin: any;
public destination: any;
@ViewChild("iframe") iframe: ElementRef;
constructor(
private msgService: MessageService,
protected sanitizer: DomSanitizer
) {}
ngOnInit() {
const self = this;
this.iframe.nativeElement.onload = function () {
const header = self.iframe.nativeElement.contentDocument.getElementsByClassName(
"header"
);
const footer = self.iframe.nativeElement.contentDocument.getElementsByClassName(
"footer"
);
const chatbot = self.iframe.nativeElement.contentDocument.getElementsByClassName(
"chatbot"
);
if (header.length > 0) {
header[0].style.display = "none";
}
if (footer.length > 0) {
footer[0].style.display = "none";
}
if (chatbot.length > 0) {
chatbot[0].style.display = "none";
}
};
this.msgService.watchStorage().subscribe((message) => {
const siteUrl = localStorage.getItem("url");
this.checkForSameOriginError(siteUrl);
});
}
checkForSameOriginError(url) {
this.msgService.testUrlCanLoad(url).subscribe(
(result) => {
this.siteUrl = url;
console.log("Success");
},
(err) => {
if (err.status === 200) {
this.siteUrl = url;
} else {
this.siteUrl = "pathway";
}
}
);
}
}