blob: 6e320b07f3a6fb2eac4b709533181b01269ed6ff [file] [log] [blame]
{
"version": 3,
"sources": ["fetch.ts"],
"sourcesContent": ["/*!\n * @license\n * Copyright 2020 The Go Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\nconst fetchButton = document.querySelector('.js-fetchButton');\nif (fetchButton) {\n fetchButton.addEventListener('click', e => {\n e.preventDefault();\n fetchPath();\n });\n}\n\nasync function fetchPath() {\n const fetchMessageEl = document.querySelector<HTMLHeadingElement>('.js-fetchMessage');\n const fetchMessageSecondary = document.querySelector<HTMLParagraphElement>(\n '.js-fetchMessageSecondary'\n );\n const fetchButton = document.querySelector<HTMLButtonElement>('.js-fetchButton');\n const fetchLoading = document.querySelector<HTMLDivElement>('.js-fetchLoading');\n if (!(fetchMessageEl && fetchMessageSecondary && fetchButton && fetchLoading)) {\n return;\n }\n fetchMessageEl.textContent = `Fetching ${fetchMessageEl.dataset.path}`;\n fetchMessageSecondary.textContent =\n 'Feel free to navigate away and check back later, we\u2019ll keep working on it!';\n fetchButton.style.display = 'none';\n fetchLoading.style.display = 'block';\n\n const response = await fetch(`/fetch${window.location.pathname}`, { method: 'POST' });\n if (response.ok) {\n window.location.reload();\n return;\n }\n const responseText = await response.text();\n fetchLoading.style.display = 'none';\n fetchMessageSecondary.textContent = '';\n const responseTextParsedDOM = new DOMParser().parseFromString(responseText, 'text/html');\n fetchMessageEl.innerHTML = responseTextParsedDOM.documentElement.textContent ?? '';\n}\n"],
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAOA,KAAM,aAAc,SAAS,cAAc,mBAC3C,AAAI,aACF,YAAY,iBAAiB,QAAS,GAAK,CACzC,EAAE,iBACF,cAIJ,0BAA2B,CACzB,KAAM,GAAiB,SAAS,cAAkC,oBAC5D,EAAwB,SAAS,cACrC,6BAEI,EAAc,SAAS,cAAiC,mBACxD,EAAe,SAAS,cAA8B,oBAC5D,GAAI,CAAE,IAAkB,GAAyB,GAAe,GAC9D,OAEF,EAAe,YAAc,YAAY,EAAe,QAAQ,OAChE,EAAsB,YACpB,kFACF,EAAY,MAAM,QAAU,OAC5B,EAAa,MAAM,QAAU,QAE7B,KAAM,GAAW,KAAM,OAAM,SAAS,OAAO,SAAS,WAAY,CAAE,OAAQ,SAC5E,GAAI,EAAS,GAAI,CACf,OAAO,SAAS,SAChB,OAEF,KAAM,GAAe,KAAM,GAAS,OACpC,EAAa,MAAM,QAAU,OAC7B,EAAsB,YAAc,GACpC,KAAM,GAAwB,GAAI,aAAY,gBAAgB,EAAc,aAC5E,EAAe,UAAY,EAAsB,gBAAgB,aAAe",
"names": []
}