From 727be17aa56f8ef742818ad7159148e351a732a7 Mon Sep 17 00:00:00 2001 From: Bonnie Zheng Date: Wed, 3 Apr 2024 11:21:45 -0700 Subject: [PATCH 1/3] add admiral script --- scripts/scripts.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/scripts.js b/scripts/scripts.js index 0d58e1de..afbd6948 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -1052,12 +1052,35 @@ async function loadEager(doc) { } } +/** + * Loads Admiral script + */ +function loadAdmiral() { + const fetchScript = async () => { + try { + const response = await fetch( + "https://orchestrator-config-uat.pgatour.com/revops/admirial" + ); + const content = await response.text(); + const script = document.createElement("script"); + script.type = "text/javascript"; + script.innerHTML = content; + script.id = "admiral"; + document.head.appendChild(script); + } catch (error) { + console.error("Error loading Admiral script: ", error); + } + }; + fetchScript(); +} + /** * loads everything that doesn't need to be delayed. */ async function loadLazy(doc) { const main = doc.querySelector('main'); await loadBlocks(main); + loadAdmiral() const { hash } = window.location; const element = hash ? main.querySelector(hash) : false; From 064c152389930ac1447a63b8c2ccf5460322bde6 Mon Sep 17 00:00:00 2001 From: Bonnie Zheng Date: Wed, 10 Apr 2024 16:10:27 -0700 Subject: [PATCH 2/3] TDW-1646 admiral script --- scripts/delayed.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/delayed.js b/scripts/delayed.js index 65ee7fa9..72babe8e 100644 --- a/scripts/delayed.js +++ b/scripts/delayed.js @@ -755,3 +755,29 @@ const hasWeFevo = document.querySelector('a.we-fevo-btn'); if (hasWeFevo) { injectWeFevoScript(); } + + +/** + * Loads Admiral script + */ +function loadAdmiral() { + const fetchScript = async () => { + try { + const response = await fetch( + 'https://orchestrator-config-uat.pgatour.com/revops/admirial', + ); + const content = await response.text(); + const script = document.createElement('script'); + script.type = 'text/javascript'; + script.innerHTML = content; + script.id = 'admiral'; + script.async = true; + document.head.appendChild(script); + } catch (error) { + throw new Error('Error loading Admiral script: ', error); + } + }; + fetchScript(); +} + +loadAdmiral(); From a787a624ba03b9f2936bd5d668ff9510b5f34ef3 Mon Sep 17 00:00:00 2001 From: Bonnie Zheng Date: Wed, 10 Apr 2024 16:14:41 -0700 Subject: [PATCH 3/3] remove in script.js --- scripts/delayed.js | 2 -- scripts/scripts.js | 23 ----------------------- 2 files changed, 25 deletions(-) diff --git a/scripts/delayed.js b/scripts/delayed.js index 72babe8e..b724abbd 100644 --- a/scripts/delayed.js +++ b/scripts/delayed.js @@ -756,7 +756,6 @@ if (hasWeFevo) { injectWeFevoScript(); } - /** * Loads Admiral script */ @@ -771,7 +770,6 @@ function loadAdmiral() { script.type = 'text/javascript'; script.innerHTML = content; script.id = 'admiral'; - script.async = true; document.head.appendChild(script); } catch (error) { throw new Error('Error loading Admiral script: ', error); diff --git a/scripts/scripts.js b/scripts/scripts.js index afbd6948..0d58e1de 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -1052,35 +1052,12 @@ async function loadEager(doc) { } } -/** - * Loads Admiral script - */ -function loadAdmiral() { - const fetchScript = async () => { - try { - const response = await fetch( - "https://orchestrator-config-uat.pgatour.com/revops/admirial" - ); - const content = await response.text(); - const script = document.createElement("script"); - script.type = "text/javascript"; - script.innerHTML = content; - script.id = "admiral"; - document.head.appendChild(script); - } catch (error) { - console.error("Error loading Admiral script: ", error); - } - }; - fetchScript(); -} - /** * loads everything that doesn't need to be delayed. */ async function loadLazy(doc) { const main = doc.querySelector('main'); await loadBlocks(main); - loadAdmiral() const { hash } = window.location; const element = hash ? main.querySelector(hash) : false;