1 line
3.1 KiB
JavaScript
1 line
3.1 KiB
JavaScript
(()=>{function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var n=function(t,n){var r=n.querySelectorAll('input[type="text"], textarea, input[type="checkbox"], input[type="hidden"]'),o=new FormData;return e(r).forEach((function(e){"checkbox"===e.getAttribute("type")?o.append(e.getAttribute("name"),e.checked):o.append(e.getAttribute("name"),e.value)})),new Promise((function(e,r){var c=new XMLHttpRequest;c.open("POST","".concat(t,"/admin/shaare")),c.onload=function(){200!==c.status?(alert("An error occurred. Return code: ".concat(c.status)),r()):(n.closest(".edit-link-container").remove(),e())},c.send(o)}))},r=function(e,t,n){null!=t&&0!==t.length||(window.location.href="".concat(e).concat(n))};!function(){var t=document.querySelector('input[name="js_base_path"]').value,o=function(){return document.querySelectorAll('form[name="linkform"]')},c=document.querySelectorAll('[name="cancel-batch-link"]');null!=c&&e(c).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault(),e.target.closest('form[name="linkform"]').remove(),r(t,o(),"/admin/add-shaare")}))}));var a=document.querySelectorAll('[name="save_edit"]');null!=a&&e(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();var c=e.target.closest('form[name="linkform"]');n(t,c).then((function(){return r(t,o(),"/")}))}))}));var u=document.querySelectorAll('[name="save_edit_batch"]');null!=u&&e(u).forEach((function(r){r.addEventListener("click",(function(r){r.preventDefault();var c=e(o()),a=c.length,u=0,i=document.querySelector(".progressbar > div"),l=document.querySelector(".progressbar-current");document.querySelector(".dark-layer").style.display="block",document.querySelector(".progressbar-max").innerHTML=a,l.innerHTML=u;var f=[];c.forEach((function(e){f.push(n(t,e).then((function(){u+=1,i.style.width="".concat(100*u/a,"%"),l.innerHTML=u})))})),Promise.all(f).then((function(){window.location.href="".concat(t,"/")}))}))}));var i=document.querySelectorAll('[name="delete_link"]');null!=i&&e(i).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();var n=e.target.closest('form[name="linkform"]');(function(e,t){return new Promise((function(n,r){var o=new XMLHttpRequest;o.open("GET","".concat(e.href,"&source=batch")),o.onload=function(){204!==o.status?(alert("An error occurred. Return code: ".concat(o.status)),r()):(t.closest(".edit-link-container").remove(),n())},o.send()}))})(e.target,n).then((function(){return r(t,o(),"/")}))}))}))}()})(); |