"use strict";function upload(e,t){e.length>1?album(e):verifyimage(e[0],t)}function verifyimage(e,t){return e&&e.type.match(/image.*/)?e.size/1024/1024>=10?(console.log("File too large to upload"),document.querySelector("#link").innerHTML="The image is too large to upload to imgur (10MB max). Compress and retry.",void stoplinkprop("#link a")):void uploadimage(e,t):(console.log("File not image"),void(document.querySelector("#link").innerHTML="The file you're trying to upload is not an image."))}function uploadimage(e,t){uploading();var n=new FormData;n.append("image",e);var o=new XMLHttpRequest;o.open("POST","https://api.imgur.com/3/image"),o.setRequestHeader("Authorization","Client-id f30578e81f80336"),o.onload=function(){return console.log(JSON.parse(o.response)),JSON.parse(o.response).data.error?void(document.querySelector("#link").innerHTML=JSON.parse(o.response).data.error):void(null==t?uploaded(JSON.parse(o.response)):t(JSON.parse(o.response)))},o.send(n)}function album(e){num_of_files=e.length;for(var t=0;thttp://imgur.com/a/"+JSON.parse(a.response).data.id+" ",img_ids=[],num_of_files=null,stoplinkprop("#link a"),setcopybutton()},a.send(n)}}function uploading(){document.querySelector("#link").innerHTML=""}function uploaded(e){var t=e.data.link;document.querySelector("#link").innerHTML=""+t+" ",stoplinkprop("#link a"),setcopybutton(),document.querySelector(".desc img").src=t}function setcopybutton(){document.querySelector("#link i").addEventListener("click",function(e){copyTextToClipboard(document.querySelector("#link a").textContent),e.stopPropagation()},!1)}function stoplinkprop(e){document.querySelector(e).addEventListener("click",function(e){e.stopPropagation()},!1)}function copyTextToClipboard(e){var t=document.createElement("textarea");t.style.position="fixed",t.style.top=0,t.style.left=0,t.style.width="2em",t.style.height="2em",t.style.padding=0,t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.background="transparent",t.value=e,document.body.appendChild(t),t.select();try{var n=document.execCommand("copy"),o=n?"successful":"unsuccessful";console.log("Copying text command was "+o)}catch(a){console.log("Unable to copy")}document.body.removeChild(t),document.querySelector("#link i").classList.remove("fa-paperclip"),document.querySelector("#link i").classList.add("fa-check")}function changeMessage(e){var t=document.styleSheets[0],n=t.rules;t.insertRule('.desc h2 a:before { content: "'+e+'"; }',n.length),document.querySelector(".desc h2 a").style.transform="translateY(-100%)"}function error(e){}var num_of_files,img_ids=[];!function(e,t){stoplinkprop("a"),stoplinkprop("span a"),e.querySelector(".upload").addEventListener("click",function(){e.querySelector("input").click()},!1),e.querySelector("input").addEventListener("change",function(){upload(this.files,null)},!1);var n=function(){var n=e.createElement("div");return("draggable"in n||"ondragstart"in n&&"ondrop"in n)&&"FormData"in t&&"FileReader"in t}();n&&(["drag","dragstart","dragend","dragover","dragenter","dragleave","drop"].forEach(function(t){e.querySelector(".upload").addEventListener(t,function(e){e.preventDefault(),e.stopPropagation()})}),["dragover","dragenter"].forEach(function(t){e.querySelector(".upload").addEventListener(t,function(){this.classList.add("dragover")})}),["dragleave","dragend","drop"].forEach(function(t){e.querySelector(".upload").addEventListener(t,function(){this.classList.remove("dragover")})}),e.querySelector(".upload").addEventListener("drop",function(e){upload(e.dataTransfer.files,null)}))}(document,window);