Added post milestones where supported.
rodzic
d85aed0c58
commit
c44e6bbb7f
|
@ -0,0 +1,2 @@
|
|||
const getDomain=e=>{return new URL(e).hostname};export default getDomain;
|
||||
//# sourceMappingURL=getDomain.min.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"getDomain.min.js","sources":["modules/getDomain.js"],"sourcesContent":["const getDomain = (url) => {\n let domain = (new URL(url));\n return domain.hostname;\n};\n\nexport default getDomain;\n"],"names":["getDomain","URL","url","hostname"],"mappings":"AAAA,MAAMA,UAAY,IAEd,OADa,IAAKC,IAAIC,CAAI,EACZC,QAClB,iBAEeH"}
|
|
@ -1,2 +0,0 @@
|
|||
import getUrlParams from"/js/modules/getUrlParams.min.js";import Cookie from"/js/cookies/main.min.js";const cookieManager=new Cookie,signinForm=document.getElementById("signin-form"),instance=document.getElementById("instance"),signinButton=document.getElementById("signin-btn"),toggleFormElements=e=>{"true"===e.dataset.enabled?(instance.disabled=!0,signinButton.disabled=!0,signinButton.innerHTML="Loading...",e.dataset.enabled="false"):(instance.disabled=!1,signinButton.disabled=!1,signinButton.innerHTML="Sign in",e.dataset.enabled="true")},handleSignin=()=>{if(signinForm.addEventListener("submit",async e=>{e.preventDefault(),toggleFormElements(signinForm);e=await(await fetch("https://fediverse-info.stefanbohacek.dev/node-info?domain="+instance.value)).json();e&&e.software?window.location.href=`https://auth.stefanbohacek.dev/?method=fediverse&instance=${instance.value}&scope=read:accounts&app=localhost-3000&platform=`+e.software:(alert("This doesn't look like a fediverse instance."),toggleFormElements(signinForm))}),"/"===window.location.pathname){var e=getUrlParams(),n=cookieManager.get("fpusr"),t=document.getElementById("popover-start");if(t&&t.classList.add("show"),!e.logout&&n){const{instance,platform:i,token:a}=JSON.parse(n);instance&&i&&a&&(window.location.href=`/?instance=${instance}&platform=${i}&token=`+a)}}};export default handleSignin;
|
||||
//# sourceMappingURL=handleSignin - Copy.min.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"handleSignin - Copy.min.js","sources":["modules/handleSignin - Copy.js"],"sourcesContent":["import getUrlParams from '/js/modules/getUrlParams.min.js';\r\nimport Cookie from '/js/cookies/main.min.js';\r\n\r\nconst cookieManager = new Cookie();\r\nconst signinForm = document.getElementById(\"signin-form\");\r\nconst instance = document.getElementById(\"instance\");\r\nconst signinButton = document.getElementById(\"signin-btn\");\r\n\r\nconst toggleFormElements = (form) => {\r\n if (form.dataset.enabled === 'true'){\r\n instance.disabled = true;\r\n signinButton.disabled = true;\r\n signinButton.innerHTML = 'Loading...';\r\n form.dataset.enabled = 'false';\r\n } else {\r\n instance.disabled = false;\r\n signinButton.disabled = false;\r\n signinButton.innerHTML = 'Sign in';\r\n form.dataset.enabled = 'true';\r\n }\r\n};\r\n\r\nconst handleSignin = () => {\r\n signinForm.addEventListener(\"submit\", async (ev) => {\r\n ev.preventDefault();\r\n toggleFormElements(signinForm);\r\n\r\n const resp = await fetch(`https://fediverse-info.stefanbohacek.dev/node-info?domain=${instance.value}`);\r\n const respJSON = await resp.json();\r\n if (respJSON && respJSON.software){\r\n window.location.href = `https://auth.stefanbohacek.dev/?method=fediverse&instance=${instance.value}&scope=read:accounts&app=localhost-3000&platform=${respJSON.software}`;\r\n } else {\r\n alert(`This doesn't look like a fediverse instance.`);\r\n toggleFormElements(signinForm);\r\n }\r\n });\r\n \r\n if (window.location.pathname === '/'){\r\n const urlParams = getUrlParams();\r\n const userCookie = cookieManager.get('fpusr');\r\n\r\n const startHerePopover = document.getElementById('popover-start');\r\n if (startHerePopover){\r\n startHerePopover.classList.add('show');\r\n }\r\n\r\n if (!urlParams.logout && userCookie){\r\n const {instance, platform, token} = JSON.parse(userCookie);\r\n if (instance && platform && token){\r\n window.location.href = `/?instance=${instance}&platform=${platform}&token=${token}`;\r\n }\r\n }\r\n }\r\n};\r\n\r\nexport default handleSignin;\r\n"],"names":["getUrlParams","Cookie","cookieManager","signinForm","document","getElementById","instance","signinButton","toggleFormElements","form","dataset","enabled","disabled","innerHTML","handleSignin","addEventListener","async","ev","preventDefault","respJSON","await","fetch","value","json","software","window","location","href","alert","pathname","urlParams","userCookie","get","startHerePopover","classList","add","logout","platform","token","JSON","parse"],"mappings":"OAAOA,iBAAkB,yCAClBC,WAAY,0BAEnB,MAAMC,cAAgB,IAAID,OACpBE,WAAaC,SAASC,eAAe,aAAa,EAClDC,SAAWF,SAASC,eAAe,UAAU,EAC7CE,aAAeH,SAASC,eAAe,YAAY,EAEnDG,mBAAqB,IACI,SAAzBC,EAAKC,QAAQC,SACfL,SAASM,SAAW,CAAA,EACpBL,aAAaK,SAAW,CAAA,EACxBL,aAAaM,UAAY,aACzBJ,EAAKC,QAAQC,QAAU,UAEvBL,SAASM,SAAW,CAAA,EACpBL,aAAaK,SAAW,CAAA,EACxBL,aAAaM,UAAY,UACzBJ,EAAKC,QAAQC,QAAU,OAE3B,EAEMG,aAAe,KAenB,GAdAX,WAAWY,iBAAiB,SAAUC,MAAOC,IAC3CA,EAAGC,eAAe,EAClBV,mBAAmBL,UAAU,EAGvBgB,EAAWC,MADJA,MAAMC,MAAM,6DAA6Df,SAASgB,KAAO,GAC1EC,KAAK,EAC7BJ,GAAYA,EAASK,SACvBC,OAAOC,SAASC,kEAAoErB,SAASgB,yDAAyDH,EAASK,UAE/JI,MAAM,8CAA8C,EACpDpB,mBAAmBL,UAAU,EAEjC,CAAC,EAEgC,MAA7BsB,OAAOC,SAASG,SAAiB,CACnC,IAAMC,EAAY9B,aAAa,EACzB+B,EAAa7B,cAAc8B,IAAI,OAAO,EAEtCC,EAAmB7B,SAASC,eAAe,eAAe,EAKhE,GAJI4B,GACFA,EAAiBC,UAAUC,IAAI,MAAM,EAGnC,CAACL,EAAUM,QAAUL,EAAW,CAClC,KAAM,CAACzB,SAAU+B,SAAAA,EAAUC,MAAAA,CAAK,EAAIC,KAAKC,MAAMT,CAAU,EACrDzB,UAAY+B,GAAYC,IAC1Bb,OAAOC,SAASC,mBAAqBrB,qBAAqB+B,WAAkBC,EAEhF,CACF,CACF,iBAEexB"}
|
|
@ -1,4 +1,4 @@
|
|||
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 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="",a=(s.actor?(e+=`
|
||||
import sortArrayOfObjects from"/js/modules/sortArrayOfObjects.min.js";import getDomain from"/js/modules/getDomain.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 s=new FormData;s.set("archive",fileInput.files[0]);s=await(await fetch("/extract-data",{method:"POST",body:s})).json();if(s&&s.data){introElement.classList.add("d-none"),resultsElement.classList.remove("d-none");s=s.data;let e="",t="",a=(s.actor?(e+=`
|
||||
<p class="mb-0">
|
||||
<strong>${s.actor.name||s.actor.preferredUsername}</strong>
|
||||
</p>
|
||||
|
@ -13,27 +13,34 @@ import sortArrayOfObjects from"/js/modules/sortArrayOfObjects.min.js";import loa
|
|||
<img class="img-thumbnail" width="64" height="64" src="${s.avatar_url}">
|
||||
`:s.avatar&&(userAvatar.innerHTML=`
|
||||
<img class="img-thumbnail" width="64" height="64" src="data:image/jpg;base64,${s.avatar}">
|
||||
`)):(userInfo.remove(),userDescription.remove()),[]),o,n=0;s?.outbox?.orderedItems?a=s.outbox.orderedItems:s?.outbox&&(a=s.outbox),(n=a.length)&&(o=a[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()),[]),o,r=0;s?.outbox?.orderedItems?a=s.outbox.orderedItems:s?.outbox&&(a=s.outbox);var i=[];if(r=a.length){var l=Math.ceil(Math.pow(a.length,.1));if(o=a[0],10<=a.length)for(let t=1;t<=l;t++){var d=a[Math.pow(10,t)],m=d.id.replace("/activity","");let e=!1;d.object.id||(e=!0),d={label:[Math.pow(10,t).toLocaleString()+"th post"],url:m,isBoost:e},i.push(d)}}var c={weekday:"long",year:"numeric",month:"long",day:"numeric"};s.actor&&(u=moment(s.actor.published),u=moment().diff(u,"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(s.actor.published).toLocaleDateString(void 0,c)}</strong>, which is <strong>${u.toLocaleString()} day(s) ago</strong>. Since then, you posted <strong>${r.toLocaleString()} times</strong>, or about ${Math.round(r/u).toLocaleString()} time(s) a day on average.
|
||||
</p>
|
||||
`);let r;"mastodon"===s.format?(o&&(i=o?.object?.id||o?.id,l=new URL(i),r=l.protocol+"//"+l.hostname,t=t+`
|
||||
`);let n;if(o){let e;if(!["firefish","calckey","misskey"].includes(s.format)){c=o?.uri||o?.object?.id||o?.id;try{e=new URL(c)}catch(e){console.log("error parsing data file",e)}e&&e.protocol&&e.hostname&&(n=e.protocol+"//"+e.hostname),t+=`
|
||||
<p>
|
||||
Here's your <a href="${i}" target="_blank">first post</a>!
|
||||
Here's your <a href="${c}" target="_blank">first post</a>!
|
||||
</p>
|
||||
`+`
|
||||
`,"mastodon"===s.format&&(t+=`
|
||||
<iframe
|
||||
src="${i}/embed"
|
||||
src="${c}/embed"
|
||||
class="mastodon-embed"
|
||||
style="max-width: 100%; border: 0" width="400"
|
||||
allowfullscreen="allowfullscreen"></iframe>
|
||||
`),t+=`
|
||||
<p class="mt-4">
|
||||
And this is what your posting history looks like.
|
||||
</p>
|
||||
`):t+=`
|
||||
<p>
|
||||
Here's what your posting history looks like.
|
||||
</p>
|
||||
`,userDataBreakdown.innerHTML=t,"mastodon"===s.format&&loadEmbedScript(r);var l={labels:a.map(e=>moment(e.published||e.createdAt||e.created)),datasets:[{label:"Your posts in time",data:a.map((e,t)=>({x:moment(e.published||e.createdAt||e.created),y:new Date(e.published||e.createdAt||e.created).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}},plugins:{tooltip:{callbacks:{label:e=>e.label}}}}})}else loadingAnimation.classList.add("d-none"),loadingText.classList.add("d-none"),fileInput.disabled=!1})};export default handleUpload;
|
||||
`),i&&i.length&&(t+=`
|
||||
<p class="mt-3">
|
||||
Here are more of your milestones:
|
||||
</p>
|
||||
<ul>
|
||||
${i.map(e=>`
|
||||
<li>
|
||||
<a target="_blanlk" href="${e.url}">${e.label}</a>${e.isBoost?" (boost)":""}
|
||||
</li>
|
||||
`).join("")}
|
||||
</ul>
|
||||
`),t+=`
|
||||
<p class="mt-4">
|
||||
And this is what your posting history looks like.
|
||||
</p>
|
||||
`}}userDataBreakdown.innerHTML=t,"mastodon"===s.format&&loadEmbedScript(n);var u={labels:a.map(e=>moment(e.published||e.createdAt||e.created)),datasets:[{label:"Your posts in time",data:a.map((e,t)=>({x:moment(e.published||e.createdAt||e.created),y:new Date(e.published||e.createdAt||e.created).getHours()})),backgroundColor:["#ff6384"]}]};new Chart(chartElement,{type:"scatter",data:u,options:{scales:{x:{type:"time",position:"bottom",ticks:{beginAtZero:!1,stepSize:10}},y:{ticks:{beginAtZero:!1,display:!1},scaleLabel:{display:!1},minorTickInterval:null}},plugins:{tooltip:{callbacks:{label:e=>e.label}}}}})}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
|
@ -1,2 +0,0 @@
|
|||
const sleep=s=>new Promise(e=>setTimeout(e,s));export default sleep;
|
||||
//# sourceMappingURL=sleep - Copy.min.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"sleep - Copy.min.js","sources":["modules/sleep - Copy.js"],"sourcesContent":["const sleep = (ms) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n\nexport default sleep;\n"],"names":["sleep","Promise","resolve","setTimeout","ms"],"mappings":"AAAA,MAAMA,MAAQ,GACL,IAAIC,QAAQC,GAAWC,WAAWD,EAASE,CAAE,CAAC,iBAGxCJ"}
|
|
@ -1,2 +0,0 @@
|
|||
const timeSince=o=>{var o=Math.floor((new Date-o)/1e3),t=Math.floor(o/31536e3);return 1<t?t+" years":1<(t=Math.floor(o/2592e3))?t+" months":1<(t=Math.floor(o/86400))?t+" days":1<(t=Math.floor(o/3600))?t+" hours":1<(t=Math.floor(o/60))?t+" minutes":Math.floor(o)+" seconds"};export default timeSince;
|
||||
//# sourceMappingURL=timeSince - Copy.min.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"timeSince - Copy.min.js","sources":["modules/timeSince - Copy.js"],"sourcesContent":["const timeSince = (date) => {\r\n let seconds = Math.floor((new Date() - date) / 1000);\r\n let interval = Math.floor(seconds / 31536000);\r\n \r\n if (interval > 1) {\r\n return interval + \" years\";\r\n }\r\n\r\n interval = Math.floor(seconds / 2592000);\r\n\r\n if (interval > 1) {\r\n return interval + \" months\";\r\n }\r\n\r\n interval = Math.floor(seconds / 86400);\r\n\r\n if (interval > 1) {\r\n return interval + \" days\";\r\n }\r\n\r\n interval = Math.floor(seconds / 3600);\r\n\r\n if (interval > 1) {\r\n return interval + \" hours\";\r\n }\r\n\r\n interval = Math.floor(seconds / 60);\r\n\r\n if (interval > 1) {\r\n return interval + \" minutes\";\r\n }\r\n\r\n return Math.floor(seconds) + \" seconds\";\r\n};\r\n\r\nexport default timeSince;"],"names":["timeSince","let","seconds","Math","floor","Date","date","interval"],"mappings":"AAAA,MAAMA,UAAY,IACdC,IAAIC,EAAUC,KAAKC,OAAO,IAAIC,KAASC,GAAQ,GAAI,EAC/CC,EAAWJ,KAAKC,MAAMF,EAAU,OAAQ,EAE5C,OAAe,EAAXK,EACOA,EAAW,SAKP,GAFfA,EAAWJ,KAAKC,MAAMF,EAAU,MAAO,GAG5BK,EAAW,UAKP,GAFfA,EAAWJ,KAAKC,MAAMF,EAAU,KAAK,GAG1BK,EAAW,QAKP,GAFfA,EAAWJ,KAAKC,MAAMF,EAAU,IAAI,GAGzBK,EAAW,SAKP,GAFfA,EAAWJ,KAAKC,MAAMF,EAAU,EAAE,GAGvBK,EAAW,WAGfJ,KAAKC,MAAMF,CAAO,EAAI,UACjC,iBAEeF"}
|
|
@ -0,0 +1,6 @@
|
|||
const getDomain = (url) => {
|
||||
let domain = (new URL(url));
|
||||
return domain.hostname;
|
||||
};
|
||||
|
||||
export default getDomain;
|
|
@ -1,4 +1,5 @@
|
|||
import sortArrayOfObjects from "/js/modules/sortArrayOfObjects.min.js";
|
||||
import getDomain from "/js/modules/getDomain.min.js";
|
||||
import loadEmbedScript from "/js/modules/loadEmbedScript.min.js";
|
||||
import Cookie from "/js/cookies/main.min.js";
|
||||
|
||||
|
@ -17,8 +18,8 @@ const chartElement = document.getElementById("chart");
|
|||
const handleUpload = () => {
|
||||
if (fileInput) {
|
||||
fileInput.addEventListener("change", async (ev) => {
|
||||
loadingAnimation.classList.remove('d-none');
|
||||
loadingText.classList.remove('d-none');
|
||||
loadingAnimation.classList.remove("d-none");
|
||||
loadingText.classList.remove("d-none");
|
||||
fileInput.disabled = true;
|
||||
const formData = new FormData();
|
||||
formData.set("archive", fileInput.files[0]);
|
||||
|
@ -29,17 +30,17 @@ const handleUpload = () => {
|
|||
});
|
||||
|
||||
const response = await resp.json();
|
||||
console.log(response);
|
||||
|
||||
if (response && response.data) {
|
||||
introElement.classList.add("d-none");
|
||||
resultsElement.classList.remove("d-none");
|
||||
const userData = response.data;
|
||||
|
||||
let userDescriptionHTML = '';
|
||||
let userDataBreakdownHTML = '';
|
||||
// let userDomain = getDomain(userData.actor.id);
|
||||
let userDescriptionHTML = "";
|
||||
let userDataBreakdownHTML = "";
|
||||
|
||||
if (userData.actor){
|
||||
if (userData.actor) {
|
||||
userDescriptionHTML += `
|
||||
<p class="mb-0">
|
||||
<strong>${
|
||||
|
@ -48,7 +49,7 @@ const handleUpload = () => {
|
|||
</p>
|
||||
${userData.actor.summary.replaceAll('class="invisible"', "")}
|
||||
`;
|
||||
|
||||
|
||||
if (userData.actor.attachment) {
|
||||
userDescriptionHTML += `
|
||||
<ul class="list-group">
|
||||
|
@ -64,14 +65,14 @@ const handleUpload = () => {
|
|||
</ul>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
userDescription.innerHTML = `<div>${userDescriptionHTML}</div>`;
|
||||
|
||||
if (userData.avatar_url){
|
||||
if (userData.avatar_url) {
|
||||
userAvatar.innerHTML = `
|
||||
<img class="img-thumbnail" width="64" height="64" src="${userData.avatar_url}">
|
||||
`;
|
||||
} else if (userData.avatar){
|
||||
} else if (userData.avatar) {
|
||||
userAvatar.innerHTML = `
|
||||
<img class="img-thumbnail" width="64" height="64" src="data:image/jpg;base64,${userData.avatar}">
|
||||
`;
|
||||
|
@ -87,15 +88,41 @@ const handleUpload = () => {
|
|||
|
||||
if (userData?.outbox?.orderedItems) {
|
||||
posts = userData.outbox.orderedItems;
|
||||
} else if (userData?.outbox){
|
||||
posts = userData.outbox;
|
||||
} else if (userData?.outbox) {
|
||||
posts = userData.outbox;
|
||||
}
|
||||
|
||||
|
||||
postCount = posts.length;
|
||||
let milestones = [];
|
||||
|
||||
if (postCount) {
|
||||
// posts = sortArrayOfObjects(posts, key, desc)
|
||||
const maxRoot = Math.ceil(Math.pow(posts.length, 1 / 10));
|
||||
firstPost = posts[0];
|
||||
|
||||
if (posts.length >= 10) {
|
||||
for (let i = 1; i <= maxRoot; i++) {
|
||||
const post = posts[Math.pow(10, i)];
|
||||
const url = post.id.replace("/activity", "");
|
||||
|
||||
let milestone = {};
|
||||
let isBoost = false;
|
||||
|
||||
if (!post.object.id) {
|
||||
isBoost = true;
|
||||
}
|
||||
|
||||
milestone = {
|
||||
label: [`${Math.pow(10, i).toLocaleString()}th post`],
|
||||
url,
|
||||
isBoost,
|
||||
};
|
||||
|
||||
milestones.push(milestone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const options = {
|
||||
weekday: "long",
|
||||
year: "numeric",
|
||||
|
@ -103,30 +130,45 @@ const handleUpload = () => {
|
|||
day: "numeric",
|
||||
};
|
||||
|
||||
if (userData.actor){
|
||||
if (userData.actor) {
|
||||
const accountCreationDate = moment(userData.actor.published);
|
||||
const today = moment();
|
||||
const timeAgo = today.diff(accountCreationDate, 'days');
|
||||
|
||||
|
||||
const timeAgo = today.diff(accountCreationDate, "days");
|
||||
|
||||
userDataBreakdownHTML += `
|
||||
<p>
|
||||
You created your account on <strong>${new Date(userData.actor.published).toLocaleDateString(
|
||||
You created your account on <strong>${new Date(
|
||||
userData.actor.published
|
||||
).toLocaleDateString(
|
||||
undefined,
|
||||
options
|
||||
)}</strong>, which is <strong>${timeAgo.toLocaleString()} day(s) ago</strong>. Since then, you posted <strong>${postCount.toLocaleString()} times</strong>, or about ${(Math.round(postCount/timeAgo)).toLocaleString()} time(s) a day on average.
|
||||
)}</strong>, which is <strong>${timeAgo.toLocaleString()} day(s) ago</strong>. Since then, you posted <strong>${postCount.toLocaleString()} times</strong>, or about ${Math.round(
|
||||
postCount / timeAgo
|
||||
).toLocaleString()} time(s) a day on average.
|
||||
</p>
|
||||
`;
|
||||
}
|
||||
|
||||
let instanceURL;
|
||||
|
||||
if (userData.format === 'mastodon'){
|
||||
if (firstPost) {
|
||||
const postURL = firstPost?.object?.id || firstPost?.id;
|
||||
const url = new URL(postURL);
|
||||
instanceURL = `${url.protocol}//${url.hostname}`;
|
||||
if (firstPost) {
|
||||
let postURL;
|
||||
let url;
|
||||
|
||||
if (["firefish", "calckey", "misskey"].includes(userData.format)) {
|
||||
// Export file doesn't contain server name.
|
||||
} else {
|
||||
postURL = firstPost?.uri || firstPost?.object?.id || firstPost?.id;
|
||||
|
||||
try {
|
||||
url = new URL(postURL);
|
||||
} catch (err) {
|
||||
console.log("error parsing data file", err);
|
||||
}
|
||||
|
||||
if (url && url.protocol && url.hostname) {
|
||||
instanceURL = `${url.protocol}//${url.hostname}`;
|
||||
}
|
||||
|
||||
userDataBreakdownHTML += `
|
||||
<p>
|
||||
|
@ -134,31 +176,48 @@ const handleUpload = () => {
|
|||
</p>
|
||||
`;
|
||||
|
||||
userDataBreakdownHTML += `
|
||||
if (userData.format === "mastodon") {
|
||||
userDataBreakdownHTML += `
|
||||
<iframe
|
||||
src="${postURL}/embed"
|
||||
class="mastodon-embed"
|
||||
style="max-width: 100%; border: 0" width="400"
|
||||
allowfullscreen="allowfullscreen"></iframe>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
userDataBreakdownHTML += `
|
||||
<p class="mt-4">
|
||||
And this is what your posting history looks like.
|
||||
</p>
|
||||
`;
|
||||
} else {
|
||||
userDataBreakdownHTML += `
|
||||
<p>
|
||||
Here's what your posting history looks like.
|
||||
</p>
|
||||
`;
|
||||
if (milestones && milestones.length) {
|
||||
userDataBreakdownHTML += `
|
||||
<p class="mt-3">
|
||||
Here are more of your milestones:
|
||||
</p>
|
||||
<ul>
|
||||
${milestones
|
||||
.map(
|
||||
(milestone) => `
|
||||
<li>
|
||||
<a target="_blanlk" href="${milestone.url}">${
|
||||
milestone.label
|
||||
}</a>${milestone.isBoost ? ` (boost)` : ""}
|
||||
</li>
|
||||
`
|
||||
)
|
||||
.join("")}
|
||||
</ul>
|
||||
`;
|
||||
}
|
||||
|
||||
userDataBreakdownHTML += `
|
||||
<p class="mt-4">
|
||||
And this is what your posting history looks like.
|
||||
</p>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
userDataBreakdown.innerHTML = userDataBreakdownHTML;
|
||||
|
||||
if (userData.format === 'mastodon'){
|
||||
if (userData.format === "mastodon") {
|
||||
loadEmbedScript(instanceURL);
|
||||
}
|
||||
|
||||
|
@ -167,7 +226,9 @@ const handleUpload = () => {
|
|||
// };
|
||||
|
||||
const data = {
|
||||
labels: posts.map((post) => moment(post.published || post.createdAt || post.created)),
|
||||
labels: posts.map((post) =>
|
||||
moment(post.published || post.createdAt || post.created)
|
||||
),
|
||||
datasets: [
|
||||
{
|
||||
label: "Your posts in time",
|
||||
|
@ -175,60 +236,60 @@ const handleUpload = () => {
|
|||
return {
|
||||
x: moment(post.published || post.createdAt || post.created),
|
||||
// y: (new Date(post.published || post.createdAt)).getHour() + 1,
|
||||
y: (new Date(post.published || post.createdAt || post.created)).getHours(),
|
||||
y: new Date(
|
||||
post.published || post.createdAt || post.created
|
||||
).getHours(),
|
||||
};
|
||||
}),
|
||||
backgroundColor: ['#ff6384']
|
||||
backgroundColor: ["#ff6384"],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
new Chart(chartElement, {
|
||||
type: "scatter",
|
||||
data : data,
|
||||
data: data,
|
||||
options: {
|
||||
scales: {
|
||||
x:
|
||||
{
|
||||
type: "time",
|
||||
position: "bottom",
|
||||
ticks: {
|
||||
beginAtZero: false,
|
||||
stepSize: 10,
|
||||
},
|
||||
x: {
|
||||
type: "time",
|
||||
position: "bottom",
|
||||
ticks: {
|
||||
beginAtZero: false,
|
||||
stepSize: 10,
|
||||
},
|
||||
y:
|
||||
{
|
||||
ticks: {
|
||||
beginAtZero: false,
|
||||
display: false,
|
||||
},
|
||||
scaleLabel: {
|
||||
display: false,
|
||||
// labelString: chartEl.dataset.axisLabelData
|
||||
// labelString: chartEl.dataset.sourceId ? window.ftfDataviz[parseInt( chartEl.dataset.sourceId )].axis_label_title : ''
|
||||
// labelString: 'Day of the month'
|
||||
},
|
||||
minorTickInterval: null,
|
||||
},
|
||||
y: {
|
||||
ticks: {
|
||||
beginAtZero: false,
|
||||
display: false,
|
||||
},
|
||||
scaleLabel: {
|
||||
display: false,
|
||||
// labelString: chartEl.dataset.axisLabelData
|
||||
// labelString: chartEl.dataset.sourceId ? window.ftfDataviz[parseInt( chartEl.dataset.sourceId )].axis_label_title : ''
|
||||
// labelString: 'Day of the month'
|
||||
},
|
||||
minorTickInterval: null,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
// label: (ctx) => ctx.label
|
||||
// label: (ctx) => ctx.label
|
||||
label: (ctx) => {
|
||||
// console.log(ctx);
|
||||
// console.log(posts[ctx.dataIndex].object.content);
|
||||
return ctx.label
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ctx.label;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
loadingAnimation.classList.add('d-none');
|
||||
loadingText.classList.add('d-none');
|
||||
loadingAnimation.classList.add("d-none");
|
||||
loadingText.classList.add("d-none");
|
||||
fileInput.disabled = false;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
Click the "Export" button under "All posts".
|
||||
</li>
|
||||
<li>
|
||||
Your exported file will be available in your Drive. (Link is under "Settings".)
|
||||
Your exported file will be available in your Drive. (Link is under "More" in the sidebar.)
|
||||
</li>
|
||||
</ol>
|
||||
</details>
|
||||
|
|
Ładowanie…
Reference in New Issue