Commit 0f2629ab authored by Yogita Sinkar's avatar Yogita Sinkar
Browse files

Add v8

parent 570d132b
Loading
Loading
Loading
Loading

leegalityv7.js

deleted100644 → 0
+0 −1
Original line number Diff line number Diff line
!function(){"use strict";function e(e){this.name="LeegalityException",this.message=e}window.Leegality=function(n){if(!n||!n.callback)throw new e("Callback function is required.");this.callback=n.callback,this.logoUrl=n.logoUrl||"https://assets.leegality.com/images/leegality_logo_new_transparent.png"},window.Leegality.prototype={popup:null,callback:null,logoUrl:null,responseData:null,messageListener:null,intervalId:null,_getWebSdkVersion:function(){return"v7"},cleanupEventListeners:function(){this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null),this.intervalId&&(window.clearInterval(this.intervalId),this.intervalId=null)},handleResponse:function(e){this.cancel(),this.callback(e),this.responseData=null},getLoadingHtml:function(){return"<html><head><meta http-equiv=\"Content-Security-Policy\" content=\"default-src *; img-src * 'self' data: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *\"><style>body { background: #d2d6de; font-family: Arial, sans-serif; margin: 0; padding: 0; }.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px }.logo-wrapper { text-align: center; margin-top: 5%; }.loading-wrapper { text-align: center; margin-top: 10%; }.loading-text { font-size: 16px; color: #333; }.logo-image { max-width: 50%; }.loader { max-width: 40px; max-height: 40px; }</style></head><body><div class=\"container\"><div class=\"logo-wrapper\"><img src=\""+this.logoUrl+'" class="logo-image"></div><div class="loading-wrapper"><p class="loading-text">Loading..Please Wait!</p><img src="https://s3.ap-south-1.amazonaws.com/leegality-production-helpers/spinner2.gif" class="loader"/></div></div></body></html>'},init:function(){if(this.cleanupEventListeners(),this.popup)try{console.log("Closing existing signing window"),this.popup.close(),console.log("Leegality signing window closed")}catch(e){console.error("Error closing existing popup:",e)}var e=.4*screen.width,n=.85*screen.height,t=.3*screen.width;try{if(this.popup=window.open("","_blank","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=0,width="+e+",height="+n+",top=0, left="+t),!this.popup)return this.callback({error:"Popup blocked. Please allow popups for this site."}),!1;this.popup.document.write(this.getLoadingHtml())}catch(e){return console.error("Error opening popup:",e),this.callback({error:"Failed to open popup: "+e.message}),!1}var i=this;return this.messageListener=function(e){var n=e.data;n&&"object"==typeof n&&(console.log("data",n),(n.hasOwnProperty("error")&&n.hasOwnProperty("invitationId")||n.hasOwnProperty("message")&&n.hasOwnProperty("documentId"))&&(i.responseData=n))},window.addEventListener("message",this.messageListener,!1),this.intervalId&&(window.clearInterval(this.intervalId),this.intervalId=null),this.intervalId=window.setInterval((function(){try{i.popup&&!i.popup.closed?i.responseData&&(window.clearInterval(i.intervalId),i.intervalId=null,i.handleResponse(i.responseData)):(window.clearInterval(i.intervalId),i.intervalId=null,i.handleResponse({error:"Cancelled."}))}catch(e){console.error("Error in popup check interval:",e),window.clearInterval(i.intervalId),i.intervalId=null,i.handleResponse({error:"Error: "+e.message})}}),1e3),!0},esign:function(n){if(!n)throw new e("URL is required.");if(!this.popup)throw new e("Initialize signing first.");try{var t=-1!==n.indexOf("?")?"&":"?",i=n+t+"webSdkVersion="+this._getWebSdkVersion();return this.popup.location=i,!0}catch(e){return console.error("Error navigating popup to URL:",e),this.callback({error:"Failed to load signing URL: "+e.message}),!1}},cancel:function(){if(this.cleanupEventListeners(),this.popup){try{console.log("Closing signing window"),this.popup.close(),console.log("Leegality Signing window closed")}catch(e){console.error("Error closing popup:",e)}this.popup=null}}}}();

