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

fsw (full screen widget) #297

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
23 changes: 7 additions & 16 deletions acrobat/blocks/dc-converter-widget/dc-converter-widget.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {createTag} from "../../scripts/miloUtils.js";

// Could use webpack/rollup. Just manually inline these structures, for now.
const localeMap = {
'': 'en-us',
Expand Down Expand Up @@ -121,15 +119,10 @@ const pageLang = localeMap[langFromPath] || 'en-us';
export default function init(element) {
element.closest('main > div').dataset.section = 'widget';
const widget = element;
widget.querySelector('div').id = 'VERB';
const VERB = widget.querySelector('div').textContent.trim().toLowerCase();
const DC_WIDGET_VERSION_FALLBACK = '2.40.0_1.172.1';
const DC_GENERATE_CACHE_VERSION_FALLBACK = '1.172.1';
const STG_DC_WIDGET_VERSION = document.querySelector('meta[name="stg-dc-widget-version"]')?.getAttribute('content');
const STG_DC_GENERATE_CACHE_VERSION = document.querySelector('meta[name="stg-dc-generate-cache-version"]')?.getAttribute('content');
const isReturningUser = window.localStorage.getItem('pdfnow.auth');
const isRedirection = /redirect_(?:conversion|files)=true/.test(window.location.search);
const preRenderDropZone = !isReturningUser && !isRedirection;

let DC_DOMAIN = 'https://dev.acrobat.adobe.com';
let DC_WIDGET_VERSION = document.querySelector('meta[name="dc-widget-version"]')?.getAttribute('content');
Expand All @@ -151,13 +144,6 @@ export default function init(element) {
let REDIRECT_URL = '';
let DC_GENERATE_CACHE_URL = '';

createTag.then((createTag) => {
const preCacheGen = createTag('link', { rel: 'prefetch', as: 'script', href: `${DC_DOMAIN}/dc-generate-cache/dc-hosted-${DC_GENERATE_CACHE_VERSION}/${VERB}-${pageLang}.html` });
if (preRenderDropZone) { document.head.appendChild(preCacheGen); }
const preAppLauncher = createTag('link', { rel: 'prefetch', as: 'script', href: WIDGET_ENV });
document.head.appendChild(preAppLauncher);
});

if (window.location.hostname === 'www.adobe.com') {
WIDGET_ENV = `https://acrobat.adobe.com/dc-hosted/${DC_WIDGET_VERSION}/dc-app-launcher.js`;
DC_DOMAIN = 'https://acrobat.adobe.com';
Expand All @@ -175,6 +161,9 @@ export default function init(element) {
ENV = 'stage';
}

widget.querySelector('div').id = 'VERB';
const VERB = widget.querySelector('div').textContent.trim().toLowerCase();

// Redir URL
const REDIRECT_URL_DIV = widget.querySelectorAll('div')[2];
if (REDIRECT_URL_DIV) {
Expand All @@ -183,6 +172,7 @@ export default function init(element) {
REDIRECT_URL_DIV.remove();
}


// Generate cache url
const GENERATE_CACHE_URL_DIV = widget.querySelectorAll('div')[4];
if (GENERATE_CACHE_URL_DIV) {
Expand All @@ -202,13 +192,14 @@ export default function init(element) {
}
};



const widgetContainer = document.createElement('div');
widgetContainer.id = 'CID';
widgetContainer.className = `fsw wapper-${VERB}`;
widget.appendChild(widgetContainer);

const isReturningUser = window.localStorage.getItem('pdfnow.auth');
const isRedirection = /redirect_(?:conversion|files)=true/.test(window.location.search);
const preRenderDropZone = !isReturningUser && !isRedirection;
if (preRenderDropZone) {
(async () => {
// TODO: Make dynamic
Expand Down
Loading