// let IMP=new Array(); IMB=new Array(); IMB["Load"]=true; IMB["AjaxRequestAfterFunc"]=null; IMB["CurrentAjaxRequest"]=null; IMB["IMOnLoadFunc"]=new Array(); IMB["IMOnLoad"]=function(){ IMB["IsToaster"](); if(IMP["init"]){IMB["IMOnLoadFunc"].push(IMP["init"]);} for(let i=0;i < IMB["IMOnLoadFunc"].length;i++){ if(typeof IMB["IMOnLoadFunc"][i] === "function"){IMB["IMOnLoadFunc"][i]();} } } window.onload=IMB["IMOnLoad"]; IMB["sendf"]=true; IMB["ISSP"]=false; IMB["IMBInit"]=function(){ IMB["sendf"]=true; IMB["ISSP"]=false; if(window.innerWidth <= 768){IMB["ISSP"]=true;} } IMB["IMOnLoadFunc"].push(IMB["IMBInit"]); IMB["AfterLoadInnerHTML"]=function(d,data){ IMB["IMOnLoadFunc"].push(function(){document.getElementById(d).innerHTML=data;}); } IMB["IMPBridge"]=function(f){ IMP[f](); } IMB["presend"]=function(d,x,obj){ if(IMB["sendf"]){ IMB["sendf"]=false; if(IMB["AllValid"]()){ if(d){return x(IMB["AjaxRequest"]("POST",IMP["WebPrefix"]+"/",{"Content-Type":"application/x-www-form-urlencoded"},IMB["EncodeHTMLForm"](d)));} else{document.getElementById(obj).submit();} } else if(IMP["PresendValidReturn"]){IMP["PresendValidReturn"]();} IMB["sendf"]=true; } } IMB["EnterSubmit"]=function(e,obj){ if(`${e.code}` == "Enter"){IMB["presend"]("","",obj);} } IMB["EncodeHTMLForm"]=function(data){ let params=[]; for(let name in data){ let value=data[name]; let param=encodeURIComponent(name)+'='+encodeURIComponent(value); params.push(param); } return params.join('&').replace(/%20/g,'+'); } IMB["AjaxRequest"]=function(m,u,ct,d){ let ARajax; if(window.XMLHttpRequest){ARajax=new XMLHttpRequest();} else if(window.ActiveXObject){ try{ARajax=new ActiveXObject("Msxml2.XMLHTTP");} catch(e){ARajax=new ActiveXObject("Microsoft.XMLHTTP");} } IMB["CurrentAjaxRequest"]=ARajax; if(IMB["AjaxRequestAfterFunc"]){ if(m == "UP"){ if(IMP['AjaxRequestProgress']){ //let reader=new FileReader(); //reader.readAsBinaryString(document.getElementById(IMP['AjaxRequestCurrentSendFile']).files[0]); //reader.addEventListener('load',IMP['AjaxRequestRead']); ARajax.upload.addEventListener('progress',IMP['AjaxRequestProgress']); } m="POST"; } ARajax.addEventListener('readystatechange',(e)=>{ if((ARajax.readyState == 4) && (ARajax.status == 200)){ IMB["AjaxRequestAfterFunc"](ARajax.responseText); IMB["AjaxRequestAfterFunc"]=null; IMB["CurrentAjaxRequest"]=null; } }); ARajax.open(m,u,true); } else if(m == "UP"){alert("IMB['AjaxRequestAfterFunc'] not defined");return false;} else{ARajax.open(m,u,false);} for(let i in ct){ARajax.setRequestHeader(i,ct[i]);} ARajax.send(d); if(!IMB["AjaxRequestAfterFunc"]){ IMB["CurrentAjaxRequest"]=null; return ARajax.responseText; } } IMB['AjaxRequestGetWrap']=function(u,obj){ let msg=""; let f=false; if(obj == "retv"){} else if((obj) && (document.getElementById(obj))){obj=document.getElementById(obj);} else{obj="";} IMB["AjaxRequestGetWrapMsg"]=""; let result=IMB["AjaxRequest"]("GET",u,{},""); if(!result){msg="サーバーからの応答がありませんでした";} else if(result.substring(0,7) == "error: "){msg=result.substring(7);} else if(result.substring(0,9) == "success: "){ if(result.length > 9){ msg=result.substring(9); f=msg; } if(result == "success: "){ f=true; if(obj == "retv"){} else if(obj){obj.innerHTML="";} } } else{msg=result;} if(msg.length){ if(obj == "retv"){ if(!f){alert(msg);} } else if(obj){obj.innerHTML=msg;} else{alert(msg);} IMB["AjaxRequestGetWrapMsg"]=msg; } return f; } IMB["AjaxPost"]=function(SendData){ let result=IMB["AjaxRequest"]("POST",IMP["WebPrefix"]+"/",{"Content-Type":"application/x-www-form-urlencoded"},IMB["EncodeHTMLForm"](SendData)); if(!result){alert("サーバーからの応答がありませんでした");return false;} else if(result.substring(0,7) == "error: "){alert(result.substring(7));return false;} else if(result.substring(0,9) == "success: "){return result.substring(9);} else{alert(result);return false;} } IMB["Popup"]=function(u,m,d){ let result=""; if(d){result=d;} else{ result=IMB["AjaxRequest"]("GET",u,{},null); if(result.substring(0,7) == "error: "){alert(result);return false;} } document.getElementById("IMPopupPlate").innerHTML=result+'
'; document.getElementById("IMPopupPlate").style.display="block"; document.getElementById("IMPopupPlateBack"+m).style.display="block"; } IMB["PopupSize"]=function(w,h){ if(w == "auto"){document.getElementById("IMPopupPlate").style.width="auto";} else{ if(w > 100){w=100;} document.getElementById("IMPopupPlate").style.width=w+"vw"; } if(h == "auto"){document.getElementById("IMPopupPlate").style.height="auto";} else{ if(h > 100){h=100;} document.getElementById("IMPopupPlate").style.height=h+"vh"; } setTimeout("IMB['PopupCentering']()",10); } IMB["PopupCentering"]=function(){ document.getElementById("IMPopupPlate").style.left=(window.innerWidth-document.getElementById("IMPopupPlate").offsetWidth)/2+"px"; document.getElementById("IMPopupPlate").style.top=(window.innerHeight-document.getElementById("IMPopupPlate").offsetHeight)/2+"px"; } IMB["PopupHide"]=function(){ if("PopupHidePre" in IMP){ if(!IMP["PopupHidePre"]()){return false;} } document.getElementById("IMPopupPlate").style.display="none"; document.getElementById("IMPopupPlateBack").style.display="none"; document.getElementById("IMPopupPlateBackModal").style.display="none"; if("PopupHide" in IMP){IMP["PopupHide"]();} } IMB["ToasterInterval"]=10;// msec IMB["ToasterFadeSpan"]=250;// msec IMB["ToasterWaitSpan"]=500;// msec IMB["ToasterTimer"]=null; IMB["ToasterProgress"]=0; IMB["Toaster"]=function(s){ if(IMB["ToasterTimer"]){clearTimeout(IMB["ToasterTimer"]);} document.getElementById("IMToaster").innerHTML=decodeURI(s); IMB["ToasterWaitSpan"]=document.getElementById("IMToaster").innerHTML.length*100; document.getElementById("IMToaster").style.display="inline-block"; document.getElementById("IMToaster").style.left=((window.innerWidth/2)-(document.getElementById("IMToaster").offsetWidth/2))+"px"; document.getElementById("IMToaster").style.top=((window.innerHeight/2)+(document.getElementById("IMToaster").offsetHeight/2))+"px"; IMB["ToasterProgress"]=0; IMB["ToasterRun"](); } IMB["ToasterRun"]=function(){ if(IMB["ToasterProgress"] < IMB["ToasterFadeSpan"]){ document.getElementById("IMToaster").style.top=((window.innerHeight/2)+(document.getElementById("IMToaster").offsetHeight/2)-((document.getElementById("IMToaster").offsetHeight*(IMB["ToasterInterval"]/IMB["ToasterFadeSpan"]))*(IMB["ToasterProgress"]/IMB["ToasterInterval"])))+"px"; document.getElementById("IMToaster").style.opacity=(IMB["ToasterProgress"]/IMB["ToasterInterval"])*(100/(IMB["ToasterFadeSpan"]/IMB["ToasterInterval"]))/100; } else if(IMB["ToasterProgress"] < (IMB["ToasterFadeSpan"]+IMB["ToasterWaitSpan"])){ if(IMB["ToasterProgress"] == IMB["ToasterFadeSpan"]){ document.getElementById("IMToaster").style.top=((window.innerHeight/2)-(document.getElementById("IMToaster").offsetHeight/2))+"px"; document.getElementById("IMToaster").style.opacity=1; } } else if(IMB["ToasterProgress"] < ((IMB["ToasterFadeSpan"]*2)+IMB["ToasterWaitSpan"])){ document.getElementById("IMToaster").style.top=document.getElementById("IMToaster").style.top=((window.innerHeight/2)-(document.getElementById("IMToaster").offsetHeight/2)-((document.getElementById("IMToaster").offsetHeight*(IMB["ToasterInterval"]/IMB["ToasterFadeSpan"]))*((IMB["ToasterProgress"]-IMB["ToasterFadeSpan"]-IMB["ToasterWaitSpan"])/IMB["ToasterInterval"])))+"px";; document.getElementById("IMToaster").style.opacity=1-(((IMB["ToasterProgress"]-IMB["ToasterFadeSpan"]-IMB["ToasterWaitSpan"])/IMB["ToasterInterval"])*(100/(IMB["ToasterFadeSpan"]/IMB["ToasterInterval"]))/100); } else{ document.getElementById("IMToaster").style.top=((window.innerHeight/2)-(document.getElementById("IMToaster").offsetHeight*1.5))+"px"; document.getElementById("IMToaster").style.opacity=0; document.getElementById("IMToaster").style.display="none"; IMB["ToasterProgress"]=0; IMB["ToasterTimer"]=null; return true; } IMB["ToasterProgress"]+=IMB["ToasterInterval"]; IMB["ToasterTimer"]=setTimeout(IMB["ToasterRun"],IMB["ToasterInterval"]); } IMB["IsToaster"]=function(){ IMB["IsInitialAlert"](); if(document.cookie.indexOf("IMToaster=") >= 0){ let temp=document.cookie.split("IMToaster="); if(temp[1].substring(0,1) == '"'){IMB["Toaster"](temp[1].substring(1,temp[1].substring(1).indexOf('"')+1));} else if(temp[1].substring(0,1) == "'"){IMB["Toaster"](temp[1].substring(1,temp[1].substring(1).indexOf("'")+1));} else{IMB["Toaster"](temp[1].split(";")[0]);} document.cookie="IMToaster=; max-age=0"; } } IMB["IsInitialAlert"]=function(){ if(document.cookie.indexOf("IMInitialAlert=") >= 0){ let temp=document.cookie.split("IMInitialAlert="); if(temp[1].substring(0,1) == '"'){alert(decodeURI(temp[1].substring(1,temp[1].substring(1).indexOf('"')+1)));} else if(temp[1].substring(0,1) == "'"){alert(decodeURI(temp[1].substring(1,temp[1].substring(1).indexOf("'")+1)));} else{alert(decodeURI(temp[1].split(";")[0]));} document.cookie="IMInitialAlert=; max-age=0"; } } IMB["NowUploadObj"]=null; IMB["NowUploadStat"]=false; IMB["NowUploadResult"]=""; IMB['UpFileSelect']=function(d){ if(document.getElementById("IMFileForm-"+d)){document.getElementById("IMFileForm-"+d).click();} else{alert("要素 IMFileForm-"+d+" が存在しません");} } IMB['FileUpload']=function(obj,sm,ct){ if(obj.id.substring(0,11) != "IMFileForm-"){alert("要素のidの形式が正しくありません "+obj.id);return false;} if(obj.id.length < 12){alert("要素のidの形式が正しくありません "+obj.id);return false;} if(IMB["NowUploadObj"]){alert("現在、他のアップロード処理が進行中です。しばらくお待ちください。");return false;} if(sm){ if(obj.files.length > 1){alert("アップロードするファイルは1度に1つです");return false;} } let c=0; for(let i=0;i < obj.files.length;i++){ if(ct == "image"){ if((IMP["FileAcceptable"]) && (IMP["FileAcceptable"][obj.id])){ if(IMP["FileAcceptable"][obj.id].indexOf(","+obj.files[i].type+",") >= 0){} else{alert("想定されているファイル形式ではないファイルが含まれています");return false;} } else if(obj.files[i].type.match(/image.*/)){} else{ ext=obj.files[i].name.split('.').pop().toLowerCase(); if(ext === 'heic' || ext === 'heif'){} else{alert("想定されているファイル形式ではないファイルが含まれています");return false;} } c++; } else if(ct == "movie"){ if((IMP["FileAcceptable"]) && (IMP["FileAcceptable"][obj.id])){ if(IMP["FileAcceptable"][obj.id].indexOf(","+obj.files[i].type+",") >= 0){} else{alert("想定されているファイル形式ではないファイルが含まれています");return false;} } else if(obj.files[i].type.match(/video\/*/)){} else{alert("想定されているファイル形式ではないファイルが含まれています");return false;} c++; } else{ if((IMP["FileAcceptable"]) && (IMP["FileAcceptable"][obj.id])){ if(IMP["FileAcceptable"][obj.id].indexOf(","+obj.files[i].type+",") >= 0){} else{alert("想定されているファイル形式ではないファイルが含まれています");return false;} } c++; } } if(c == 0){alert("アップロードするファイルはありませんでした");return false;} if(IMP["PreFileUploadSend"]){ if(!IMP["PreFileUploadSend"](obj,c)){return false;} } if(document.getElementById("IMFileFormStat-"+obj.id.substring(11))){document.getElementById("IMFileFormStat-"+obj.id.substring(11)).innerHTML="アップロード中";} if(IMP['NowUploadFunc']){IMP['NowUploadFunc']();} IMB["NowUploadObj"]=obj; setTimeout("IMB['FileUploadSend']()",10); } IMB["FileUpIndex"]=0; IMB["FileUploadSend"]=function(){ let fd=new FormData(); fd.append('rev','contents//lib/FileUp'); fd.append("file",IMB["NowUploadObj"].files[IMB["FileUpIndex"]]); if(IMP["FileUpOption"]){ for(let i in IMP["FileUpOption"]){fd.append(i,IMP["FileUpOption"][i]);} } IMB["NowUploadStat"]=false; IMB["AjaxRequestAfterFunc"]=IMB["FileUpFinalize"]; IMB["AjaxRequest"]('UP',IMP["WebPrefix"]+'/',{},fd); } IMB["FileUpFinalize"]=function(d){ if(!d){alert("no response");IMB["NowUploadObj"]=null;return false;} else if(d.substring(0,7) == "error: "){alert(d.substring(7));IMB["NowUploadObj"]=null;return false;} else if(d.substring(0,9) == "success: "){IMB["NowUploadStat"]=true;IMB["NowUploadResult"]=d.substring(9);} else{alert("unknown error "+d);IMB["NowUploadObj"]=null;return false;} //プレビューに画像表示含め、要素の再構築(input type=file には値が入ってしまっているので、タグを空にする意味でも要素再構築が必要) if(IMP["FileUpFinalize"]){IMP["FileUpFinalize"](d.substring(9));} IMB["NowUploadResult"]=""; IMB["FileUpIndex"]++; if(IMB["NowUploadObj"].files[IMB["FileUpIndex"]]){ if(IMP['NowUploadFunc']){IMP['NowUploadFunc']();} setTimeout("IMB['FileUploadSend']()",10); } else{ IMB["FileUpIndex"]=0; IMB["NowUploadStat"]=false; IMB["NowUploadObj"]=null; } } IMB['IMSNFileUpload']=function(n,f){ if(IMB["NowUploadObj"]){alert("現在、他のアップロード処理が進行中です。しばらくお待ちください。");return false;} IMB["NowUploadObj"]=n; let fd=new FormData(); fd.append('rev','contents//lib/FileUp'); fd.append("file",f); fd.append("ResizePreset",IMP["IMSNFileUpOption"][IMB["NowUploadObj"]]["ResizePreset"]); fd.append("ImageTag",IMP["IMSNFileUpOption"][IMB["NowUploadObj"]]["ImageTag"]); IMB["NowUploadStat"]=false; IMB["AjaxRequestAfterFunc"]=IMB["IMSNFileUpFinalize"]; IMB["AjaxRequest"]('UP',IMP["WebPrefix"]+'/',{},fd); } IMB["IMSNFileUpFinalize"]=function(d){ if(!d){alert("no response");IMB["NowUploadObj"]=null;return false;} else if(d.substring(0,7) == "error: "){alert(d.substring(7));IMB["NowUploadObj"]=null;return false;} else if(d.substring(0,9) == "success: "){} else{alert("unknown error "+d);IMB["NowUploadObj"]=null;return false;} //プレビューに画像表示含め、要素の再構築(input type=file には値が入ってしまっているので、タグを空にする意味でも要素再構築が必要) let tmp=d.substring(9).split("/"); let img=$("