From b669be9f59c61b5669e1261594a3bec2f10d721b Mon Sep 17 00:00:00 2001 From: welpo Date: Sat, 24 May 2025 14:07:50 +0200 Subject: [PATCH] Undo testing JS change + minify further --- static/js/webmention.min.js | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/static/js/webmention.min.js b/static/js/webmention.min.js index 76f9cc6..5340d7e 100644 --- a/static/js/webmention.min.js +++ b/static/js/webmention.min.js @@ -1,16 +1,16 @@ -(()=>{function getCfg(key,dfl){return document.currentScript.getAttribute("data-"+key)||dfl}window.i18next=window.i18next||{t:function(key){return key}},window.i18next.t.bind(window.i18next);let refurl=getCfg("page-url",window.location.href.replace(/#.*$/,"")),addurls=getCfg("add-urls",void 0),containerID=getCfg("id","webmentions"),maxWebmentions=(getCfg("wordcount"),getCfg("max-webmentions",30)),sortBy=(getCfg("prevent-spoofing"),getCfg("sort-by","published")),sortDir=getCfg("sort-dir","up");function stripurl(url){return url.substr(url.indexOf("//"))}function dedupe(mentions){let filtered=[],seen={};return mentions.forEach(function(r){var source=stripurl(r.url);seen[source]||(filtered.push(r),seen[source]=!0)}),filtered}function formatComments(type,comments){let html=` +(()=>{function t(t,e){return document.currentScript.getAttribute("data-"+t)||e}window.i18next=window.i18next||{t:function(t){return t}},window.i18next.t.bind(window.i18next);let m=t("page-url",window.location.href.replace(/#.*$/,"")),f=t("add-urls",void 0),e=t("id","webmentions"),g=(t("wordcount"),t("max-webmentions",30)),v=(t("prevent-spoofing"),t("sort-by","published")),b=t("sort-dir","up");function y(t){return t.substr(t.indexOf("//"))}function x(t){let l=[],a={};return t.forEach(function(t){var e=y(t.url);a[e]||(l.push(t),a[e]=!0)}),l}function L(t,e){let a=`
-

`+getIcon("comment")+" "+comments.length+" "+type+`s

-
    `;return comments.forEach(function(comment){let content="";var published;comment.hasOwnProperty("content")&&(comment.content.hasOwnProperty("html")?content=comment.content.html:comment.content.hasOwnProperty("text")&&(content=comment.content.text)),html+=` +

    `+o("comment")+" "+e.length+" "+t+`s

    +
      `;return e.forEach(function(t){let e="";var l;t.hasOwnProperty("content")&&(t.content.hasOwnProperty("html")?e=t.content.html:t.content.hasOwnProperty("text")&&(e=t.content.text)),a+=`
    1. - `+comment.author.name+` - `,comment.published&&(published=new Date(comment.published),html+=` - "),html+=` + `+t.author.name+` + `,t.published&&(l=new Date(t.published),a+=` + "),a+=`
      -

      `+content+` +

      `+e+` source

    2. -`}),html+=` +`}),a+=`
- `}function getIcon(name){return"like"==name?' ':"repost"==name?' ':"comment"==name?' ':"bookmark"==name?` + `}function o(t){return"like"==t?' ':"repost"==t?' ':"comment"==t?' ':"bookmark"==t?` -`:void 0}function formatReactions(type,reacts){let html=` +`:void 0}function k(t,e){let l=`
-

'+getIcon(type)+"  "+reacts.length+" "+type+`s

+

'+o(t)+"  "+e.length+" "+t+`s

-
- `}window.addEventListener("load",async function(){var container=document.getElementById(containerID);if(container){let pages=[stripurl(refurl)],apiURL=(addurls&&addurls.split("|").forEach(function(url){pages.push(stripurl(url))}),`http://127.0.0.1:1111/test_webmentions.jf2?`),json=(pages.forEach(function(path){apiURL+=`&target[]=${encodeURIComponent("http:"+path)}&target[]=`+encodeURIComponent("https:"+path)}),{});try{var response=await window.fetch(apiURL);200<=response.status&&response.status<300?json=await response.json():(console.error("Could not parse response"),new Error(response.statusText))}catch(error){console.error("Request failed",error)}var response=[],mentions=[],bookmarks=[],likes=[],reposts=[];let mapping={"in-reply-to":response,"like-of":likes,"repost-of":reposts,"bookmark-of":bookmarks,"follow-of":[],"mention-of":mentions,rsvp:response},formattedMentions=(json.children.forEach(function(child){var store=mapping[child["wm-property"]];store&&store.push(child)}),""),formattedComments=(0${repostsStr}${likesStr}${bookmarksStr}${formattedComments}${formattedMentions}`}})})(); + `}window.addEventListener("load",async function(){var c=document.getElementById(e);if(c){let e=[y(m)],l=(f&&f.split("|").forEach(function(t){e.push(y(t))}),`https://webmention.io/api/mentions.jf2?per-page=${g}&sort-by=${v}&sort-dir=`+b),t=(e.forEach(function(t){l+=`&target[]=${encodeURIComponent("http:"+t)}&target[]=`+encodeURIComponent("https:"+t)}),{});try{200<=(h=await window.fetch(l)).status&&h.status<300?t=await h.json():(console.error("Could not parse response"),new Error(h.statusText))}catch(t){console.error("Request failed",t)}var h,d=[],u=[],p=[],w=[];let a={"in-reply-to":h=[],"like-of":p,"repost-of":w,"bookmark-of":u,"follow-of":[],"mention-of":d,rsvp:h},o=(t.children.forEach(function(t){var e=a[t["wm-property"]];e&&e.push(t)}),""),n=(0${i}${r}${s}${n}${o}`}})})();