diff --git a/pages/index.js b/pages/index.js index d2dbb20..41a437a 100644 --- a/pages/index.js +++ b/pages/index.js @@ -11,52 +11,70 @@ export default function Home() { function getSS(event){ event.preventDefault(); try{ - document.querySelector("#screenshot").src = "https://cutewallpaper.org/21/loading-gif-transparent-background/HopeWell.gif"; - var theUrl = event.target.url.value; - - function isMobile(){ - if(event.target.mobile.checked){ - return "/device=mobile"; + + if(event.target.pdf.checked){ + if(event.target.url.value.match(/\:\/\//) == "://"){ + window.open("https://cdn.statically.io/screenshot/pdf/"+event.target.url.value.split(/\:\/\//)[1]); + }else{ + window.open("https://cdn.statically.io/screenshot/pdf/"+event.target.url.value); } - return "/"; - } - - function isFullPage(){ - if(event.target.full.checked){ - return "full=true/"; + }else{ + document.querySelector("#screenshot").src = "https://cutewallpaper.org/21/loading-gif-transparent-background/HopeWell.gif"; + var theUrl = event.target.url.value; + + function isMobile(){ + if(event.target.mobile.checked){ + return "/device=mobile"; + } + return "/"; } - return "/"; - } - function comma(){ - if(event.target.mobile.checked && event.target.full.checked){ - return ","; - }else{ + function isFullPage(){ + if(event.target.full.checked){ + return "full=true/"; + } return "/"; } - } - if(theUrl.match(/\:\/\//) == "://"){ - fetch("https://cdn.statically.io/screenshot"+isMobile()+comma()+isFullPage()+theUrl.split(/\:\/\//)[1]) - .then((res) => { - document.querySelector("#screenshot").src = "https://cdn.statically.io/screenshot"+isMobile()+comma()+isFullPage()+theUrl.split(/\:\/\//)[1]; - }) - .then((res) => {swal("Good job!", "The screenshot was generated successfully!", "success")}) - }else{ - fetch("https://cdn.statically.io/screenshot"+isMobile()+comma()+isFullPage()+theUrl) - .then((res) => { - document.querySelector("#screenshot").src = "https://cdn.statically.io/screenshot"+isMobile()+comma()+isFullPage()+theUrl; - }) - .then((res) => {swal("Good job!", "The screenshot was generated successfully!", "success")}) + function comma(){ + if(event.target.mobile.checked && event.target.full.checked){ + return ","; + }else{ + return "/"; + } + } + + if(theUrl.match(/\:\/\//) == "://"){ + fetch("https://cdn.statically.io/screenshot"+isMobile()+comma()+isFullPage()+theUrl.split(/\:\/\//)[1]) + .then((res) => { + document.querySelector("#screenshot").src = "https://cdn.statically.io/screenshot"+isMobile()+comma()+isFullPage()+theUrl.split(/\:\/\//)[1]; + }) + .then((res) => {swal("Good job!", "The screenshot was generated successfully!", "success")}) + }else{ + fetch("https://cdn.statically.io/screenshot"+isMobile()+comma()+isFullPage()+theUrl) + .then((res) => { + document.querySelector("#screenshot").src = "https://cdn.statically.io/screenshot"+isMobile()+comma()+isFullPage()+theUrl; + }) + .then((res) => {swal("Good job!", "The screenshot was generated successfully!", "success")}) + } } }catch(e){alert(e)} } - function copyURL(){ copy(document.querySelector("#screenshot").src); } - + + function pdfChanged(){ + if (document.querySelector("#pdf").checked) { + document.querySelector("#controls").style.display = "none"; + document.querySelector("#full").checked = "false"; + document.querySelector("#mobile").checked = "false"; + } else { + document.querySelector("#controls").style.display = "block"; + } + } + return (
@@ -79,11 +97,16 @@ export default function Home() {
- - -
- - +
+ + +
+ + +
+
+ +