-
Your Links
-
+
+ Your Links
+
+
-
+
- You haven't created any links yet.
+
+ You haven't created any links yet.
+
-
+
- No links yet
+
+ No links yet.
+
@@ -227,7 +404,7 @@
-
@@ -237,9 +414,12 @@
-
@@ -254,17 +434,20 @@
loadingLinks:!0,
errorLinks:"",
async fetchLinks(){
- this.loadingLinks=!0,this.errorLinks="";
+ this.loadingLinks=!0,
+ this.errorLinks="";
try{
const e=localStorage.getItem("username"),
t=localStorage.getItem("pass_hash");
- if(!e||!t)throw new Error("Authentication error.");
+ if(!e||!t)
+ throw new Error("Authentication error.");
const s=await fetch("/api/links/list",{
method:"POST",
headers:{"Content-Type":"application/json"},
body:JSON.stringify({username:e,pass_hash:t})
});
- if(!s.ok)throw new Error(await s.text()||"Failed to fetch links.");
+ if(!s.ok)
+ throw new Error(await s.text()||"Failed to fetch links.");
this.links=(await s.json()).reverse()
}catch(e){
this.errorLinks=e.message
@@ -285,20 +468,30 @@
copied:!1,
widgetId:null,
renderCaptcha(){
- if(!window.grecaptcha?.render)return setTimeout(()=>this.renderCaptcha(),100);
+ if(!window.grecaptcha?.render)
+ return setTimeout(()=>this.renderCaptcha(),100);
this.$nextTick(()=>{
const e=this.$el.querySelector(".recaptcha-container");
- e&&(e.innerHTML="",this.widgetId=grecaptcha.render(e,{sitekey:"6LeXhdYrAAAAALW6DdgxNeHU0kwBncdicLnVYvXT"}))
+ e&&(e.innerHTML="",
+ this.widgetId=grecaptcha.render(e,{
+ sitekey:"6LeXhdYrAAAAALW6DdgxNeHU0kwBncdicLnVYvXT"
+ }))
})
},
async createLink(){
- this.loading=!0,this.error="",this.result={};
+ this.loading=!0,
+ this.error="",
+ this.result={};
const o=grecaptcha.getResponse(this.widgetId);
- if(!o)return this.error="Please complete the CAPTCHA.",this.loading=!1,void 0;
+ if(!o)
+ return this.error="Please complete the CAPTCHA.",
+ this.loading=!1,
+ void 0;
try{
const e=localStorage.getItem("username"),
s=localStorage.getItem("pass_hash");
- if(!e||!s)throw new Error("Authentication error.");
+ if(!e||!s)
+ throw new Error("Authentication error.");
const t=await fetch("/api/links/create",{
method:"POST",
headers:{"Content-Type":"application/json"},
@@ -310,10 +503,14 @@
"g-recaptcha-response":o
})
});
- if(!t.ok)throw new Error(await t.text()||"Failed to create link.");
+ if(!t.ok)
+ throw new Error(await t.text()||"Failed to create link.");
const i=await t.json(),
r=window.location.host;
- this.result={...i,url:`https://${r}/${i.slug}`},
+ this.result={
+ ...i,
+ url:`https://${r}/${i.slug}`
+ };
this.destination_url="",
this.slug="",
this.$dispatch("link-created"),
@@ -337,7 +534,9 @@
error:"",
widgetId:null,
init(){
- this.$watch("editingSlug",t=>{t&&this.loadDataForSlug(t)}),
+ this.$watch("editingSlug",t=>{
+ t&&this.loadDataForSlug(t)
+ }),
this.editingSlug&&this.loadDataForSlug(this.editingSlug)
},
async loadDataForSlug(t){
@@ -348,15 +547,19 @@
this.renderTurnstile();
try{
const s=await fetch(`/api/links/get?slug=${t}`);
- if(!s.ok)throw new Error(await s.text()||"Failed to load link");
+ if(!s.ok)
+ throw new Error(await s.text()||"Failed to load link");
const i=await s.json();
- this.destination_url=i.destination_url.startsWith("http")?i.destination_url:`https://${i.destination_url}`,
+ this.destination_url=i.destination_url.startsWith("http")
+ ? i.destination_url
+ : `https://${i.destination_url}`;
this.analyticsEnabled=i.analytics_enabled||!1;
if(this.analyticsEnabled){
this.loadingAnalytics=!0;
try{
const a=await fetch(`/api/analytics/get?slug=${t}`);
- if(!a.ok)throw new Error(await a.text()||"Failed to load analytics");
+ if(!a.ok)
+ throw new Error(await a.text()||"Failed to load analytics");
this.analytics=await a.json()
}finally{
this.loadingAnalytics=!1
@@ -369,20 +572,29 @@
}
},
renderTurnstile(){
- if(!window.turnstile?.render)return setTimeout(()=>this.renderTurnstile(),100);
+ if(!window.turnstile?.render)
+ return setTimeout(()=>this.renderTurnstile(),100);
this.$nextTick(()=>{
const t=this.$el.querySelector(".turnstile-container");
- t&&(t.innerHTML="",this.widgetId=turnstile.render(t,{sitekey:"0x4AAAAAAB54R0OUQDyuiUS5"}))
+ t&&(t.innerHTML="",
+ this.widgetId=turnstile.render(t,{
+ sitekey:"0x4AAAAAAB54R0OUQDyuiUS5"
+ }))
})
},
async updateLink(){
- this.loading=!0,this.error="";
+ this.loading=!0,
+ this.error="";
const o=turnstile.getResponse(this.widgetId);
- if(!o)return this.error="Please complete the CAPTCHA.",this.loading=!1,void 0;
+ if(!o)
+ return this.error="Please complete the CAPTCHA.",
+ this.loading=!1,
+ void 0;
try{
const t=localStorage.getItem("username"),
s=localStorage.getItem("pass_hash");
- if(!t||!s)throw new Error("Authentication error.");
+ if(!t||!s)
+ throw new Error("Authentication error.");
const i=await fetch("/api/links/update",{
method:"POST",
headers:{"Content-Type":"application/json"},
@@ -395,7 +607,8 @@
"cf-turnstile-response":o
})
});
- if(!i.ok)throw new Error(await i.text()||"Failed to update link.");
+ if(!i.ok)
+ throw new Error(await i.text()||"Failed to update link.");
this.editingSlug=null,
this.$dispatch("link-created")
}catch(t){
@@ -406,14 +619,20 @@
}
},
async deleteLink(){
- if(!confirm("Are you sure you want to delete this link?"))return;
- this.loading=!0,this.error="";
+ if(!confirm("Are you sure you want to delete this link?"))
+ return;
+ this.loading=!0,
+ this.error="";
const o=turnstile.getResponse(this.widgetId);
- if(!o)return this.error="Please complete the CAPTCHA.",this.loading=!1,void 0;
+ if(!o)
+ return this.error="Please complete the CAPTCHA.",
+ this.loading=!1,
+ void 0;
try{
const t=localStorage.getItem("username"),
s=localStorage.getItem("pass_hash");
- if(!t||!s)throw new Error("Authentication error.");
+ if(!t||!s)
+ throw new Error("Authentication error.");
const i=await fetch("/api/links/delete",{
method:"POST",
headers:{"Content-Type":"application/json"},
@@ -424,7 +643,8 @@
"cf-turnstile-response":o
})
});
- if(!i.ok)throw new Error(await i.text()||"Failed to delete link.");
+ if(!i.ok)
+ throw new Error(await i.text()||"Failed to delete link.");
this.editingSlug=null,
this.$dispatch("link-created")
}catch(t){
@@ -435,11 +655,13 @@
}
},
async fetchAnalytics(){
- if(!this.analyticsEnabled||!this.editingSlug)return;
+ if(!this.analyticsEnabled||!this.editingSlug)
+ return;
this.loadingAnalytics=!0;
try{
const r=await fetch(`/api/analytics/get?slug=${this.editingSlug}`);
- if(!r.ok)throw new Error(await r.text()||"Failed to load analytics");
+ if(!r.ok)
+ throw new Error(await r.text()||"Failed to load analytics");
this.analytics=await r.json()
}catch(e){
this.error=e.message