[square] create common function to inject square so we don't have c/p everywhere

This commit is contained in:
nymkappa 2025-04-09 17:00:12 +09:00
parent d4074b3a0c
commit 8cec3c6e91
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04

View File

@ -3,6 +3,7 @@ import { TransactionStripped } from "@interfaces/node-api.interface";
import { AmountShortenerPipe } from "@app/shared/pipes/amount-shortener.pipe";
import { Router, ActivatedRoute } from '@angular/router';
const amountShortenerPipe = new AmountShortenerPipe();
import { isDevMode } from '@angular/core';
export function isMobile(): boolean {
return (window.innerWidth <= 767.98);
@ -280,3 +281,21 @@ export function md5(inputString): string {
}
return rh(a)+rh(b)+rh(c)+rh(d);
}
export function injectSquare(isProdDomain): void {
if (!isProdDomain && !isDevMode()) {
return;
}
if (window['Square']) {
return;
}
let statsUrl = 'https://sandbox.web.squarecdn.com/v1/square.js';
if (isProdDomain) {
statsUrl = '/square/v1/square.js';
}
(function(): void {
const d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.src=statsUrl; s.parentNode.insertBefore(g, s);
})();
}