async loadContext() { const res = await fetch('/playground/context'); const result = await res.json(); return { cubejsToken: result.cubejsToken, apiUrl: result.apiUrl || window.location.href.split('#')[0].replace(/\/$/, ''), }; }
/** * Gets page URL including hash. */ async _getPageUrl() { return this.executeScript(() => window.location.href); }
function triggerPageChange(name) { try { var onPageChange = window.parent.onWhistlePageChange; if (typeof onPageChange === 'function' && curPageName !== name) { curPageName = name; onPageChange(name, location.href); } } catch (e) {} }
/** * Whether the current URL can potentially contain personally identifiable info. * * @returns {boolean} true if the current URL can potentially contain personally identifiable info. */ export default function isPiiUrl() { const href = document.location.href; const match = ( pattern ) => href.indexOf( pattern ) !== -1; const result = forbiddenPiiPatterns.some( match ) || forbiddenPiiPatternsEnc.some( match ); debug( `Is PII URL: ${ result }` ); return result; }
/** * {{> grabCurrentUrl }} */ async grabCurrentUrl() { return ClientFunction(() => document.location.href).with({ boundTestRun: this.t })(); }
this.$store.dispatch("init").then(function () { if(!/\/public\/public\.html/i.test(location.href)) { $.stopLoading() } })
/** * {{> waitInUrl }} */ async waitInUrl(urlPart, sec = null) { const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout; const clientFn = createClientFunction((urlPart) => { const currUrl = decodeURIComponent(decodeURIComponent(decodeURIComponent(window.location.href))); return currUrl.indexOf(urlPart) > -1; }, [urlPart]).with({ boundTestRun: this.t }); return waitForFunction(clientFn, waitTimeout).catch(async (err) => { const currUrl = await this.grabCurrentUrl(); throw new Error(`expected url to include ${urlPart}, but found ${currUrl}`); }); }
async function makePayPalExpressRequest( data ) { window.console.log( 'Processing paypal transaction with data', data ); // This simulates the transaction and provisioning time await asyncTimeout( 2000 ); return window.location.href; }
async componentDidMount() { const res = await fetch('/playground/context'); const result = await res.json(); this.setState({ cubejsToken: result.cubejsToken, apiUrl: result.apiUrl || window.location.href.split('#')[0].replace(/\/$/, ''), }); }
function getPageInfo() { return '\r\nPage Url: ' + location.href + '\r\nUser Agent: ' + navigator.userAgent; }
async function preselectParentPage() { const parentPostId = parseInt( getQueryArg( window.location.href, 'parent_post' ) ); if ( ! parentPostId || isNaN( parseInt( parentPostId ) ) ) { return; } const postType = select( 'core/editor' ).getCurrentPostType(); if ( 'page' !== postType ) { return; } const pages = await getPages(); const isValidParentId = pages.some( ( page ) => page.id === parentPostId ); if ( isValidParentId ) { dispatch( 'core/editor' ).editPost( { parent: parentPostId } ); } }
/** * {{> waitInUrl }} */ async waitInUrl(urlPart, sec = null) { const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout; return this.page.waitForFunction((urlPart) => { const currUrl = decodeURIComponent(decodeURIComponent(decodeURIComponent(window.location.href))); return currUrl.indexOf(urlPart) > -1; }, { timeout: waitTimeout }, urlPart).catch(async (e) => { const currUrl = await this._getPageUrl(); // Required because the waitForFunction can't return data. if (/failed: timeout/i.test(e.message)) { throw new Error(`expected url to include ${urlPart}, but found ${currUrl}`); } else { throw e; } }); }
/** * Client Functions */ const getPageUrl = t => ClientFunction(() => document.location.href).with({ boundTestRun: t })
/** * Gets page URL including hash. */ async _getPageUrl() { return this.executeScript(() => window.location.href); }
/** * {{> waitInUrl }} */ async waitInUrl(urlPart, sec = null) { const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout; return this.page.waitForFunction((urlPart) => { const currUrl = decodeURIComponent(decodeURIComponent(decodeURIComponent(window.location.href))); return currUrl.indexOf(urlPart) > -1; }, urlPart, { timeout: waitTimeout }).catch(async (e) => { const currUrl = await this._getPageUrl(); // Required because the waitForFunction can't return data. if (/Timeout/i.test(e.message)) { throw new Error(`expected url to include ${urlPart}, but found ${currUrl}`); } else { throw e; } }); }