')}else{$('#modalImageFooter').addClass('d-none')}});$('#imgMain').attr('src',imgSrc[0]);modalImage.show()}};let viewThumbnail=function(imgSrc){$('#imgMain').attr('src',imgSrc)};$(document).ready(function(){modalImage=new bootstrap.Modal('#modalImage',{keyboard:true});modalAlertPayment=new bootstrap.Modal('#modalAlertPayment',{keyboard:true});if($('.btnBuy').length){$('.btnBuy').click(function(){let btnClicked=$(this);let itemId=btnClicked.attr('data-id');buy(itemId)})}});let buy=function(itemId){let domain=$('#btnBuy'+itemId).attr('data-domain');let message='ドメイン「{domain}」の購入を行うと、クレジットカード決済が行われます。購入を行いますか?';$.confirm({theme:theme,title:'本当に購入しますか?',content:message.replace('{domain}',domain),columnClass:'col-md-3 col-sm-6',buttons:{removeButton:{text:'はい',btnClass:'btn-primary',action:function(){$('#btnBuy'+itemId).html('');$('#btnBuy'+itemId).addClass('disabled');let bodyFormData=new FormData();bodyFormData.append('id',itemId);axios({method:"post",url:"/user/market-buy/",data:bodyFormData,headers:{"Content-Type":"multipart/form-data"},}).then(function(response){$('#btnBuy'+itemId).removeClass('disabled');if(response.data.status=='failed'){if(response.data.action=='ALERT_PAYMENT'){$('#btnBuy'+itemId).html('購入する');modalAlertPayment.show()}else{bs5Utils.Snack.show('danger',response.data.message,delay=5000,dismissible=true)}}if(response.data.status=='success'){bs5Utils.Snack.show('success','成功',delay=5000,dismissible=true);if(response.data.action=='ORDERED'){$('#btnBuy'+itemId).removeClass('btn-outline-primary');$('#btnBuy'+itemId).addClass('btn-outline-success');$('#btnBuy'+itemId).html('キャンセル')}else{$('#btnBuy'+itemId).addClass('btn-outline-primary');$('#btnBuy'+itemId).removeClass('btn-outline-success');$('#btnBuy'+itemId).html('購入する');$('#tr'+itemId).remove()}}}).catch(function(data){$('#btnBuy'+itemId).html('購入する');$('#btnBuy'+itemId).removeClass('disabled');bs5Utils.Snack.show('danger','Error, please login again.',delay=5000,dismissible=true);if(data.response.status==403){setTimeout(()=>{location.href='https://backorder.jp/login'},3000)}else{setTimeout(()=>{location.reload()},3000)}})}},close:{text:'閉じる',action:function(){}}}})};