mirror of
				https://github.com/bumi/lntip
				synced 2025-10-31 04:32:31 +00:00 
			
		
		
		
	Optional constructor parameter
this makes the interface easier when we only want to get a new address: new LnMe().newAddress().then(console.log)
This commit is contained in:
		
							parent
							
								
									e1882b8fcf
								
							
						
					
					
						commit
						ff35c727d4
					
				| @ -48,14 +48,14 @@ var paymentConfirmationTemplate = `<h1 class="lnme-header lnme-confirmation">Pay | ||||
| class LnMe { | ||||
| 
 | ||||
|   constructor(options) { | ||||
|     options = options || {}; | ||||
|     this.script = document.getElementById('lnme-script'); | ||||
|     if (options.baseURL) { | ||||
|       this.baseURL = options.baseURL; | ||||
|     } else if (this.script.dataset.lnmeBaseUrl) { | ||||
|     } else if (this.script && this.script.dataset.lnmeBaseUrl) { | ||||
|       this.baseURL = this.script.dataset.lnmeBaseUrl; | ||||
|     } else { | ||||
|       let url = new URL(this.script.src); | ||||
|       this.baseURL = `${url.protocol}//${url.host}`; | ||||
|       this.baseURL = `${document.location.protocol}//${document.location.host}`; | ||||
|     } | ||||
|     this.value = parseInt(options.value || 0); | ||||
|     this.memo = options.memo || ''; | ||||
| @ -66,7 +66,7 @@ class LnMe { | ||||
|   loadStylesheet() { | ||||
|     if (document.getElementById('lnme-style')) { return; } | ||||
|     // get the CSS file from the same source as the JS widget file
 | ||||
|     let source = this.script.src.replace(/\.js$/, ".css"); | ||||
|     let source = `${this.baseURL}/lnme/lnme.css`; | ||||
|     let head = document.getElementsByTagName('head')[0]; | ||||
|     let css = document.createElement('link'); | ||||
|     css.id = "lnme-style"; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user