async handleSignoutSubmit(event) { event.preventDefault() // Save current URL so user is redirected back here after signing out const cookies = new Cookies() cookies.set('redirect_url', window.location.pathname, { path: '/' }) await NextAuth.signout() Router.push('/') }
function baseUrl() { let output = pageLocationOrigin() + location.pathname; if (output[output.length - 1] !== '/') { output = output.split('/'); output.pop(); output = output.join('/'); } return output; }
async componentDidMount() { const session = await NextAuth.init({force: true}) this.setState({ session: session, isSignedIn: (session.user) ? true : false }) // If the user bounces off to link/unlink their account we want them to // land back here after signing in with the other service / unlinking. const cookies = new Cookies() cookies.set('redirect_url', window.location.pathname, { path: '/' }) this.getProfile() }
router.beforeEach((to, from, next) => { const components = router.getMatchedComponents(to).map( c => isFunc(c) && isNil(c.cid) ? c() : c ) Promise.all(components) .then(() => next()) .catch(err => { // reload page if a component failed to load if (err.request && to.path !== window.location.pathname) { const fullPathWithPrefix = (config.pathPrefix ?? '') + to.fullPath window.location.assign(fullPathWithPrefix) } else { next(err) } }) })
const clippedContentResponse = (title, html, imageSizes, anchorNames, stylesheets) => { return { name: shouldSendToJoplin ? 'sendContentToJoplin' : 'clippedContent', title: title, html: html, base_url: baseUrl(), url: pageLocationOrigin() + location.pathname + location.search, parent_id: command.parent_id, tags: command.tags || '', image_sizes: imageSizes, anchor_names: anchorNames, source_command: Object.assign({}, command), convert_to: convertToMarkup, stylesheets: stylesheets, }; }
handleSubmit(event) { event.preventDefault() if (!this.state.email) return this.setState({ submitting: true }) // Save current URL so user is redirected back here after signing in const cookies = new Cookies() cookies.set('redirect_url', window.location.pathname, { path: '/' }) NextAuth.signin(this.state.email) .then(() => { Router.push(`/auth/check-email?email=${this.state.email}`) }) .catch(err => { Router.push(`/auth/error?action=signin&type=email&email=${this.state.email}`) }) }
/** * Makes a URL, preserving querystring ("search") parameters. * * @param {string} s * @returns {string} A new URL. */ function makeUrl( s ) { var search = window.location.search; // Remove previous grep query parameter if present if ( search ) { search = search.replace( /[?&]grep=[^&\s]*/g, '' ).replace( /^&/, '?' ); } return ( window.location.pathname + ( search ? search + '&' : '?' ) + 'grep=' + encodeURIComponent( escapeRe( s ) ) ); }
fetch(to) .then(res => { if (res.code === 404) { next({ name: '*', params: { 0: to.path }}) } else { setResults(to.path, res) next() } }) .catch(err => { if (err.code === 'MODULE_NOT_FOUND' || err.code === 404) { console.error(err) next({ name: '*', params: { 0: to.path } }) } else if (err.code === 'INVALID_HASH' && to.path !== window.location.pathname) { const fullPathWithPrefix = (config.pathPrefix ?? '') + to.fullPath window.location.assign(fullPathWithPrefix) } else { formatError(err, to) next(err) } })
window.addEventListener('WebComponentsReady', () => { let url = new URL(window.location) let room = url.searchParams.get('room') let force = url.searchParams.get('force') if (window.location.search && getChromeVersion(force) && room) { require('./components') container.innerHTML = `${help}<roll-call call="${room}"></roll-call>` dragDrop('body', files => { document.querySelector('roll-call').serveFiles(files) }) } else { container.innerHTML = welcome if (!getChromeVersion(force)) { document.querySelector('span.start-text').innerHTML = onlyChrome } each(document.querySelectorAll('welcome-message span'), elem => { elem.onclick = () => { let room if (elem.id === 'start-party') room = 'party' else room = random() window.location = window.location.pathname + '?room=' + room } }) } })
pathname = window.location.pathname;
async toggleModal(e) { if (e) e.preventDefault() // Save current URL so user is redirected back here after signing in if (this.state.modal !== true) { const cookies = new Cookies() cookies.set('redirect_url', window.location.pathname, { path: '/' }) } this.setState({ providers: this.state.providers || await NextAuth.providers(), modal: !this.state.modal }) }
var langElements = langPickerElement.querySelectorAll('button') var currentLang = window.location.pathname.split('/')[1] || 'en' var currentLangElement = null el.addEventListener('click', function (e) { var newLocale = (e.target && e.target.dataset && e.target.dataset.lang) || 'en' window.location.assign(window.location.pathname.replace(/\/[a-zA-Z-]+/, '/' + newLocale)) }) } else {
/** * Retrieve markup for page links * * @param {array} pages - A list of page objects * @return {array} - Markup containing the page links */ _getPages(pages) { let pathname = ''; if (window.location !== undefined) { pathname = window.location.pathname; } return pages.map(page => { let url = `${page.url}`, active = pathname === url; return ( <Link key={url} className={`sidebar-mobile__page sidebar-mobile__section-child ${active ? 'sidebar-mobile__page--active' : ''}`} to={url} onClick={this.props.toggle.bind(null, false)}> {page.title} </Link> ); }); }
router.beforeEach((to, from, next) => { const components = router.getMatchedComponents(to).map( c => isFunc(c) && isNil(c.cid) ? c() : c ) Promise.all(components) .then(() => next()) .catch(err => { // reload page if a component failed to load if (err.request && to.path !== window.location.pathname) { const fullPathWithPrefix = (config.pathPrefix ?? '') + to.fullPath window.location.assign(fullPathWithPrefix) } else { next(err) } }) })
fetch(to) .then(res => { if (res.code === 404) { next({ name: '*', params: { 0: to.path }}) } else { setResults(to.path, res) next() } }) .catch(err => { if (err.code === 'MODULE_NOT_FOUND' || err.code === 404) { console.error(err) next({ name: '*', params: { 0: to.path } }) } else if (err.code === 'INVALID_HASH' && to.path !== window.location.pathname) { const fullPathWithPrefix = (config.pathPrefix ?? '') + to.fullPath window.location.assign(fullPathWithPrefix) } else { formatError(err, to) next(err) } })