From b9083f911112c3170621acabcf0cb35d869ffcc2 Mon Sep 17 00:00:00 2001 From: Stefan Bohacek Date: Tue, 29 Aug 2023 19:43:22 -0400 Subject: [PATCH] Added loading text. --- public/js/modules/handleUpload.min.js | 20 ++++++++++---------- public/js/modules/handleUpload.min.js.map | 2 +- src/scripts/modules/handleUpload.js | 5 +++++ views/home.handlebars | 3 +++ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/public/js/modules/handleUpload.min.js b/public/js/modules/handleUpload.min.js index f03ebe0..faebbd4 100644 --- a/public/js/modules/handleUpload.min.js +++ b/public/js/modules/handleUpload.min.js @@ -1,21 +1,21 @@ -import sortArrayOfObjects from"/js/modules/sortArrayOfObjects.min.js";import loadEmbedScript from"/js/modules/loadEmbedScript.min.js";import Cookie from"/js/cookies/main.min.js";const cookieManager=new Cookie,fileInput=document.getElementById("file-input"),introElement=document.getElementById("intro"),loadingAnimation=document.getElementById("loading-animation"),resultsElement=document.getElementById("results"),userInfo=document.getElementById("user-info"),userAvatar=document.getElementById("user-avatar"),userDescription=document.getElementById("user-description"),userDataBreakdown=document.getElementById("user-data-breakdown"),chartElement=document.getElementById("chart"),handleUpload=()=>{fileInput&&fileInput.addEventListener("change",async e=>{loadingAnimation.classList.remove("d-none");var s=new FormData;s.set("archive",fileInput.files[0]);s=await(await fetch("/extract-data",{method:"POST",body:s})).json();if(console.log(s),s&&s.data){introElement.classList.add("d-none"),resultsElement.classList.remove("d-none");s=s.data;let e="",t="",o=(s.actor?(e+=` +import sortArrayOfObjects from"/js/modules/sortArrayOfObjects.min.js";import loadEmbedScript from"/js/modules/loadEmbedScript.min.js";import Cookie from"/js/cookies/main.min.js";const cookieManager=new Cookie,fileInput=document.getElementById("file-input"),introElement=document.getElementById("intro"),loadingAnimation=document.getElementById("loading-animation"),loadingText=document.getElementById("loading-text"),resultsElement=document.getElementById("results"),userInfo=document.getElementById("user-info"),userAvatar=document.getElementById("user-avatar"),userDescription=document.getElementById("user-description"),userDataBreakdown=document.getElementById("user-data-breakdown"),chartElement=document.getElementById("chart"),handleUpload=()=>{fileInput&&fileInput.addEventListener("change",async e=>{loadingAnimation.classList.remove("d-none"),loadingText.classList.remove("d-none"),fileInput.disabled=!0;var r=new FormData;r.set("archive",fileInput.files[0]);r=await(await fetch("/extract-data",{method:"POST",body:r})).json();if(console.log(r),r&&r.data){introElement.classList.add("d-none"),resultsElement.classList.remove("d-none");r=r.data;let e="",t="",o=(r.actor?(e+=`

- ${s.actor.name||s.actor.preferredUsername} + ${r.actor.name||r.actor.preferredUsername}

- ${s.actor.summary.replaceAll('class="invisible"',"")} - `,s.actor.attachment&&(e+=` + ${r.actor.summary.replaceAll('class="invisible"',"")} + `,r.actor.attachment&&(e+=` `),userDescription.innerHTML=`
${e}
`,userAvatar.innerHTML=` - - `):(userInfo.remove(),userDescription.remove()),[]),a,n=0;s?.outbox?.orderedItems?o=s.outbox.orderedItems:s?.outbox&&(o=s.outbox),(n=o.length)&&(a=o[0]);var i={weekday:"long",year:"numeric",month:"long",day:"numeric"};s.actor&&(l=moment(s.actor.published),l=moment().diff(l,"days"),t+=` + + `):(userInfo.remove(),userDescription.remove()),[]),a,n=0;r?.outbox?.orderedItems?o=r.outbox.orderedItems:r?.outbox&&(o=r.outbox),(n=o.length)&&(a=o[0]);var i={weekday:"long",year:"numeric",month:"long",day:"numeric"};r.actor&&(l=moment(r.actor.published),l=moment().diff(l,"days"),t+=`

- You created your account on ${new Date(s.actor.published).toLocaleDateString(void 0,i)}, which is ${l.toLocaleString()} day(s) ago. Since then, you posted ${n.toLocaleString()} times, or about ${Math.round(n/l).toLocaleString()} time(s) a day on average. + You created your account on ${new Date(r.actor.published).toLocaleDateString(void 0,i)}, which is ${l.toLocaleString()} day(s) ago. Since then, you posted ${n.toLocaleString()} times, or about ${Math.round(n/l).toLocaleString()} time(s) a day on average.

- `);let r;"mastodon"===s.format?(a&&(i=a?.object?.id||a?.id,l=new URL(i),r=l.protocol+"//"+l.hostname,t=t+` + `);let s;"mastodon"===r.format?(a&&(i=a?.object?.id||a?.id,l=new URL(i),s=l.protocol+"//"+l.hostname,t=t+`

Here's your first post!

@@ -33,5 +33,5 @@ import sortArrayOfObjects from"/js/modules/sortArrayOfObjects.min.js";import loa

Here's what your posting history looks like.

- `,userDataBreakdown.innerHTML=t,"mastodon"===s.format&&loadEmbedScript(r);var l={labels:o.map(e=>moment(e.published||e.createdAt)),datasets:[{label:"Your posts in time",data:o.map((e,t)=>({x:moment(e.published||e.createdAt),y:new Date(e.published||e.createdAt).getHours()})),backgroundColor:["#ff6384"]}]};new Chart(chartElement,{type:"scatter",data:l,options:{scales:{x:{type:"time",position:"bottom",ticks:{beginAtZero:!1,stepSize:10}},y:{ticks:{beginAtZero:!1,display:!1},scaleLabel:{display:!1},minorTickInterval:null}}}})}else loadingAnimation.classList.add("d-none")})};export default handleUpload; + `,userDataBreakdown.innerHTML=t,"mastodon"===r.format&&loadEmbedScript(s);var l={labels:o.map(e=>moment(e.published||e.createdAt)),datasets:[{label:"Your posts in time",data:o.map((e,t)=>({x:moment(e.published||e.createdAt),y:new Date(e.published||e.createdAt).getHours()})),backgroundColor:["#ff6384"]}]};new Chart(chartElement,{type:"scatter",data:l,options:{scales:{x:{type:"time",position:"bottom",ticks:{beginAtZero:!1,stepSize:10}},y:{ticks:{beginAtZero:!1,display:!1},scaleLabel:{display:!1},minorTickInterval:null}}}})}else loadingAnimation.classList.add("d-none"),loadingText.classList.add("d-none"),fileInput.disabled=!1})};export default handleUpload; //# sourceMappingURL=handleUpload.min.js.map diff --git a/public/js/modules/handleUpload.min.js.map b/public/js/modules/handleUpload.min.js.map index 32e8071..6e3d9f1 100644 --- a/public/js/modules/handleUpload.min.js.map +++ b/public/js/modules/handleUpload.min.js.map @@ -1 +1 @@ -{"version":3,"file":"handleUpload.min.js","sources":["modules/handleUpload.js"],"sourcesContent":["import sortArrayOfObjects from \"/js/modules/sortArrayOfObjects.min.js\";\r\nimport loadEmbedScript from \"/js/modules/loadEmbedScript.min.js\";\r\nimport Cookie from \"/js/cookies/main.min.js\";\r\n\r\nconst cookieManager = new Cookie();\r\nconst fileInput = document.getElementById(\"file-input\");\r\nconst introElement = document.getElementById(\"intro\");\r\nconst loadingAnimation = document.getElementById(\"loading-animation\");\r\nconst resultsElement = document.getElementById(\"results\");\r\nconst userInfo = document.getElementById(\"user-info\");\r\nconst userAvatar = document.getElementById(\"user-avatar\");\r\nconst userDescription = document.getElementById(\"user-description\");\r\nconst userDataBreakdown = document.getElementById(\"user-data-breakdown\");\r\nconst chartElement = document.getElementById(\"chart\");\r\n\r\nconst handleUpload = () => {\r\n if (fileInput) {\r\n fileInput.addEventListener(\"change\", async (ev) => {\r\n loadingAnimation.classList.remove('d-none');\r\n const formData = new FormData();\r\n formData.set(\"archive\", fileInput.files[0]);\r\n\r\n const resp = await fetch(\"/extract-data\", {\r\n method: \"POST\",\r\n body: formData,\r\n });\r\n\r\n const response = await resp.json();\r\n console.log(response);\r\n\r\n if (response && response.data) {\r\n introElement.classList.add(\"d-none\");\r\n resultsElement.classList.remove(\"d-none\");\r\n const userData = response.data;\r\n\r\n let userDescriptionHTML = '';\r\n let userDataBreakdownHTML = '';\r\n\r\n if (userData.actor){\r\n userDescriptionHTML += `\r\n

\r\n ${\r\n userData.actor.name || userData.actor.preferredUsername\r\n }\r\n

\r\n ${userData.actor.summary.replaceAll('class=\"invisible\"', \"\")}\r\n `;\r\n \r\n if (userData.actor.attachment) {\r\n userDescriptionHTML += `\r\n \r\n `;\r\n }\r\n \r\n userDescription.innerHTML = `
${userDescriptionHTML}
`;\r\n userAvatar.innerHTML = `\r\n \r\n `;\r\n } else {\r\n userInfo.remove();\r\n userDescription.remove();\r\n }\r\n\r\n let posts = [],\r\n firstPost,\r\n postCount = 0;\r\n\r\n if (userData?.outbox?.orderedItems) {\r\n posts = userData.outbox.orderedItems;\r\n } else if (userData?.outbox){\r\n posts = userData.outbox; \r\n }\r\n \r\n postCount = posts.length;\r\n if (postCount) {\r\n // posts = sortArrayOfObjects(posts, key, desc)\r\n firstPost = posts[0];\r\n }\r\n const options = {\r\n weekday: \"long\",\r\n year: \"numeric\",\r\n month: \"long\",\r\n day: \"numeric\",\r\n };\r\n\r\n if (userData.actor){\r\n const accountCreationDate = moment(userData.actor.published);\r\n const today = moment();\r\n const timeAgo = today.diff(accountCreationDate, 'days');\r\n \r\n \r\n userDataBreakdownHTML += `\r\n

\r\n You created your account on ${new Date(userData.actor.published).toLocaleDateString(\r\n undefined,\r\n options\r\n )}, which is ${timeAgo.toLocaleString()} day(s) ago. Since then, you posted ${postCount.toLocaleString()} times, or about ${(Math.round(postCount/timeAgo)).toLocaleString()} time(s) a day on average.\r\n

\r\n `;\r\n }\r\n\r\n let instanceURL;\r\n\r\n if (userData.format === 'mastodon'){\r\n if (firstPost) {\r\n const postURL = firstPost?.object?.id || firstPost?.id;\r\n const url = new URL(postURL);\r\n instanceURL = `${url.protocol}//${url.hostname}`\r\n\r\n\r\n userDataBreakdownHTML += `\r\n

\r\n Here's your first post!\r\n

\r\n `;\r\n\r\n userDataBreakdownHTML += `\r\n \r\n `;\r\n }\r\n\r\n userDataBreakdownHTML += `\r\n

\r\n And this is what your posting history looks like.\r\n

\r\n `;\r\n } else {\r\n userDataBreakdownHTML += `\r\n

\r\n Here's what your posting history looks like.\r\n

\r\n `;\r\n }\r\n \r\n userDataBreakdown.innerHTML = userDataBreakdownHTML;\r\n\r\n if (userData.format === 'mastodon'){\r\n loadEmbedScript(instanceURL);\r\n }\r\n\r\n // chartOptions.options.legend = {\r\n // display: false\r\n // };\r\n\r\n const data = {\r\n labels: posts.map((post) => moment(post.published || post.createdAt)),\r\n datasets: [\r\n {\r\n label: \"Your posts in time\",\r\n data: posts.map((post, index) => {\r\n return {\r\n x: moment(post.published || post.createdAt),\r\n // y: (new Date(post.published || post.createdAt)).getHour() + 1,\r\n y: (new Date(post.published || post.createdAt)).getHours(),\r\n };\r\n }),\r\n backgroundColor: ['#ff6384']\r\n },\r\n ],\r\n };\r\n\r\n new Chart(chartElement, {\r\n type: \"scatter\",\r\n data : data,\r\n options: {\r\n scales: {\r\n x: \r\n {\r\n type: \"time\",\r\n position: \"bottom\",\r\n ticks: {\r\n beginAtZero: false,\r\n stepSize: 10,\r\n },\r\n },\r\n y: \r\n {\r\n ticks: {\r\n beginAtZero: false,\r\n display: false,\r\n },\r\n scaleLabel: {\r\n display: false,\r\n // labelString: chartEl.dataset.axisLabelData\r\n // labelString: chartEl.dataset.sourceId ? window.ftfDataviz[parseInt( chartEl.dataset.sourceId )].axis_label_title : ''\r\n // labelString: 'Day of the month'\r\n },\r\n minorTickInterval: null,\r\n },\r\n },\r\n\r\n // scales: {\r\n // x: {\r\n // type: 'linear',\r\n // position: 'bottom'\r\n // }\r\n // }\r\n },\r\n });\r\n } else {\r\n loadingAnimation.classList.add('d-none');\r\n }\r\n });\r\n }\r\n};\r\n\r\nexport default handleUpload;\r\n"],"names":["sortArrayOfObjects","loadEmbedScript","Cookie","cookieManager","fileInput","document","getElementById","introElement","loadingAnimation","resultsElement","userInfo","userAvatar","userDescription","userDataBreakdown","chartElement","handleUpload","addEventListener","async","ev","classList","remove","formData","FormData","set","files","response","await","fetch","method","body","json","console","log","data","add","userData","let","userDescriptionHTML","userDataBreakdownHTML","posts","actor","name","preferredUsername","summary","replaceAll","attachment","map","value","replace","join","innerHTML","avatar","firstPost","postCount","outbox","orderedItems","length","options","weekday","year","month","day","accountCreationDate","moment","published","timeAgo","diff","Date","toLocaleDateString","undefined","toLocaleString","Math","round","instanceURL","format","postURL","object","id","url","URL","protocol","hostname","labels","post","createdAt","datasets","label","index","x","y","getHours","backgroundColor","Chart","type","scales","position","ticks","beginAtZero","stepSize","display","scaleLabel","minorTickInterval"],"mappings":"OAAOA,uBAAwB,+CACxBC,oBAAqB,4CACrBC,WAAY,0BAEnB,MAAMC,cAAgB,IAAID,OACpBE,UAAYC,SAASC,eAAe,YAAY,EAChDC,aAAeF,SAASC,eAAe,OAAO,EAC9CE,iBAAmBH,SAASC,eA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MAAO,CACLC,YAAa,CAAA,EACbE,QAAS,CAAA,CACX,EACAC,WAAY,CACVD,QAAS,CAAA,CAIX,EACAE,kBAAmB,IACrB,CACJ,CAQF,CACF,CAAC,CACH,MACE7F,iBAAiBW,UAAUe,IAAI,QAAQ,CAE3C,CAAC,CAEL,iBAEenB"} \ No newline at end of file +{"version":3,"file":"handleUpload.min.js","sources":["modules/handleUpload.js"],"sourcesContent":["import sortArrayOfObjects from \"/js/modules/sortArrayOfObjects.min.js\";\r\nimport loadEmbedScript from \"/js/modules/loadEmbedScript.min.js\";\r\nimport Cookie from \"/js/cookies/main.min.js\";\r\n\r\nconst cookieManager = new Cookie();\r\nconst fileInput = document.getElementById(\"file-input\");\r\nconst introElement = document.getElementById(\"intro\");\r\nconst loadingAnimation = document.getElementById(\"loading-animation\");\r\nconst loadingText = document.getElementById(\"loading-text\");\r\nconst resultsElement = document.getElementById(\"results\");\r\nconst userInfo = document.getElementById(\"user-info\");\r\nconst userAvatar = document.getElementById(\"user-avatar\");\r\nconst userDescription = document.getElementById(\"user-description\");\r\nconst userDataBreakdown = document.getElementById(\"user-data-breakdown\");\r\nconst chartElement = document.getElementById(\"chart\");\r\n\r\nconst handleUpload = () => {\r\n if (fileInput) {\r\n fileInput.addEventListener(\"change\", async (ev) => {\r\n loadingAnimation.classList.remove('d-none');\r\n loadingText.classList.remove('d-none');\r\n fileInput.disabled = true;\r\n const formData = new FormData();\r\n formData.set(\"archive\", fileInput.files[0]);\r\n\r\n const resp = await fetch(\"/extract-data\", {\r\n method: \"POST\",\r\n body: formData,\r\n });\r\n\r\n const response = await resp.json();\r\n console.log(response);\r\n\r\n if (response && response.data) {\r\n introElement.classList.add(\"d-none\");\r\n resultsElement.classList.remove(\"d-none\");\r\n const userData = response.data;\r\n\r\n let userDescriptionHTML = '';\r\n let userDataBreakdownHTML = '';\r\n\r\n if (userData.actor){\r\n userDescriptionHTML += `\r\n

\r\n ${\r\n userData.actor.name || userData.actor.preferredUsername\r\n }\r\n

\r\n ${userData.actor.summary.replaceAll('class=\"invisible\"', \"\")}\r\n `;\r\n \r\n if (userData.actor.attachment) {\r\n userDescriptionHTML += `\r\n \r\n `;\r\n }\r\n \r\n userDescription.innerHTML = `
${userDescriptionHTML}
`;\r\n userAvatar.innerHTML = `\r\n \r\n `;\r\n } else {\r\n userInfo.remove();\r\n userDescription.remove();\r\n }\r\n\r\n let posts = [],\r\n firstPost,\r\n postCount = 0;\r\n\r\n if (userData?.outbox?.orderedItems) {\r\n posts = userData.outbox.orderedItems;\r\n } else if (userData?.outbox){\r\n posts = userData.outbox; \r\n }\r\n \r\n postCount = posts.length;\r\n if (postCount) {\r\n // posts = sortArrayOfObjects(posts, key, desc)\r\n firstPost = posts[0];\r\n }\r\n const options = {\r\n weekday: \"long\",\r\n year: \"numeric\",\r\n month: \"long\",\r\n day: \"numeric\",\r\n };\r\n\r\n if (userData.actor){\r\n const accountCreationDate = moment(userData.actor.published);\r\n const today = moment();\r\n const timeAgo = today.diff(accountCreationDate, 'days');\r\n \r\n \r\n userDataBreakdownHTML += `\r\n

\r\n You created your account on ${new Date(userData.actor.published).toLocaleDateString(\r\n undefined,\r\n options\r\n )}, which is ${timeAgo.toLocaleString()} day(s) ago. Since then, you posted ${postCount.toLocaleString()} times, or about ${(Math.round(postCount/timeAgo)).toLocaleString()} time(s) a day on average.\r\n

\r\n `;\r\n }\r\n\r\n let instanceURL;\r\n\r\n if (userData.format === 'mastodon'){\r\n if (firstPost) {\r\n const postURL = firstPost?.object?.id || firstPost?.id;\r\n const url = new URL(postURL);\r\n instanceURL = `${url.protocol}//${url.hostname}`\r\n\r\n\r\n userDataBreakdownHTML += `\r\n

\r\n Here's your first post!\r\n

\r\n `;\r\n\r\n userDataBreakdownHTML += `\r\n \r\n `;\r\n }\r\n\r\n userDataBreakdownHTML += `\r\n

\r\n And this is what your posting history looks like.\r\n

\r\n `;\r\n } else {\r\n userDataBreakdownHTML += `\r\n

\r\n Here's what your posting history looks like.\r\n

\r\n `;\r\n }\r\n \r\n userDataBreakdown.innerHTML = userDataBreakdownHTML;\r\n\r\n if (userData.format === 'mastodon'){\r\n loadEmbedScript(instanceURL);\r\n }\r\n\r\n // chartOptions.options.legend = {\r\n // display: false\r\n // };\r\n\r\n const data = {\r\n labels: posts.map((post) => moment(post.published || post.createdAt)),\r\n datasets: [\r\n {\r\n label: \"Your posts in time\",\r\n data: posts.map((post, index) => {\r\n return {\r\n x: moment(post.published || post.createdAt),\r\n // y: (new Date(post.published || post.createdAt)).getHour() + 1,\r\n y: (new Date(post.published || post.createdAt)).getHours(),\r\n };\r\n }),\r\n backgroundColor: ['#ff6384']\r\n },\r\n ],\r\n };\r\n\r\n new Chart(chartElement, {\r\n type: \"scatter\",\r\n data : data,\r\n options: {\r\n scales: {\r\n x: \r\n {\r\n type: \"time\",\r\n position: \"bottom\",\r\n ticks: {\r\n beginAtZero: false,\r\n stepSize: 10,\r\n },\r\n },\r\n y: \r\n {\r\n ticks: {\r\n beginAtZero: false,\r\n display: false,\r\n },\r\n scaleLabel: {\r\n display: false,\r\n // labelString: chartEl.dataset.axisLabelData\r\n // labelString: chartEl.dataset.sourceId ? window.ftfDataviz[parseInt( chartEl.dataset.sourceId )].axis_label_title : ''\r\n // labelString: 'Day of the month'\r\n },\r\n minorTickInterval: null,\r\n },\r\n },\r\n\r\n // scales: {\r\n // x: {\r\n // type: 'linear',\r\n // position: 'bottom'\r\n // }\r\n // }\r\n },\r\n });\r\n } else {\r\n loadingAnimation.classList.add('d-none');\r\n loadingText.classList.add('d-none');\r\n fileInput.disabled = false;\r\n }\r\n });\r\n }\r\n};\r\n\r\nexport default handleUpload;\r\n"],"names":["sortArrayOfObjects","loadEmbedScript","Cookie","cookieManager","fileInput","document","getElementById","introElement","loadingAnimation","loadingText","resultsElement","userInfo","userAvatar","userDescription","userDataBreakdown","chartElement","handleUpload","addEventListener","async","ev","classList","remove","disabled","formData","FormData","set","files","response","await","fetch","method","body","json","console","log","data","add","userData","let","userDescriptionHTML","userDataBreakdownHTML","posts","actor","name","preferredUsername","summary","replaceAll","attachment","map","value","replace","join","innerHTML","avatar","firstPost","postCount","outbox","orderedItems","length","options","weekday","year","month","day","accountCreationDate","moment","published","timeAgo","diff","Date","toLocaleDateString","undefined","toLocaleString","Math","round","instanceURL","format","postURL","object","id","url","URL","protocol","hostname","labels","post","createdAt","datasets","label","index","x","y","getHours","backgroundColor","Chart","type","scales","position","ticks","beginAtZero","stepSize","display","scaleLabel","minorTickInterval"],"mappings":"OAAOA,uBAAwB,+CACxBC,oBAAqB,4CACrBC,WAAY,0BAEnB,MAAMC,cAAgB,IAAID,OACpBE,UAAYC,SAASC,eAAe,YAAY,EAChDC,aAAeF,SAASC,eAAe,OAAO,EAC9CE,iBAAmBH,SAASC,eAAe,mBAAmB,EAC9DG,YAAcJ,SAASC,eAAe,cAAc,EACpDI,eAAiBL,SAASC,eAAe,SAAS,EAClDK,SAAWN,SAASC,eAAe,WAAW,EAC9CM,WAAaP,SAASC,eAAe,aAAa,EAClDO,gBAAkBR,SAASC,eAAe,kBAAkB,EAC5DQ,kBAAoBT,SAASC,eAAe,qBAAqB,EACjES,aAAeV,SAASC,eAAe,OAAO,EAE9CU,aAAe,KACfZ,WACFA,UAAUa,iBAAiB,SAAUC,MAAOC,IAC1CX,iBAAiBY,UAAUC,OAAO,QAAQ,EAC1CZ,YAAYW,UAAUC,OAAO,QAAQ,EACrCjB,UAAUkB,SAAW,CAAA,EACrB,IAAMC,EAAW,IAAIC,SACrBD,EAASE,IAAI,UAAWrB,UAAUsB,MAAM,EAAE,EAOpCC,EAAWC,MALJA,MAAMC,MAAM,gBAAiB,CACxCC,OAAQ,OACRC,KAAMR,CACR,CAAC,GAE2BS,KAAK,EAGjC,GAFAC,QAAQC,IAAIP,CAAQ,EAEhBA,GAAYA,EAASQ,KAAM,CAC7B5B,aAAaa,UAAUgB,IAAI,QAAQ,EACnC1B,eAAeU,UAAUC,OAAO,QAAQ,EAClCgB,EAAWV,EAASQ,KAE1BG,I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ASuC,QACX3E,gBAAgB0E,CAAW,EAO7B,IAAMxC,EAAO,CACXiD,OAAQ3C,EAAMO,IAAI,GAAUiB,OAAOoB,EAAKnB,WAAamB,EAAKC,SAAS,CAAC,EACpEC,SAAU,CACR,CACEC,MAAO,qBACPrD,KAAMM,EAAMO,IAAI,CAACqC,EAAMI,KACd,CACLC,EAAGzB,OAAOoB,EAAKnB,WAAamB,EAAKC,SAAS,EAE1CK,EAAG,IAAKtB,KAAKgB,EAAKnB,WAAamB,EAAKC,SAAU,EAAEM,SAAS,CAC3D,EACD,EACDC,gBAAiB,CAAC,UACpB,EAEJ,EAEA,IAAIC,MAAM/E,aAAc,CACtBgF,KAAM,UACN5D,KAAOA,EACPwB,QAAS,CACPqC,OAAQ,CACNN,EACE,CACEK,KAAM,OACNE,SAAU,SACVC,MAAO,CACLC,YAAa,CAAA,EACbC,SAAU,EACZ,CACF,EACFT,EACE,CACEO,MAAO,CACLC,YAAa,CAAA,EACbE,QAAS,CAAA,CACX,EACAC,WAAY,CACVD,QAAS,CAAA,CAIX,EACAE,kBAAmB,IACrB,CACJ,CAQF,CACF,CAAC,CACH,MACE/F,iBAAiBY,UAAUgB,IAAI,QAAQ,EACvC3B,YAAYW,UAAUgB,IAAI,QAAQ,EAClChC,UAAUkB,SAAW,CAAA,CAEzB,CAAC,CAEL,iBAEeN"} \ No newline at end of file diff --git a/src/scripts/modules/handleUpload.js b/src/scripts/modules/handleUpload.js index 4f4e425..bec9b33 100644 --- a/src/scripts/modules/handleUpload.js +++ b/src/scripts/modules/handleUpload.js @@ -6,6 +6,7 @@ const cookieManager = new Cookie(); const fileInput = document.getElementById("file-input"); const introElement = document.getElementById("intro"); const loadingAnimation = document.getElementById("loading-animation"); +const loadingText = document.getElementById("loading-text"); const resultsElement = document.getElementById("results"); const userInfo = document.getElementById("user-info"); const userAvatar = document.getElementById("user-avatar"); @@ -17,6 +18,8 @@ const handleUpload = () => { if (fileInput) { fileInput.addEventListener("change", async (ev) => { loadingAnimation.classList.remove('d-none'); + loadingText.classList.remove('d-none'); + fileInput.disabled = true; const formData = new FormData(); formData.set("archive", fileInput.files[0]); @@ -213,6 +216,8 @@ const handleUpload = () => { }); } else { loadingAnimation.classList.add('d-none'); + loadingText.classList.add('d-none'); + fileInput.disabled = false; } }); } diff --git a/views/home.handlebars b/views/home.handlebars index fee21fd..648e029 100644 --- a/views/home.handlebars +++ b/views/home.handlebars @@ -35,6 +35,9 @@ accept="application/tar, application/tar+gzip" /> +
  • + Please wait... +