Added loading text.
rodzic
8c71a4fc3c
commit
b9083f9111
|
@ -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+=`
|
||||
<p class="mb-0">
|
||||
<strong>${s.actor.name||s.actor.preferredUsername}</strong>
|
||||
<strong>${r.actor.name||r.actor.preferredUsername}</strong>
|
||||
</p>
|
||||
${s.actor.summary.replaceAll('class="invisible"',"")}
|
||||
`,s.actor.attachment&&(e+=`
|
||||
${r.actor.summary.replaceAll('class="invisible"',"")}
|
||||
`,r.actor.attachment&&(e+=`
|
||||
<ul class="list-group">
|
||||
${s.actor.attachment.map(e=>`
|
||||
${r.actor.attachment.map(e=>`
|
||||
<li class="list-group-item">${e.name}: ${e.value.replace('class="invisible"',"")}</li>
|
||||
`).join("")}
|
||||
</ul>
|
||||
`),userDescription.innerHTML=`<div>${e}</div>`,userAvatar.innerHTML=`
|
||||
<img class="img-thumbnail" width="64" height="64" src="data:image/jpg;base64,${s.avatar}">
|
||||
`):(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+=`
|
||||
<img class="img-thumbnail" width="64" height="64" src="data:image/jpg;base64,${r.avatar}">
|
||||
`):(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+=`
|
||||
<p>
|
||||
You created your account on <strong>${new Date(s.actor.published).toLocaleDateString(void 0,i)}</strong>, which is <strong>${l.toLocaleString()} day(s) ago</strong>. Since then, you posted <strong>${n.toLocaleString()} times</strong>, or about ${Math.round(n/l).toLocaleString()} time(s) a day on average.
|
||||
You created your account on <strong>${new Date(r.actor.published).toLocaleDateString(void 0,i)}</strong>, which is <strong>${l.toLocaleString()} day(s) ago</strong>. Since then, you posted <strong>${n.toLocaleString()} times</strong>, or about ${Math.round(n/l).toLocaleString()} time(s) a day on average.
|
||||
</p>
|
||||
`);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+`
|
||||
<p>
|
||||
Here's your <a href="${i}" target="_blank">first post</a>!
|
||||
</p>
|
||||
|
@ -33,5 +33,5 @@ import sortArrayOfObjects from"/js/modules/sortArrayOfObjects.min.js";import loa
|
|||
<p>
|
||||
Here's what your posting history looks like.
|
||||
</p>
|
||||
`,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
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
accept="application/tar, application/tar+gzip"
|
||||
/>
|
||||
</li>
|
||||
<li id="loading-text" class="mt-4 d-none">
|
||||
Please wait...
|
||||
</li>
|
||||
</ol>
|
||||
</p>
|
||||
<p id="loading-animation" class="d-none mt-4 card-text placeholder-wave">
|
||||
|
|
Ładowanie…
Reference in New Issue