PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 All 36 releases
← All changes | assets/js/widget-recent-comments.min.js +1 -1 0.9.8 → 1.1.12 View file →
@@ -1 +1 @@
1 -(function(){"use strict";const g="X-WP-Nonce";function b(e,t){const n=N();if(!n)return t;const o=R(e);if(!o||!M(o))return t;const r=t?.headers??(typeof Request<"u"&&e instanceof Request?e.headers:void 0),a=new Headers(r??{});return a.has(g)?t:(a.set(g,n),{...t??{},headers:a})}function N(){if(typeof window>"u")return;const t=window.desktopModeConfig?.restNonce;return typeof t=="string"&&t.length>0?t:void 0}function R(e){try{const t=typeof window<"u"&&window.location?window.location.href:void 0;return typeof e=="string"?new URL(e,t):e instanceof URL?e:typeof Request<"u"&&e instanceof Request?new URL(e.url,t):null}catch{return null}}function M(e){return typeof window>"u"||!window.location||e.origin!==window.location.origin?!1:!!(e.pathname.includes("/wp-json/")||e.searchParams.has("rest_route"))}function T(e,t,n={}){const o=window.wp?.desktop?.fetch;if(typeof o=="function")return o(e,t,n);const r=b(e,t);return fetch(e,r)}function x(e,t){let n=null,o=Date.now();const r=()=>{o=Date.now(),e()},a=()=>{n===null&&(n=setInterval(r,t))},d=()=>{n!==null&&(clearInterval(n),n=null)},c=()=>{if(document.hidden){d();return}Date.now()-o>=t&&r(),a()};return document.addEventListener("visibilitychange",c),document.hidden||a(),{stop(){d(),document.removeEventListener("visibilitychange",c)}}}function k(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const I="desktop-mode/recent-comments",L=6e4,A=8,v={approved:{label:"Approved",color:"#22c55e"},hold:{label:"Pending",color:"#f59e0b"},spam:{label:"Spam",color:"#ef4444"},trash:{label:"Trash",color:"#9ca3af"}};function D(e){const t=e.endsWith("Z")?e:e+"Z",n=Math.floor((Date.now()-new Date(t).getTime())/1e3);return n<60?n+"s ago":n<3600?Math.floor(n/60)+"m ago":n<86400?Math.floor(n/3600)+"h ago":Math.floor(n/86400)+"d ago"}async function H(){const e=window.wpApiSettings?.root??"/wp-json/",t=await T(e.replace(/\/$/,"")+`/wp/v2/comments?per_page=${A}&orderby=date&order=desc&_embed=up`,{credentials:"same-origin"},{source:"desktop-mode/recent-comments",silent:!0});if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}function C(e,t,n){e.innerHTML="";const o=document.createElement("div");o.className="dm-comments__header";const r=document.createElement("span");r.className="dm-comments__title",r.textContent="Recent Comments";const a=document.createElement("span");a.className="dm-comments__badge";const d=t?t.filter(s=>s.status==="hold").length:0;if(d>0&&(a.textContent=d+" pending",a.classList.add("dm-comments__badge--visible")),o.appendChild(r),o.appendChild(a),e.appendChild(o),n){const s=document.createElement("div");s.className="dm-comments__error",s.textContent="Could not load comments.",e.appendChild(s);return}if(!t||t.length===0){const s=document.createElement("div");s.className="dm-comments__empty",s.textContent="No comments yet.",e.appendChild(s);return}const c=document.createElement("div");c.className="dm-comments__list";for(const s of t){const l=document.createElement("div");l.className="dm-comments__row";const p=document.createElement("div");p.className="dm-comments__avatar",p.textContent=(s.author_name||"?").trim().charAt(0).toUpperCase();const m=document.createElement("div");m.className="dm-comments__body";const i=document.createElement("div");i.className="dm-comments__meta";const h=document.createElement("span");h.className="dm-comments__author",h.textContent=s.author_name||"Anonymous";const E=v[s.status]??v.hold,u=document.createElement("span");u.className="dm-comments__status",u.style.background=E.color,u.textContent=E.label;const w=document.createElement("span");w.className="dm-comments__time",w.textContent=D(s.date_gmt),i.appendChild(h),i.appendChild(u),i.appendChild(w);const _=document.createElement("div");_.className="dm-comments__post";const y=s._embedded?.up?.[0]?.title?.rendered;_.textContent="↳ "+(y?k(y):`Post #${s.post}`),m.appendChild(i),m.appendChild(_),l.appendChild(p),l.appendChild(m),c.appendChild(l)}e.appendChild(c)}const S=async(e,t)=>{let n=!1;const o=async()=>{if(!n)try{const a=await H();n||C(e,a,!1)}catch{n||C(e,null,!0)}};await o();const r=x(o,L);return()=>{n=!0,r.stop()}},f=window;f.desktopModeWidgets=f.desktopModeWidgets??{},f.desktopModeWidgets[I]=S})();
1 +(function(){"use strict";const v="X-WP-Nonce";function L(e,t){const n=S();if(!n)return t;const o=D(e);if(!o||!H(o))return t;const a=t?.headers??(typeof Request<"u"&&e instanceof Request?e.headers:void 0),c=new Headers(a??{});return c.has(v)?t:(c.set(v,n),{...t??{},headers:c})}function S(){if(typeof window>"u")return;const t=window.openStationConfig?.restNonce;return typeof t=="string"&&t.length>0?t:void 0}function D(e){try{const t=typeof window<"u"&&window.location?window.location.href:void 0;return typeof e=="string"?new URL(e,t):e instanceof URL?e:typeof Request<"u"&&e instanceof Request?new URL(e.url,t):null}catch{return null}}function H(e){return typeof window>"u"||!window.location||e.origin!==window.location.origin?!1:!!(e.pathname.includes("/wp-json/")||e.searchParams.has("rest_route"))}function $(e,t,n={}){const o=window.wp?.os?.fetch;if(typeof o=="function")return o(e,t,n);const a=L(e,t);return fetch(e,a)}class y extends Error{constructor(t,n){super(t||n.serverMessage||`HTTP ${n.status}`),this.name="RestError",this.status=n.status,this.code=n.code,this.data=n.data,this.serverMessage=n.serverMessage??""}}function E(e){return e instanceof y}function F(e){const t=typeof e=="object"&&e!==null?e:void 0;return{code:typeof t?.code=="string"?t.code:void 0,data:t?.data,serverMessage:typeof t?.message=="string"?t.message:""}}function P(e,t,n=""){return new y(n,{status:e,...F(t)})}async function j(e,t=""){let n=null;try{n=await e.json()}catch{n=null}return P(e.status,n,t)}const O="desktop-mode";function b(){return window.wp?.i18n}function l(e,t=O){return b()?.__(e,t)??e}function C(e,...t){const n=b()?.sprintf;if(n)return n(e,...t);let o=0;return e.replace(/%(?:(\d+)\$)?[sd]/g,(a,c)=>{const s=c?Number.parseInt(c,10)-1:o++;return String(t[s]??"")})}const W="rest_cookie_invalid_nonce",N=()=>l("Could not reach the site. Check your connection and try again.","desktop-mode");function k(e){return typeof navigator<"u"&&navigator.onLine===!1?!0:e instanceof TypeError}function q(e){return E(e)?e.code===W||e.status===401?"session":e.status>=200&&e.status<300?"unreadable":e.status===404?"gone":e.status>=500?"server":e.status>=400?"refused":"unknown":k(e)?"offline":"unknown"}function U(e){return E(e)?e.serverMessage:k(e)?N():e instanceof Error?e.message:""}function V(e,t){const{fallback:n,lead:o}=t,a=q(e),c=a==="offline"||a==="unreadable"?"warning":"error";let s="",i=!0;switch(a){case"offline":s=N();break;case"session":s=l("Your session has expired. Reload the page and try again.","desktop-mode");break;case"unreadable":s=l("The site sent an unreadable reply. Reload the page to check whether the change went through.","desktop-mode");break;case"gone":case"refused":case"server":{const d=e;d.serverMessage?s=d.serverMessage:a==="gone"?(s=l("It no longer exists. Reload the page to catch up.","desktop-mode"),i=!1):a==="server"?(s=C(l("The server answered with error %d.","desktop-mode"),d.status),i=!1):(s=C(l("The server refused the request (HTTP %d).","desktop-mode"),d.status),i=!1);break}case"unknown":default:s=U(e);break}let r;return o?r=s?`${o}: ${s}`:n:s?i?r=s:r=`${n} ${s}`:r=n,{message:r,reason:s,kind:a,type:c}}function X(e,t){let n=null,o=Date.now();const a=()=>{o=Date.now(),e()},c=()=>{n===null&&(n=setInterval(a,t))},s=()=>{n!==null&&(clearInterval(n),n=null)},i=()=>{if(document.hidden){s();return}Date.now()-o>=t&&a(),c()};return document.addEventListener("visibilitychange",i),document.hidden||c(),{stop(){s(),document.removeEventListener("visibilitychange",i)}}}function R(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const Z="desktop-mode/recent-comments",B=6e4,G=8,T={approved:{label:"Approved",color:"#22c55e"},hold:{label:"Pending",color:"#f59e0b"},spam:{label:"Spam",color:"#ef4444"},trash:{label:"Trash",color:"#9ca3af"}};function K(e){const t=e.endsWith("Z")?e:e+"Z",n=Math.floor((Date.now()-new Date(t).getTime())/1e3);return n<60?n+"s ago":n<3600?Math.floor(n/60)+"m ago":n<86400?Math.floor(n/3600)+"h ago":Math.floor(n/86400)+"d ago"}async function Y(){const e=window.wpApiSettings?.root??"/wp-json/",t=await $(e.replace(/\/$/,"")+`/wp/v2/comments?per_page=${G}&orderby=date&order=desc&_embed=up`,{credentials:"same-origin"},{source:"desktop-mode/recent-comments",silent:!0});if(!t.ok)throw await j(t);return t.json()}function M(e,t,n){e.innerHTML="";const o=document.createElement("div");o.className="dm-comments__header";const a=document.createElement("span");a.className="dm-comments__title",a.textContent="Recent Comments";const c=document.createElement("span");c.className="dm-comments__badge";const s=t?t.filter(r=>r.status==="hold").length:0;if(s>0&&(c.textContent=s+" pending",c.classList.add("dm-comments__badge--visible")),o.appendChild(a),o.appendChild(c),e.appendChild(o),n){const r=document.createElement("div");r.className="dm-comments__error",r.textContent=n,e.appendChild(r);return}if(!t||t.length===0){const r=document.createElement("div");r.className="dm-comments__empty",r.textContent="No comments yet.",e.appendChild(r);return}const i=document.createElement("div");i.className="dm-comments__list";for(const r of t){const d=document.createElement("div");d.className="dm-comments__row";const x=R(r.author_name||"Anonymous"),h=document.createElement("div");h.className="dm-comments__avatar",h.textContent=x.trim().charAt(0).toUpperCase();const m=document.createElement("div");m.className="dm-comments__body";const u=document.createElement("div");u.className="dm-comments__meta";const g=document.createElement("span");g.className="dm-comments__author",g.textContent=x;const I=T[r.status]??T.hold,f=document.createElement("span");f.className="dm-comments__status",f.style.background=I.color,f.textContent=I.label;const w=document.createElement("span");w.className="dm-comments__time",w.textContent=K(r.date_gmt),u.appendChild(g),u.appendChild(f),u.appendChild(w);const _=document.createElement("div");_.className="dm-comments__post";const A=r._embedded?.up?.[0]?.title?.rendered;_.textContent="↳ "+(A?R(A):`Post #${r.post}`),m.appendChild(u),m.appendChild(_),d.appendChild(h),d.appendChild(m),i.appendChild(d)}e.appendChild(i)}const z=async(e,t)=>{let n=!1;const o=async()=>{if(!n)try{const c=await Y();n||M(e,c,null)}catch(c){n||M(e,null,V(c,{fallback:"Could not load comments."}).message)}};await o();const a=X(o,B);return()=>{n=!0,a.stop()}},p=window;p.openStationWidgets=p.openStationWidgets??{},p.openStationWidgets[Z]=z})();