mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-04-21 11:32:30 +08:00
* [APP-929][APP-930] * [APP-929][APP-930] * update logic * update init app * [APP-0000] store plan scope after register/switch * change return of load * add header * Move into shadow dom, add context, add headers components * add UI components * add UI components * add UI components * merge current develop * merge current develop * Add AltText Form * Add scroll to current element * Align with current design, add loader, added preview for svg * Align with current design, add loader, added preview for svg * Resolve comments * Resolve comments * Resolve comments
30 lines
765 B
JavaScript
30 lines
765 B
JavaScript
const load = async () => {
|
|
return new Promise((resolve, reject) => {
|
|
const { scannerUrl, planData } = window?.ea11yScannerData;
|
|
|
|
const scriptSrc = `${scannerUrl}?api_key=${planData?.public_api_key}`;
|
|
|
|
// Check if script already exists
|
|
if (document.querySelector(`script[src="${scriptSrc}"]`)) {
|
|
return resolve(true); // Already loaded, resolve immediately
|
|
}
|
|
|
|
const script = document.createElement('script');
|
|
script.src = scriptSrc;
|
|
script.async = true;
|
|
|
|
script.onload = () => {
|
|
return resolve(true); // Resolve the promise
|
|
};
|
|
|
|
script.onerror = () => {
|
|
return reject(new Error(`Failed to load script: ${scannerUrl}`)); // Reject the promise
|
|
};
|
|
|
|
document.body.appendChild(script);
|
|
});
|
|
};
|
|
|
|
export const scannerWizard = {
|
|
load,
|
|
};
|