/* * simpleUpload.js v.1.1 * * Copyright 2018, Michael Brook, All rights reserved. * http://simpleupload.michaelcbrook.com/ * * simpleUpload.js is an extremely simple yet powerful jQuery file upload plugin. * It is free to use under the MIT License (http://opensource.org/licenses/MIT) * * https://github.com/michaelcbrook/simpleUpload.js * @michaelcbrook */ function simpleUpload(e,l,n){var t=!1,a=null,o=0,r=0,i=[],s=[],p="auto",u=null,f=null,d="file",c={},m={},h=function(e){},v=function(e){},y=function(e){},U=function(e){},g=function(e){},b=function(){},w=function(e){},x=function(){},j=function(e,l){},k=[],E=[],S={files:k},z=0,F=null,T=function(e,l){M(e,l),0==--z&&D(),simpleUpload.activeUploads--,simpleUpload.uploadNext()},C=function(e){return h.call(S,e)},I=function(e,l){return!(R(e)>0)&&(!1===v.call(k[e],l)?(O(e,4),!1):!(R(e)>0)&&void O(e,1))},L=function(e,l){1==R(e)&&y.call(k[e],l)},q=function(e,l){1==R(e)&&(O(e,2),U.call(k[e],l),T(e,"success"))},W=function(e,l){1==R(e)&&(O(e,3),g.call(k[e],l),T(e,"error"))},_=function(e){b.call(k[e]),T(e,"cancel")},M=function(e,l){w.call(k[e],l)},D=function(){x.call(S),null!=F&&F.remove()},N=function(e,l,n){j.call(k[e],l,n)};function A(n){if(1==R(n)){if(null!=a){if(null==a[n]||null==a[n])return void W(n,{name:"InternalError",message:"There was an error uploading the file"});if(window.FormData){var t=$.ajaxSettings.xhr();if(t.upload){var o=a[n],r=new FormData;!function e(l,n,t){null!=t&&""!==t||(t=null);for(var a in n)void 0===n[a]||null===n[a]?l.append(null==t?a+"":t+"["+a+"]",""):"object"==typeof n[a]?e(l,n[a],null==t?a+"":t+"["+a+"]"):"boolean"==typeof n[a]?l.append(null==t?a+"":t+"["+a+"]",n[a]?"true":"false"):"number"==typeof n[a]?l.append(null==t?a+"":t+"["+a+"]",n[a]+""):"string"==typeof n[a]&&l.append(null==t?a+"":t+"["+a+"]",n[a])}(r,c),r.append(d,o);var i={url:e,data:r,type:"post",cache:!1,xhrFields:m,beforeSend:function(e,l){N(n,e,l),E[n].xhr=e},xhr:function(){return t.upload.addEventListener("progress",function(e){e.lengthComputable&&L(n,e.loaded/e.total*100)},!1),t},error:function(e){E[n].xhr=null,W(n,{name:"RequestError",message:"Upload failed",xhr:e})},success:function(e){E[n].xhr=null,L(n,100),q(n,e)},contentType:!1,processData:!1};return"auto"!=p&&(i.dataType=p),void $.ajax(i)}}}"object"==typeof l&&null!==l?function(l){if(0==l){var n=simpleUpload.queueIframe({origin:function(e){var l=document.createElement("a");l.href=e;var n=l.host,t=l.protocol;""==n&&(n=window.location.host);""!=t&&":"!=t||(t=window.location.protocol);return t.replace(/\:$/,"")+"://"+n}(e),expect:p,complete:function(e){1==R(l)&&(E[l].iframe=null,simpleUpload.dequeueIframe(n),L(l,100),q(l,e))},error:function(e){1==R(l)&&(E[l].iframe=null,simpleUpload.dequeueIframe(n),W(l,{name:"RequestError",message:e}))}});E[l].iframe=n;var t=function e(l,n){null!=n&&""!==n||(n=null);var t="";for(var a in l)void 0===l[a]||null===l[a]?t+=$("