xhluca's picture
Add files using upload-large-folder tool
81956aa verified
raw
history blame
24.2 kB
<head data-webtasks-id="ce5993df-7095-49c8"><title data-webtasks-id="d266b62f-c95b-41ff">Todoist</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" data-webtasks-id="bdc41c49-34aa-4126"><meta http-equiv="X-UA-Compatible" content="IE=edge" data-webtasks-id="e5d4b2ba-ec12-4ede"><meta property="og:image" content="/assets/images/968d99236e2536919d6d14ca13d25930.jpg" data-webtasks-id="3eda9fd0-ddb0-4f6a"><meta property="og:image:secure_url" content="/assets/images/968d99236e2536919d6d14ca13d25930.jpg" data-webtasks-id="1ea68055-44f5-4c31"><meta name="apple-itunes-app" content="app-id=572688855" data-webtasks-id="0f3bb196-5031-486e"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" data-webtasks-id="e50a5a50-37c1-4dad"><meta name="theme-color" content="#C24F3D" data-webtasks-id="de63632f-b094-4688"><script async="" defer="" src="https://www.googletagmanager.com/gtm.js?id=GTM-WQB95PC&amp;gtm_auth=BcR4sNCoRjSMVR5_xQ5zQA&amp;gtm_preview=env-1&amp;gtm_cookies_win=x" nonce="" data-webtasks-id="646d286a-d470-481f"></script><script nonce="" data-webtasks-id="8f4e5131-b268-41b6">class CdnFailbackWatchdog {
TYPE_CSS = 'css'
TYPE_JS = 'js'
MAX_CDN_FALLBACK = 2
ASSET_TIMEOUT = 15 * 1000 // 15 seconds
SEARCH_PARAM = 'cdn_fallback'
constructor(console) {
this.console = console
this.isReloading = false
this.tracked = 0
this.timeout = null
this.successes = []
this.failures = []
this.params = new URLSearchParams(window.location.search)
this.jsFilesCnt = 0
this.cssFilesCnt = 0
this.cdns = null
this.cdn = ''
this.console.log('[watchdog] init')
}
saveLastTriedCDN(value) {
// store in localStorage a value 'x', otherwise log that it was not possible
try {
this.console.log('[watchdog] saving last tried CDN: ' + value)
localStorage.setItem('td-cdn', value)
localStorage.setItem('td-cdn-ttl', Date.now() + 1000 * 60 * 60 * 24 * 30) // 30 days
} catch (e) {
this.console.log('[watchdog] failed to save working CDN in localStorage')
}
}
getLastTriedCDN() {
const value = localStorage.getItem('td-cdn')
const ttl = localStorage.getItem('td-cdn-ttl')
if (value && ttl && parseInt(ttl, 10) > Date.now()) {
this.console.log('[watchdog] retrieving last tried CDN: ' + value)
return value
}
this.clearLastTriedCDN()
return null
}
clearLastTriedCDN() {
try {
this.console.log('[watchdog] clearing last tried CDN')
localStorage.removeItem('td-cdn')
localStorage.removeItem('td-cdn-ttl')
} catch (e) {
this.console.log('[watchdog] failed to clear working CDN in localStorage')
}
}
getCdns() {
if (this.cdns == null) {
const cdnsStr =
(document &&
document.documentElement &&
document.documentElement.getAttribute('data-cdns')) ||
'/'
this.cdns = cdnsStr.split('|')
}
return this.cdns
}
selectCDN() {
if (this.cdn) {
this.console.log('[watchdog] using CDN from cache: ' + this.cdn)
return this.cdn
}
const cdns = this.getCdns()
// Check if we have a cached CDN
// If we can't access it, use the last CDN in the list
let lastTriedCDN
try {
lastTriedCDN = this.getLastTriedCDN()
} catch (e) {
this.console.log('[watchdog] failed to get last tried CDN')
this.cdn = cdns[cdns.length - 1]
return this.cdn
}
// If the cached CDN is not in the list, clear it
if (lastTriedCDN && !cdns.includes(lastTriedCDN)) {
lastTriedCDN = null
this.clearLastTriedCDN()
}
// If we have a cached CDN, use it
// Otherwise, use the current load attempt to get the CDN
if (lastTriedCDN) {
this.cdn = lastTriedCDN
} else {
const loadAttempt = this.getLoadAttempt()
const cdnIndex = Math.min(loadAttempt, cdns.length - 1)
this.cdn = cdns[cdnIndex]
}
// ensure CDN always end in trailing /
if (!this.cdn.endsWith('/')) {
this.cdn += '/'
}
this.saveLastTriedCDN(this.cdn)
return this.cdn
}
getLoadAttempt() {
const cdnFallback = this.params.get(this.SEARCH_PARAM)
return (cdnFallback && parseInt(cdnFallback, 10)) || 0
}
track(assetType) {
this.tracked += 1
if (assetType === this.TYPE_JS) {
this.jsFilesCnt += 1
} else if (assetType === this.TYPE_CSS) {
this.cssFilesCnt += 1
}
if (this.timeout != null) {
clearTimeout(this.timeout)
this.timeout = null
}
this.timeout = setTimeout(this.reloadIfIssue.bind(this, true), this.ASSET_TIMEOUT)
}
parse(element) {
element.onload = null
element.onerror = null
if (element) {
if (element.href && element.rel && element.rel === 'stylesheet') {
return {
src: element.href,
type: this.TYPE_CSS,
}
}
if (element.src && element.nodeName.toLowerCase() === 'script') {
return {
src: element.src,
type: this.TYPE_JS,
}
}
}
return null
}
ok(element) {
const parsedAsset = this.parse(element)
if (parsedAsset) {
this.successes.push(parsedAsset)
this.reloadIfIssue()
}
}
err(element) {
const parsedAsset = this.parse(element)
if (parsedAsset) {
this.failures.push({
...parsedAsset,
reason: 'Failed to load from CDN',
})
this.reloadIfIssue()
}
}
haveAssetsLoaded(ignoreTracking = false) {
if (ignoreTracking) {
this.console.warn(
`Ignoring asset checks, because something timed out. Tracked: ${this.tracked}; Successes: ${this.successes.length}; Failures: ${this.failures.length}`,
)
return false
}
if (this.tracked > this.successes.length + this.failures.length) {
return null
}
if (this.timeout != null) {
this.console.log(
`[watchdog] All assets have reported back; successes: ${this.successes.length}; failures: ${this.failures.length}`,
)
clearTimeout(this.timeout)
this.timeout = null
}
if (this.failures.length > 0) {
this.logFailures()
return false
}
const anySuccessfulCss =
this.cssFilesCnt == 0 ||
this.successes.findIndex((asset) => asset.type === this.TYPE_CSS) > -1
const anySuccessfulJS =
this.jsFilesCnt == 0 ||
this.successes.findIndex((asset) => asset.type === this.TYPE_JS) > -1
if (anySuccessfulCss && anySuccessfulJS) {
return true
}
this.console.warn(
`CSS or JS is missing from loaded assets; CSS: ${anySuccessfulCss}; JS: ${anySuccessfulJS}`,
)
return false
}
showTroubleLoading() {
try {
document.querySelector('.cdn-failback-error').classList.add('cdn-failback-error--show')
} catch (e) {
// do nothing
}
}
logFailures() {
this.console.group('The following assets had issues loading:')
const messages = this.failures.map((asset) => `${asset.src}: ${asset.reason}`)
messages.forEach((msg) => this.console.warn(msg))
this.console.groupEnd()
}
reloadIfIssue(ignoreTracking = false) {
const result = this.haveAssetsLoaded(ignoreTracking)
if (result === null || result === true) {
return
}
if (result === false) {
// ensures next attempt won't use the same CDN, as failed this time.
this.clearLastTriedCDN()
}
if (this.isReloading) {
this.console.warn(
'[RELOAD] Detected more issues loading assets, but we are already preparing to reload so no need to do anything',
)
return
}
if (window.navigator.onLine === false) {
this.console.warn("[RELOAD] Need to reload, but not online; won't try reloading")
this.showTroubleLoading()
return
}
const cdnFallback = this.getLoadAttempt() + 1
const maxCdnFallback = Math.min(this.getCdns().length, this.MAX_CDN_FALLBACK)
if (cdnFallback > maxCdnFallback) {
this.console.warn("[RELOAD] Hit maximum reload attempts, won't try reloading anymore")
this.showTroubleLoading()
return
}
let timeoutId = null
this.isReloading = true
const reloadClient = () => {
this.params.set(this.SEARCH_PARAM, cdnFallback)
this.console.warn('[RELOAD] Reloading client with URL: ' + this.params.toString())
window.clearTimeout(timeoutId)
window.location.search = this.params.toString()
}
timeoutId = window.setTimeout(
reloadClient.bind(this),
5 * 1000, // 5 seconds
)
this.cleanupServiceWorkers().then(reloadClient).catch(reloadClient)
}
cleanupServiceWorkers() {
const cleanupPromises = []
if ('serviceWorker' in navigator && window && window.caches != null) {
cleanupPromises.push(
new Promise((resolve) => {
window.caches
.keys()
.then((cacheKeys) =>
Promise.all(
cacheKeys.map((cacheKey) => window.caches.delete(cacheKey)),
),
)
.then(() => {
this.console.warn('[RELOAD] Removed all Service Worker caches')
resolve()
})
.catch((t) => {
this.console.warn(
'[RELOAD] Service worker cache keys could not be removed: ' +
t.message,
),
resolve()
})
}),
)
}
// unregister service worker
cleanupPromises.push(
new Promise((resolve) => {
navigator.serviceWorker
.getRegistration('/app/service-worker.js')
.then((swReg) => {
if (swReg) {
swReg
.unregister()
.then(() => {
this.console.warn('[RELOAD] Service worker unregistered')
resolve()
})
.catch((t) => {
this.console.warn(
'[RELOAD] Service worker could not be unregistered: ' +
t.message,
)
resolve()
})
} else {
resolve()
}
})
.catch((e) => {
this.console.warn(
'[RELOAD] Service worker could not be unregistered: ' + e.message,
)
resolve()
})
}),
)
return Promise.all(cleanupPromises)
}
}
function getPathnameFromAsset(asset) {
if (asset.startsWith('/')) {
return asset.slice(1)
}
try {
return new URL(asset).pathname.slice(1)
} catch {
return asset
}
}
function cdnLoadScript(tagName = 'head') {
return (asset) => {
window.watchdog.track('js')
const scriptE = document.createElement('script')
scriptE.onload = () => {
window.watchdog.ok(scriptE)
}
scriptE.onerror = () => {
window.watchdog.err(scriptE)
}
scriptE.src = window.watchdog.cdn + getPathnameFromAsset(asset)
scriptE.async = false
scriptE.crossOrigin = 'anonymous'
scriptE.nonce = document.documentElement.getAttribute('data-csp-nonce') || 'unknown-nonce'
document.getElementsByTagName(tagName)[0].appendChild(scriptE)
}
}
function cdnLoadLink(tagName = 'head') {
return (asset) => {
window.watchdog.track('css')
const linkE = document.createElement('link')
linkE.onload = () => {
window.watchdog.ok(linkE)
}
linkE.onerror = () => {
window.watchdog.err(linkE)
}
linkE.href = window.watchdog.cdn + getPathnameFromAsset(asset)
linkE.async = false
linkE.crossOrigin = 'anonymous'
linkE.rel = 'stylesheet'
linkE.nonce = document.documentElement.getAttribute('data-csp-nonce') || 'unknown-nonce'
document.getElementsByTagName(tagName)[0].appendChild(linkE)
}
}
window.watchdog = new CdnFailbackWatchdog(window.console)
window.watchdog.selectCDN()
window.cdnLoadScript = cdnLoadScript
window.cdnLoadLink = cdnLoadLink</script><script nonce="" data-webtasks-id="ca2d59e5-4f30-46db">cdnLoadScript()("init-theme.424d6e9aca3f1406ddd0052b67231394.js");
cdnLoadScript()("checkUnsupportedBrowser.c96c50bcdd3a49f39a83b159f26b5b3c.js");
cdnLoadScript()("/assets/runtime.8ce64929dd0addb55bb5787d1d866de2.js");</script><script src="https://todoist.b-cdn.net/init-theme.424d6e9aca3f1406ddd0052b67231394.js" crossorigin="anonymous" data-webtasks-id="00f88984-10d9-4520"></script><script src="https://todoist.b-cdn.net/checkUnsupportedBrowser.c96c50bcdd3a49f39a83b159f26b5b3c.js" crossorigin="anonymous" data-webtasks-id="e25b6147-a171-4549"></script><script src="https://todoist.b-cdn.net/assets/runtime.8ce64929dd0addb55bb5787d1d866de2.js" crossorigin="anonymous" data-webtasks-id="10546550-c541-4686"></script><script nonce="" data-webtasks-id="53365748-05ec-4680">cdnLoadLink()("/assets/vendor~add~app~authentication~275fb47b.3bddbc7f0e2749783e460b54c1f6fab0.css");
cdnLoadLink()("/assets/vendor~add~app~253ae210.cecc6c91b0559c218c324a51b600ce1c.css");
cdnLoadLink()("/assets/app~d0ae3f07.2415fea43ce14de494a1bb15c0e0377f.css");
cdnLoadLink()("/assets/app~5a11b65b.789955acb2b0d1b96ce54fa7f1bdf022.css");
cdnLoadLink()("/assets/app~c714bc7b.3b9a3320fb1350deb46a6ab033b25dc2.css");
cdnLoadLink()("/assets/app~31e116db.a721f48b197617be0b1fe1f4a501a5f9.css");
cdnLoadLink()("/assets/app~fc66dfb5.801c0ac5f0ac081b675a6e6ffe084595.css");
cdnLoadLink()("/assets/app~2cb4426d.f8c583acb830ed5a9238cd39ea4c2b78.css");</script><link href="https://todoist.b-cdn.net/assets/vendor~add~app~authentication~275fb47b.3bddbc7f0e2749783e460b54c1f6fab0.css" crossorigin="anonymous" rel="stylesheet" data-webtasks-id="fe285e1a-4cc2-4fea"><link href="https://todoist.b-cdn.net/assets/vendor~add~app~253ae210.cecc6c91b0559c218c324a51b600ce1c.css" crossorigin="anonymous" rel="stylesheet" data-webtasks-id="3e73251d-9d49-4bc7"><link href="https://todoist.b-cdn.net/assets/app~d0ae3f07.2415fea43ce14de494a1bb15c0e0377f.css" crossorigin="anonymous" rel="stylesheet" data-webtasks-id="3df97913-2434-416b"><link href="https://todoist.b-cdn.net/assets/app~5a11b65b.789955acb2b0d1b96ce54fa7f1bdf022.css" crossorigin="anonymous" rel="stylesheet" data-webtasks-id="4cbd7597-e91d-4df2"><link href="https://todoist.b-cdn.net/assets/app~c714bc7b.3b9a3320fb1350deb46a6ab033b25dc2.css" crossorigin="anonymous" rel="stylesheet" data-webtasks-id="43d2c805-9348-424b"><link href="https://todoist.b-cdn.net/assets/app~31e116db.a721f48b197617be0b1fe1f4a501a5f9.css" crossorigin="anonymous" rel="stylesheet" data-webtasks-id="54b8c0bc-8d19-4666"><link href="https://todoist.b-cdn.net/assets/app~fc66dfb5.801c0ac5f0ac081b675a6e6ffe084595.css" crossorigin="anonymous" rel="stylesheet" data-webtasks-id="04b0d1d6-298a-487b"><link href="https://todoist.b-cdn.net/assets/app~2cb4426d.f8c583acb830ed5a9238cd39ea4c2b78.css" crossorigin="anonymous" rel="stylesheet" data-webtasks-id="3211440d-c3a4-40ee"><script async="" src="https://www.google-analytics.com/analytics.js" data-webtasks-id="6cb284d8-3f25-4ef7"></script><style data-webtasks-id="56dfbc63-ef91-427f">.cdn-failback-error {
display: none;
flex-direction: column;
justify-content: center;
align-items: center;
position: fixed;
height: calc(100% - 36px);
width: calc(100% - 36px);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
'Apple Color Emoji', Helvetica, Arial, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';
padding: 18px;
background-color: white;
z-index: 1;
}
.cdn-failback-error h1 {
font-size: 24px;
}
.cdn-failback-error p {
font-size: 16px;
}
.cdn-failback-error p a {
color: #d1453b !important;
}
.cdn-failback-error.cdn-failback-error--show {
display: flex;
}</style><style data-webtasks-id="632c38a8-73f6-40b0">body {
margin: 0;
}
.loading_screen {
position: fixed;
display: flex;
justify-content: center;
height: 100%;
width: 100%;
}
.loading_screen--loader {
width: 100px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.loading_screen--logo {
margin-bottom: 32px;
}
.loading_screen--spinner {
animation-name: circular-spinner;
animation-duration: 1.2s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.theme_dark .loading_screen {
background-color: #1f1f1f;
}
.theme_dark .loading_screen--logo .logo_bg {
fill: rgba(255, 255, 255, 0.87);
}
.theme_dark .loading_screen--logo .logo_stripe {
fill: #1f1f1f;
}
.theme_dark .loading_screen--spinner .ring_thumb {
fill: rgba(255, 255, 255, 0.87);
}
.theme_dark .loading_screen--spinner .ring_track {
fill: rgba(255, 255, 255, 0.4);
}
@keyframes circular-spinner {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}</style><script nonce="" data-webtasks-id="bb55e368-bdcc-4f2a">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.defer=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl+'&gtm_auth=BcR4sNCoRjSMVR5_xQ5zQA&gtm_preview=env-1&gtm_cookies_win=x';
var n=d.querySelector('[nonce]');n&&j.setAttribute('nonce',n.nonce||n.getAttribute('nonce'));f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-WQB95PC');</script><meta name="apple-mobile-web-app-title" content="Todoist" data-webtasks-id="f4dbbab9-48e3-492c"><meta name="apple-mobile-web-app-capable" content="yes" data-webtasks-id="05006ed6-309e-4778"><meta name="apple-mobile-web-app-status-bar-style" content="default" data-webtasks-id="a64ece55-49a6-4ab1"><meta name="theme-color" content="#C24F3D" data-webtasks-id="ad2b5b02-ec41-439e"><link rel="apple-touch-startup-image" sizes="1024x1024" href="/app/manifest_icons/icon_1024x1024.098d1a14e2f871db82d8a2392d59b587.png" data-webtasks-id="6e32a510-da2a-4de3"><link rel="apple-touch-icon" sizes="1024x1024" href="/app/manifest_icons/icon_1024x1024.098d1a14e2f871db82d8a2392d59b587.png" data-webtasks-id="c1b180e0-b0b7-4d78"><link rel="apple-touch-icon" sizes="180x180" href="/app/manifest_icons/icon_180x180.d0c3ef3c6be29a9ca57ead5171bbebc4.png" data-webtasks-id="4dfc71d2-d06c-4e60"><link rel="apple-touch-icon" sizes="167x167" href="/app/manifest_icons/icon_167x167.3a26fccf02024d9e908aa61a168c04b6.png" data-webtasks-id="99ca58a9-4877-416a"><link rel="apple-touch-icon" sizes="152x152" href="/app/manifest_icons/icon_152x152.749dc17e04c34f6e3ade0c6ec90a827c.png" data-webtasks-id="0e104243-2021-4a74"><link rel="apple-touch-icon" sizes="120x120" href="/app/manifest_icons/icon_120x120.4a19b1dbc4514d6e3e3929c28f912cc8.png" data-webtasks-id="399dd716-e67c-4954"><link rel="manifest" href="/app/manifest.48149c9f0c601e29a9554640f7bf5b4d.json" data-webtasks-id="f9a98fb8-9b16-4715"></head><body data-webtasks-id="65e0f9f7-e2e2-4424"><div class="cdn-failback-error" data-webtasks-id="52bf2bc4-d7ad-44c4"><svg class="loading_screen--logo" width="64" height="64" xmlns="http://www.w3.org/2000/svg" data-webtasks-id="85cc1bc5-c545-46b2"><g fill="none" fill-rule="evenodd" data-webtasks-id="5d375aab-6ae1-4982"><path class="logo_bg" d="M56.000016 0h-48c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V8c0-4.4-3.6-8-8-8" fill="#E44332" data-webtasks-id="36d3fc9f-1c37-4e8f"></path><g class="logo_stripe" fill="#FFF" data-webtasks-id="11d5cbfd-bafb-4c33"><path d="M13.672368 29.985936c1.1304-.65152 25.34368-14.58496 25.89952-14.90592.5544-.32016.58224-1.30224-.03824-1.65632-.62096-.35408-1.79984-1.02368-2.23856-1.28048-.44656-.26048-1.24976-.40528-1.99472.02384-.30928.1784-21.00256 12.0768-21.69424
12.46992-.82784.47072-1.85248.4768-2.67744-.0008-.65152-.37696-10.92864-6.3488-10.92864-6.3488v5.39712c2.66016 1.54912 9.2744 5.40128 10.87744 6.30624.95664.54016 1.87232.52688 2.79488-.0048" data-webtasks-id="2452471c-100a-4262"></path><path d="M13.672368 40.76952c1.1304-.65152 25.34368-14.58496 25.89952-14.90592.5544-.32.58224-1.30224-.03824-1.65632-.62096-.35408-1.79984-1.02368-2.23856-1.28048-.44656-.26048-1.24976-.40528-1.99472.02384-.30928.1784-21.00256 12.0768-21.69424
12.46992-.82784.47072-1.85248.4768-2.67744-.0008-.65152-.37696-10.92864-6.3488-10.92864-6.3488v5.39712c2.66016 1.54912 9.2744 5.40128 10.87744 6.30624.95664.54016 1.87232.52688 2.79488-.0048" data-webtasks-id="b563565d-e536-404b"></path><path d="M13.672368 51.55312c1.1304-.65152 25.34368-14.58496 25.89952-14.90592.5544-.32.58224-1.30224-.03824-1.65632-.62096-.35408-1.79984-1.02368-2.23856-1.28048-.44656-.26048-1.24976-.40528-1.99472.02384-.30928.1784-21.00256 12.0768-21.69424
12.46992-.82784.47072-1.85248.4768-2.67744-.0008-.65152-.37696-10.92864-6.3488-10.92864-6.3488v5.39712c2.66016 1.54912 9.2744 5.40128 10.87744 6.30624.95664.54016 1.87232.52688 2.79488-.0048" data-webtasks-id="d2faa1d1-800a-4cb2"></path></g></g></svg></div></body>