Commit 570d132b authored by Prakhar Agrawal's avatar Prakhar Agrawal
Browse files

v7 version.

parent 805a2446
Loading
Loading
Loading
Loading

leegalityv6.js

deleted100644 → 0
+0 −1
Original line number Diff line number Diff line
!function(){"use strict";function t(t){this.name="LeegalityExecption",this.message=t}(window.Leegality=function(e){if(!e||!e.callback)throw new t("Callback function is required.");this.callback=e.callback,this.logoUrl=e.logoUrl}).prototype={popup:null,callback:null,logoUrl:null,responseData:null,handleResponse:function(t){this.cancel(),this.callback(t),this.responseData=null},getLoadingHtml:function(){var t='<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\' *"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"><\/script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"><\/script><style>body{background: #d2d6de;}.logo-div{margin-top: 5%;}.loading-div{margin-top: 10%;}.text-center{text-align: center;}.loading-text{font-size: 16px;}.logo-image{max-width: 50%;}.loader{max-width: 40px;max-height: 40px;}</style></head><body><div class="container"><div class="row logo-div"><div class="col-md-4"></div><div class="col-md-4 text-center"><img src="',e='" class="logo-image"></div><div class="col-md-4"></div></div><div class="row loading-div"><div class="col-md-4"></div><div class="col-md-4 text-center"><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 class="col-md-4"></div></div></div></body></html>';return this.logoUrl?t+this.logoUrl+e:t+"https://s3.ap-south-1.amazonaws.com/leegality-production-helpers/leegality-logo.png"+e},init:function(){this.popup&&this.popup.close();var t=.4*screen.width,e=.85*screen.height,s=.3*screen.width;this.popup=window.open("","_blank","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=0,width="+t+",height="+e+",top=0, left="+s),this.popup.document.write(this.getLoadingHtml());var o=this;window.addEventListener("message",function(t){var e=t.data;e&&"object"==typeof e&&(e.hasOwnProperty("error")||e.hasOwnProperty("message")&&e.hasOwnProperty("documentId"))&&(o.responseData=e)},!1);var i=window.setInterval(function(){o.responseData?(window.clearInterval(i),o.handleResponse(o.responseData)):o.popup.closed&&(o.handleResponse({error:"Cancelled."}),window.clearInterval(i))},1e3)},esign:function(e){if(!e)throw new t("Url is required.");if(!this.popup)throw new t("Intialize signing first.");this.popup.location=e},cancel:function(){this.popup&&this.popup.close()}}}();

leegalityv7.js

0 → 100644
+1 −0
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}}}}();
+4 −4
Original line number Diff line number Diff line
# Leegality Web SDK 6.0#
# Leegality Web SDK 7.0#

### Steps to use: ###

1. Download Leegality Library from http://gitlab.leegality.com/leegality-public/web-sdk/blob/v5/leegalityv6.js
1. Download Leegality Library from http://gitlab.leegality.com/leegality-public/web-sdk/blob/v7/leegalityv7.js
2. Insert the SDK JS file in head tag of HTML.
    <br __>Ex. `<script src="leegalityv6.js" type="text/javascript"></script>`
    <br __>Ex. `<script src="leegalityv7.js" type="text/javascript"></script>`
3. Create a JSON object with following keys:
    <br __>3.1 logoUrl: (This is an optional parameter) This key contains a URL of your logo in any image file format. This Logo is shown on the Loading Page before the Signing Page appears. 
    <br __>3.2 callback: (This is a required parameter) This key contains a function which will be automatically executed after the completion of signing or in case of any error.
@@ -45,7 +45,7 @@
```
<html>
    <head>
        <script src="leegalityv5.js" type="text/javascript"></script>
        <script src="leegalityv7.js" type="text/javascript"></script>
    </head>
    <body>
        <p>Message: <span id="message"></span></p>