UNPKG

@satisfactor/web-integration-angular

Version:

This package helps you integrate the satisfaction survey into any website implemented in angular

89 lines (81 loc) 3.71 kB
import { __decorate } from 'tslib'; import { ɵɵdefineInjectable, Injectable, Input, Component, NgModule } from '@angular/core'; var SatisfactorService = /** @class */ (function () { function SatisfactorService() { } SatisfactorService.ɵprov = ɵɵdefineInjectable({ factory: function SatisfactorService_Factory() { return new SatisfactorService(); }, token: SatisfactorService, providedIn: "root" }); SatisfactorService = __decorate([ Injectable({ providedIn: 'root' }) ], SatisfactorService); return SatisfactorService; }()); /** * UserSurvey */ var UserSurveyModel = /** @class */ (function () { function UserSurveyModel(id, name, email, cellPhone, company) { this.id = id; this.name = name !== undefined ? name : null; this.email = email !== undefined ? email : null; this.cellPhone = cellPhone !== undefined ? cellPhone : null; this.company = company !== undefined ? company : null; } UserSurveyModel.prototype.isValid = function () { return this.id !== undefined; }; return UserSurveyModel; }()); var SatisfactorComponent = /** @class */ (function () { function SatisfactorComponent() { } SatisfactorComponent.prototype.loadScript = function () { console.log(this.userSurvey); console.log(this.projectToken); if (this.userSurvey instanceof UserSurveyModel && this.userSurvey.isValid()) { var script = document.createElement('script'); script.type = 'text/javascript'; script.innerHTML = "!function(){window.satisfactor=window.satisfactor||function(){(window.satisfactor.value=window.satisfactor.value||[]).push(arguments)};var e=document.createElement(\"script\"),t=document.getElementsByTagName(\"script\")[0].parentNode;e.async=1,e.src=\"https://app.satisfactor.io/js/nps.min.js\",t.appendChild(e);var s=document.createElement(\"link\"),a=document.getElementsByTagName(\"head\")[0];s.type=\"text/css\",s.rel=\"stylesheet\",s.href=\"https://app.satisfactor.io/css/nps.min.css\",a.appendChild(s)}();\n satisfactor({\n token: \"" + this.projectToken + "\",\n userId: \"" + this.userSurvey.id + "\",\n traits: {\n name: \"" + this.userSurvey.name + "\",\n email: \"" + this.userSurvey.email + "\",\n cell_phone: \"" + this.userSurvey.cellPhone + "\",\n company: \"" + this.userSurvey.company + "\"\n }\n });"; document.getElementsByTagName('body')[0].appendChild(script); } }; SatisfactorComponent.prototype.ngOnInit = function () { this.loadScript(); }; __decorate([ Input() ], SatisfactorComponent.prototype, "userSurvey", void 0); __decorate([ Input() ], SatisfactorComponent.prototype, "projectToken", void 0); SatisfactorComponent = __decorate([ Component({ selector: 'satisfactor', template: "" }) ], SatisfactorComponent); return SatisfactorComponent; }()); var SatisfactorModule = /** @class */ (function () { function SatisfactorModule() { } SatisfactorModule = __decorate([ NgModule({ declarations: [SatisfactorComponent], imports: [], exports: [ SatisfactorComponent, ] }) ], SatisfactorModule); return SatisfactorModule; }()); /* * Public API Surface of satisfactor */ /** * Generated bundle index. Do not edit. */ export { SatisfactorComponent, SatisfactorModule, SatisfactorService, UserSurveyModel }; //# sourceMappingURL=satisfactor-web-integration-angular.js.map