UNPKG

dzxstatic

Version:

The static files of Discuz! X

1 lines 12 kB
var sdCloseTime=2;function preLoad(){if(!this.support.loading)return disableMultiUpload(this.customSettings),!1}function loadFailed(){disableMultiUpload(this.customSettings)}function disableMultiUpload(e){if("forum"==e.uploadSource&&"fastpost"!=e.uploadFrom)try{e.singleUpload.style.display="";var t=e.singleUpload.getAttribute("did");if(null!=t){"undefined"==typeof forum_post_inited&&appendscript(JSPATH+"forum_post.js?"+VERHASH);var a=t.split("|");$(a[0]).style.display="none","local"==a[1]?switchImagebutton("local"):"upload"==a[1]&&switchAttachbutton("upload")}}catch(e){}}function fileDialogStart(){"forum"==this.customSettings.uploadSource&&(this.customSettings.alertType=0,"fastpost"==this.customSettings.uploadFrom&&"undefined"==typeof forum_post_inited&&appendscript(JSPATH+"forum_post.js?"+VERHASH))}function fileQueued(e){try{var t=!0;if("forum"==this.customSettings.uploadSource&&"poll"==this.customSettings.uploadType)(a=$(this.customSettings.progressTarget+"_aid"))&&parseInt(a.value)&&this.addPostParam("aid",a.value);else if("portal"==this.customSettings.uploadSource){var a;(a=$("catid"))&&parseInt(a.value)&&this.addPostParam("catid",a.value)}var s=new FileProgress(e,this.customSettings.progressTarget);if("forum"==this.customSettings.uploadSource&&(null!=this.customSettings.maxAttachNum&&(this.customSettings.maxAttachNum>0?this.customSettings.maxAttachNum--:(this.customSettings.alertType=6,t=!1)),t&&null!=this.customSettings.maxSizePerDay&&(this.customSettings.maxSizePerDay-e.size>0?this.customSettings.maxSizePerDay=this.customSettings.maxSizePerDay-e.size:(this.customSettings.alertType=11,t=!1)),t&&null!=this.customSettings.filterType)){var i=this.customSettings.filterType[e.type.substr(1).toLowerCase()];null!=i&&i&&e.size>i&&(this.customSettings.alertType=5,t=!1)}t?s.setStatus("等待上传..."):(this.cancelUpload(e.id),s.setCancelled()),s.toggleCancel(!0,this)}catch(e){this.debug(e)}}function fileQueueError(e,t,a){try{if(t===SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED)return a=parseInt(a),void showDialog("您选择的文件个数超过限制。\n"+(0===a?"您已达到上传文件的上限了。":"您还可以选择 "+a+" 个文件"),"notice",null,null,0,null,null,null,null,sdCloseTime);var s=new FileProgress(e,this.customSettings.progressTarget);switch(s.setError(),s.toggleCancel(!1),t){case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:s.setStatus("文件太大."),this.debug("Error Code: File too big, File name: "+e.name+", File size: "+e.size+", Message: "+a);break;case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:s.setStatus("不能上传零字节文件."),this.debug("Error Code: Zero byte file, File name: "+e.name+", File size: "+e.size+", Message: "+a);break;case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:s.setStatus("禁止上传该类型的文件."),this.debug("Error Code: Invalid File Type, File name: "+e.name+", File size: "+e.size+", Message: "+a);break;case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:alert("You have selected too many files. "+(a>1?"You may only add "+a+" more files":"You cannot add any more files."));break;default:null!==e&&s.setStatus("Unhandled Error"),this.debug("Error Code: "+t+", File name: "+e.name+", File size: "+e.size+", Message: "+a)}}catch(e){this.debug(e)}}function fileDialogComplete(e,t){try{if("forum"==this.customSettings.uploadSource){if("attach"==this.customSettings.uploadType){"function"==typeof switchAttachbutton&&switchAttachbutton("attachlist");try{this.getStats().files_queued&&($("attach_tblheader").style.display="",$("attach_notice").style.display="")}catch(e){}}else if("image"==this.customSettings.uploadType){"function"==typeof switchImagebutton&&switchImagebutton("imgattachlist");try{$("imgattach_notice").style.display=""}catch(e){}}var a="attach"==this.customSettings.uploadType?"attachlist":"imgattachlist",s=$(a);s.getElementsByTagName("table").length||(s.innerHTML="")}else"blog"==this.customSettings.uploadType&&"function"==typeof switchImagebutton&&switchImagebutton("imgattachlist");this.startUpload()}catch(e){this.debug(e)}}function uploadStart(e){try{if(this.addPostParam("filetype",e.type),"forum"==this.customSettings.uploadSource&&"poll"==this.customSettings.uploadType){var t=$(this.customSettings.progressTarget);t.style.display="none",t.innerHTML=""}var a=new FileProgress(e,this.customSettings.progressTarget);if(a.setStatus("上传中..."),a.toggleCancel(!0,this),"forum"==this.customSettings.uploadSource){var s="attach"==this.customSettings.uploadType?"attachlist":"imgattachlist",i=$(s).parentNode;i.scrollTop=$(e.id).offsetTop-i.clientHeight}}catch(e){}return!0}function uploadProgress(e,t,a){try{var s=Math.ceil(t/a*100);new FileProgress(e,this.customSettings.progressTarget).setStatus("正在上传("+s+"%)...")}catch(e){this.debug(e)}}function uploadSuccess(file,serverData){try{var progress=new FileProgress(file,this.customSettings.progressTarget);if("forum"==this.customSettings.uploadSource)if("poll"==this.customSettings.uploadType){var data=eval("("+serverData+")");if(parseInt(data.aid)){var preObj=$(this.customSettings.progressTarget);preObj.innerHTML="",preObj.style.display="";var img=new Image;img.src=IMGDIR+"/attachimg_2.png";var imgObj=document.createElement("img");imgObj.src=img.src,imgObj.className="cur1",imgObj.onmouseout=function(){hideMenu("poll_img_preview_"+data.aid+"_menu")},imgObj.onmouseover=function(){showMenu({menuid:"poll_img_preview_"+data.aid+"_menu",ctrlclass:"a",duration:2,timeout:0,pos:"34"})},preObj.appendChild(imgObj);var inputObj=document.createElement("input");inputObj.type="hidden",inputObj.name="pollimage[]",inputObj.id=this.customSettings.progressTarget+"_aid",inputObj.value=data.aid,preObj.appendChild(inputObj);var preImgObj=document.createElement("span");preImgObj.style.display="none",preImgObj.id="poll_img_preview_"+data.aid+"_menu",img=new Image,img.src=data.smallimg,imgObj=document.createElement("img"),imgObj.src=img.src,preImgObj.appendChild(imgObj),preObj.appendChild(preImgObj)}}else if(aid=parseInt(serverData),aid>0){if("attach"==this.customSettings.uploadType)ajaxget("forum.php?mod=ajax&action=attachlist&aids="+aid+(fid?"&fid="+fid:"")+("undefined"==typeof resulttype?"":"&result=simple"),file.id);else if("image"==this.customSettings.uploadType){var tdObj=getInsertTdId(this.customSettings.imgBoxObj,"image_td_"+aid);ajaxget("forum.php?mod=ajax&action=imagelist&type=single&pid="+pid+"&aids="+aid+(fid?"&fid="+fid:""),tdObj.id),$(file.id).style.display="none"}}else{aid=aid<-1?Math.abs(aid):aid,"string"==typeof STATUSMSG[aid]?(progress.setStatus(STATUSMSG[aid]),showDialog(STATUSMSG[aid],"notice",null,null,0,null,null,null,null,sdCloseTime)):progress.setStatus("取消上传"),this.cancelUpload(file.id),progress.setCancelled(),progress.toggleCancel(!0,this);var stats=this.getStats(),obj={successful_uploads:--stats.successful_uploads,upload_cancelled:++stats.upload_cancelled};this.setStats(obj)}else if("album"==this.customSettings.uploadType){var data=eval("("+serverData+")");if(parseInt(data.picid)){var newTr=document.createElement("TR"),newTd=document.createElement("TD"),img=new Image;img.src=data.url;var imgObj=document.createElement("img");imgObj.src=img.src,newTd.className="c",newTd.appendChild(imgObj),newTr.appendChild(newTd),newTd=document.createElement("TD"),newTd.innerHTML="<strong>"+file.name+"</strong>",newTr.appendChild(newTd),newTd=document.createElement("TD"),newTd.className="d",newTd.innerHTML='图片描述<br/><textarea name="title['+data.picid+']" cols="40" rows="2" class="pt"></textarea>',newTr.appendChild(newTd),this.customSettings.imgBoxObj.appendChild(newTr)}else showDialog("图片上传失败","notice",null,null,0,null,null,null,null,sdCloseTime);$(file.id).style.display="none"}else if("blog"==this.customSettings.uploadType){var data=eval("("+serverData+")");if(parseInt(data.picid)){var tdObj=getInsertTdId(this.customSettings.imgBoxObj,"image_td_"+data.picid),img=new Image;img.src=data.url;var imgObj=document.createElement("img");imgObj.src=img.src,imgObj.className="cur1",imgObj.onclick=function(){insertImage(data.bigimg)},tdObj.appendChild(imgObj);var inputObj=document.createElement("input");inputObj.type="hidden",inputObj.name="picids["+data.picid+"]",inputObj.value=data.picid,tdObj.appendChild(inputObj)}else showDialog("图片上传失败","notice",null,null,0,null,null,null,null,sdCloseTime);$(file.id).style.display="none"}else if("portal"==this.customSettings.uploadSource){var data=eval("("+serverData+")");if(data.aid)if("attach"==this.customSettings.uploadType)ajaxget("portal.php?mod=attachment&op=getattach&type=attach&id="+data.aid,file.id),$("attach_tblheader")&&($("attach_tblheader").style.display="");else{var tdObj=getInsertTdId(this.customSettings.imgBoxObj,"attach_list_"+data.aid);ajaxget("portal.php?mod=attachment&op=getattach&id="+data.aid,tdObj.id),$(file.id).style.display="none"}else showDialog("上传失败","notice",null,null,0,null,null,null,null,sdCloseTime),progress.setStatus("Cancelled"),this.cancelUpload(file.id),progress.setCancelled(),progress.toggleCancel(!0,this)}else progress.setComplete(),progress.setStatus("上传完成."),progress.toggleCancel(!1)}catch(e){this.debug(e)}}function getInsertTdId(e,t){var a,s,i,l=e.getElementsByTagName("table");l.length?l[0].getElementsByTagName("tbody").length?a=(l=l[0]).getElementsByTagName("tbody")[0]:(a=document.createElement("TBODY"),l.appendChild(a)):((l=document.createElement("table")).className="imgl",a=document.createElement("TBODY"),l.appendChild(a),e.appendChild(l));var o=!0,n=0;if(a.childNodes.length){for(var r=(s=a.childNodes[a.childNodes.length-1]).getElementsByTagName("TD"),d=0;d<r.length;d++)if(""==r[d].id){n=d,i=r[d];break}n&&(o=!1)}if(o){s=document.createElement("TR");for(var u=0;u<4;u++){var c=document.createElement("TD");c.width="25%",c.vAlign="bottom",c.appendChild(document.createTextNode(" ")),s.appendChild(c)}i=s.childNodes[0],a.appendChild(s)}return i.id=t,i}function uploadComplete(e){try{0===this.getStats().files_queued||this.startUpload()}catch(e){this.debug(e)}}function uploadError(e,t,a){try{var s=new FileProgress(e,this.customSettings.progressTarget);switch(s.setError(),s.toggleCancel(!1),t){case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:s.setStatus("Upload Error: "+a),this.debug("Error Code: HTTP Error, File name: "+e.name+", Message: "+a);break;case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:s.setStatus("Configuration Error"),this.debug("Error Code: No backend file, File name: "+e.name+", Message: "+a);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:s.setStatus("Upload Failed."),this.debug("Error Code: Upload Failed, File name: "+e.name+", File size: "+e.size+", Message: "+a);break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:s.setStatus("Server (IO) Error"),this.debug("Error Code: IO Error, File name: "+e.name+", Message: "+a);break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:s.setStatus("Security Error"),this.debug("Error Code: Security Error, File name: "+e.name+", Message: "+a);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:s.setStatus("Upload limit exceeded."),this.debug("Error Code: Upload Limit Exceeded, File name: "+e.name+", File size: "+e.size+", Message: "+a);break;case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:s.setStatus("File not found."),this.debug("Error Code: The file was not found, File name: "+e.name+", File size: "+e.size+", Message: "+a);break;case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:s.setStatus("Failed Validation. Upload skipped."),this.debug("Error Code: File Validation Failed, File name: "+e.name+", File size: "+e.size+", Message: "+a);break;case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:this.getStats().files_queued,s.setStatus(this.customSettings.alertType?STATUSMSG[this.customSettings.alertType]:"Cancelled"),s.setCancelled();break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:s.setStatus("Stopped");break;default:s.setStatus("Unhandled Error: "+error_code),this.debug("Error Code: "+t+", File name: "+e.name+", File size: "+e.size+", Message: "+a)}}catch(e){this.debug(e)}}