Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-137930 DCXY-18989 if snippet is loaded inline, use it #417

Merged
merged 7 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions acrobat/blocks/dc-converter-widget/dc-converter-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,10 @@ export default async function init(element) {
ENV = 'stage';
}

widget.querySelector('div').id = 'VERB';
const VERB = widget.querySelector('div').textContent.trim().toLowerCase();
const [FIRST_DIV, REDIRECT_URL_DIV, GENERATE_CACHE_URL_DIV] = widget.querySelectorAll(':scope > div');
FIRST_DIV.id = 'VERB';
const VERB = FIRST_DIV.textContent.trim().toLowerCase();

// Redir URL
const REDIRECT_URL_DIV = widget.querySelectorAll('div')[2];
if (REDIRECT_URL_DIV) {
REDIRECT_URL = REDIRECT_URL_DIV.textContent.trim();
REDIRECT_URL_DIV.remove();
Expand All @@ -198,8 +197,6 @@ export default async function init(element) {
window.location.href = EOLBrowserPage;
}

// Generate cache url
const GENERATE_CACHE_URL_DIV = widget.querySelectorAll('div')[4];
if (GENERATE_CACHE_URL_DIV) {
// GENERATE_CACHE_URL_DIV.id = 'GENERATE_CACHE_URL';
DC_GENERATE_CACHE_URL = GENERATE_CACHE_URL_DIV.textContent.trim();
Expand Down Expand Up @@ -317,7 +314,14 @@ export default async function init(element) {
const verbIncludeList = ['compress-pdf', 'fillsign', 'sendforsignature', 'add-comment',
'delete-pages', 'reorder-pages', 'split-pdf', 'insert-pdf', 'extract-pages', 'crop-pages', 'number-pages'];

if (verbIncludeList.includes(VERB) || preRenderDropZone) {
const INLINE_SNIPPET = widget.querySelector(':scope > section#edge-snippet');
if (INLINE_SNIPPET) {
widgetContainer.dataset.rendered = 'true';
peller marked this conversation as resolved.
Show resolved Hide resolved
widgetContainer.appendChild(...INLINE_SNIPPET.childNodes);
widget.removeChild(INLINE_SNIPPET);
cacheLoad = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <no-undef> reported by reviewdog 🐶
'cacheLoad' is not defined.

performance.mark('milo-move-snippet');
} else if (verbIncludeList.includes(VERB) || preRenderDropZone) {
const response = await fetch(DC_GENERATE_CACHE_URL || `${DC_DOMAIN}/dc-generate-cache/dc-hosted-${DC_GENERATE_CACHE_VERSION}/${VERB}-${pageLang}.html`);
switch (response.status) {
case 200: {
Expand Down
4 changes: 2 additions & 2 deletions acrobat/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ const CONFIG = {
const { ietf } = getLocale(locales);

(async function loadPage() {

// Fast track the widget
const widgetBlock = document.querySelector('[class*="dc-converter-widget"]');

Expand All @@ -283,7 +282,8 @@ const { ietf } = getLocale(locales);
widgetBlock.removeAttribute('class');
widgetBlock.id = 'dc-converter-widget';
const DC_GENERATE_CACHE_VERSION = document.querySelector('meta[name="dc-generate-cache-version"]')?.getAttribute('content');
const dcUrls = [
const INLINE_SNIPPET = document.querySelector('section#edge-snippet');
const dcUrls = INLINE_SNIPPET ? [] : [
`https://www.adobe.com/dc/dc-generate-cache/dc-hosted-${DC_GENERATE_CACHE_VERSION}/${verb}-${ietf.toLowerCase()}.html`,
];

Expand Down
Loading