leegalityv8.js

0 → 100644
+1 −0
Original line number Diff line number Diff line
!function(){function e(e){this.name="LeegalityException",this.message=e}window.Leegality=function(s){if(!s||!s.callback)throw new e("Callback function is required.");this.callback=s.callback,this.logoUrl=s.logoUrl||"https://assets.leegality.com/images/leegality_logo_new_transparent.png"},window.Leegality.prototype={popup:null,callback:null,logoUrl:null,messageListener:null,focusListener:null,isResponseHandled:!1,_getWebSdkVersion:()=>"v8",cleanupEventListeners(){this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null),this.focusListener&&(window.removeEventListener("focus",this.focusListener),this.focusListener=null)},handleResponse(e){console.log("Handling response from popup:",e),this.isResponseHandled?console.log("Response already handled, ignoring duplicate."):(this.isResponseHandled=!0,this.callback(e),this.cancel())},checkPopupClosed(){try{return!(this.popup&&!this.popup.closed)&&(this.isResponseHandled||this.handleResponse({error:"Cancelled."}),!0)}catch(e){return console.error("Error checking popup status:",e),this.isResponseHandled||this.handleResponse({error:`Error: ${e.message}`}),!0}},getLoadingHtml(){return`<html><head><meta http-equiv="Content-Security-Policy" content="default-src *; img-src * 'self' data: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *"><style>body { background: #d2d6de; font-family: Arial, sans-serif; margin: 0; padding: 0; }.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px }.logo-wrapper { text-align: center; margin-top: 5%; }.loading-wrapper { text-align: center; margin-top: 10%; }.loading-text { font-size: 16px; color: #333; }.logo-image { max-width: 50%; }.loader { max-width: 40px; max-height: 40px; }</style></head><body><div class="container"><div class="logo-wrapper"><img src="${this.logoUrl}" class="logo-image"></div><div class="loading-wrapper"><p class="loading-text">Loading..Please Wait!</p><img src="https://s3.ap-south-1.amazonaws.com/leegality-production-helpers/spinner2.gif" class="loader"/></div></div></body></html>`},init(){if(this.cleanupEventListeners(),this.isResponseHandled=!1,this.popup)try{console.log("Closing existing signing window - init"),this.popup.close(),console.log("Existing Leegality signing window closed - init")}catch(e){console.error("Error closing existing popup:",e)}const e=.4*window.screen.width,s=.85*window.screen.height,o=.3*window.screen.width;try{if(this.popup=window.open("","_blank",`toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=0,width=${e},height=${s},top=0, left=${o}`),!this.popup)return this.callback({error:"Popup blocked. Please allow popups for this site."}),!1;this.popup.document.write(this.getLoadingHtml())}catch(e){return console.error("Error opening popup:",e),this.callback({error:`Failed to open popup: ${e.message}`}),!1}const n=this;return this.messageListener=function(e){const{data:s}=e;s&&"object"==typeof s&&(console.log("Message received from popup:",s),(Object.prototype.hasOwnProperty.call(s,"error")&&Object.prototype.hasOwnProperty.call(s,"invitationId")||Object.prototype.hasOwnProperty.call(s,"message")&&Object.prototype.hasOwnProperty.call(s,"documentId"))&&n.handleResponse(s))},window.addEventListener("message",this.messageListener,!1),this.focusListener=function(){n.checkPopupClosed()},window.addEventListener("focus",this.focusListener,!1),!0},esign(s){if(!s)throw new e("URL is required.");if(!this.popup)throw new e("Initialize signing first.");try{const e=-1!==s.indexOf("?")?"&":"?",o=`${s+e}webSdkVersion=${this._getWebSdkVersion()}`;return this.popup.location=o,!0}catch(e){return console.error("Error navigating popup to URL:",e),this.callback({error:`Failed to load signing URL: ${e.message}`}),!1}},cancel(){if(this.cleanupEventListeners(),this.popup){try{console.log("Closing signing window - cancel"),this.popup.close(),console.log("Leegality Signing window closed - cancel")}catch(e){console.error("Error closing popup:",e)}this.popup=null}}}}();
 No newline at end of file