mirror of https://github.com/bumi/lntip
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 {
|
class LnMe {
|
||||||
|
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
options = options || {};
|
||||||
this.script = document.getElementById('lnme-script');
|
this.script = document.getElementById('lnme-script');
|
||||||
if (options.baseURL) {
|
if (options.baseURL) {
|
||||||
this.baseURL = 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;
|
this.baseURL = this.script.dataset.lnmeBaseUrl;
|
||||||
} else {
|
} else {
|
||||||
let url = new URL(this.script.src);
|
this.baseURL = `${document.location.protocol}//${document.location.host}`;
|
||||||
this.baseURL = `${url.protocol}//${url.host}`;
|
|
||||||
}
|
}
|
||||||
this.value = parseInt(options.value || 0);
|
this.value = parseInt(options.value || 0);
|
||||||
this.memo = options.memo || '';
|
this.memo = options.memo || '';
|
||||||
|
@ -66,7 +66,7 @@ class LnMe {
|
||||||
loadStylesheet() {
|
loadStylesheet() {
|
||||||
if (document.getElementById('lnme-style')) { return; }
|
if (document.getElementById('lnme-style')) { return; }
|
||||||
// get the CSS file from the same source as the JS widget file
|
// 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 head = document.getElementsByTagName('head')[0];
|
||||||
let css = document.createElement('link');
|
let css = document.createElement('link');
|
||||||
css.id = "lnme-style";
|
css.id = "lnme-style";
|
||||||
|
|
Loading…
Reference in New Issue