ACMS.Dispatch._observefilesize=function(elm){if(!window.File)return;var $form=$(elm),Config=ACMS.Config,postMax=returnBytes(Config.pms),fileMax=returnBytes(Config.umfs);function returnBytes(size){if(!!size.match(/^\d+}$/))return size;var scale=size.slice(size.length-1);size=parseInt(size);switch(scale){case "G":size*=1024;case "M":size*=1024;case "K":size*=1024}return size}function convertBytes(size){var scale=String(size).length>6?"M":String(size).length>3?"K":"";switch(scale){case "G":size/=1024;
case "M":size/=1024;case "K":size/=1024}return size.toFixed(1)+scale}function onSingleOver(file){alert("\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u306e\u8b66\u544a\n"+"\n"+"\u30d5\u30a1\u30a4\u30eb\u540d : "+file.name+"\n"+"\u30b5\u30a4\u30ba\u3000\u3000 : "+convertBytes(file.size)+" \u30d0\u30a4\u30c8\n"+"\u4e0a\u9650\u30b5\u30a4\u30ba : "+convertBytes(fileMax)+" \u30d0\u30a4\u30c8\n"+"\n"+"\u9078\u629e\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u30b5\u30a4\u30ba\u304c\u5927\u304d\u3044\u305f\u3081\u3001\n"+
"\u6b63\u5e38\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3067\u304d\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\n"+"\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3092\u5c0f\u3055\u304f\u3057\u3066\u304b\u3089\u767b\u9332\u3057\u3066\u304f\u3060\u3055\u3044\uff61")}function onTotalOver(totalCount,totalSize){alert("\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u306e\u8b66\u544a\n"+"\n"+"\u30d5\u30a1\u30a4\u30eb\u6570 : \u8a08"+totalCount+"\n"+"\u5408\u8a08\u30b5\u30a4\u30ba : \u8a08"+
convertBytes(totalSize)+" \u30d0\u30a4\u30c8\n"+"\u4e0a\u9650\u30b5\u30a4\u30ba : \u8a08"+convertBytes(postMax)+" \u30d0\u30a4\u30c8\n"+"\n"+"\u9078\u629e\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u5408\u8a08\u30b5\u30a4\u30ba\u304c\u5927\u304d\u3044\u305f\u3081\u3001\n"+"\u6b63\u5e38\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3067\u304d\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\n"+"\u8907\u6570\u56de\u306b\u5206\u3051\u3066\u767b\u9332\u3057\u3066\u304f\u3060\u3055\u3044\uff61")}
function checkFileSize(fileInput,callback){var files=fileInput.files,i=0,iz=files.length,size,totalSize=0,file;for(;i<iz;i++){file=files[i];size=file.size||file.fileSize;totalSize+=size;if(size>fileMax&&!!callback)callback(file)}return totalSize}$form.on("change",":file",function(){$form.removeClass("alerted");checkFileSize(this,onSingleOver)});$form.submit(function(e){var totalSize=0,totalCount=0;if($form.hasClass("alerted"))return true;$form.addClass("alerted");$(":file").each(function(){if(!this.files.length)return true;
totalSize+=checkFileSize(this);totalCount+=this.files.length});if(totalSize>postMax){onTotalOver(totalCount,totalSize);e.preventDefault();e.stopImmediatePropagation();return false}})};
