`; $('#reportReasonModal .modal-body').html(result); $('#reportReasonModal').modal('show'); } }, error: function(jqXHR, textStatus, errorThrown) { if(jqXHR.status==401) { bootbox.alert({ message: 'เกิดข้อผิดพลาด กรุณา Log In ใหม่อีกครั้ง', size: 'small', callback: function () { window.location.reload(); } }); } else { bootbox.alert({message: textStatus,size: 'small'}); } } }); }else{ if($('#loginModal').length > 0){ $("#login-action").val("self"); $('#loginModal').modal('show'); }else{ bootbox.alert({ message: "Please login again.", 'size':'small', callback: function () { location.reload(); } }); } } }); } function checkSession(callback){ $.ajax({ url: 'https://www.livinginsider.com/a_check_session.php', type: 'post', dataType: 'json', success: function (data) { if(typeof callback == 'function'){ callback(data); } }, error: function (err) { console.error(err); } }); } function confirmReport(){ var web_id = $('#report_web_id').val(); var reason_id = $('input[name=reason_report_id]:checked').val(); var reason_other = $.trim($('input[name=reason_report_name]').val()); checkSession(function(data){ if(data.result == 1){ if (!check_session) { $("#login-action").val("self"); $("#loginFB-action").val("other"); $("#loginModal").modal(); let array = { 'status': '1', 'web_id': web_id, 'reason_id':reason_id , 'reason_other': reason_other, 'url' : window.location.href } localStorage.setItem('modalReportTopic', JSON.stringify(array)); } else { if(reason_id == 8 && reason_other==''){ bootbox.alert({ message: 'โปรดระบุข้อความ', size: 'small', callback: function (){ send_report(web_id); } }); } else { add_report(web_id, '', reason_id, reason_other); } } }else{ bootbox.alert({ message: "Please login again.", 'size':'small', callback: function () { location.reload(); } }); } }); } function add_report(inform_web_id, inform_reply_id, inform_choose, inform_comment) { var form_data = { inform_type: 2, inform_web_id: inform_web_id, inform_reply_id: inform_reply_id, inform_comment: inform_comment, inform_choose: inform_choose }; $.ajax({ url: 'https://www.livinginsider.com/a_delete_inform.php', type: 'post', data: form_data, dataType: 'json', success: function (data) { var obj = data if (obj.status == true) { var errMsg = obj.error; } else { var errMsg = obj.msg + obj.error; } bootbox.alert({ message: errMsg, size: 'small' }); }, error: function (err) { bootbox.alert({ message: err, size: 'small' }); } }); } function actionReadmore(category, action, label){ gaEvent(category, action, label); $('.block-review.main').addClass('readmore'); $('.block_readmore').hide(); } let mySocket; $('#chatmodal').on('show.bs.modal', function (e) { // ? do something }).on('hidden.bs.modal', function (e) { // ? do something }); $().delegate('' , 'click' , function(){ }) function send_mail(){ if($('#name').val()==''){ bootbox.alert({ message: 'Please enter your name', size: 'small' }); return false; } if($('#phone').val()==''){ bootbox.alert({ message: 'Please enter your phone no.', size: 'small' }); return false; } else{ if($('#phone').val().length != 9 && $('#phone').val().length != 10){ bootbox.alert({ message: 'Please fill in the phone number to complete 10 digits.', size: 'small' }); return false; } var check = isPhone($('#phone').val()) if(check == false) { bootbox.alert({ message: 'Please check your phone', size: 'small' }); return false; } } if($('#email').val()==''){ bootbox.alert({ message: 'Please enter your email', size: 'small' }); return false; } else{ var check = isEmail($('#email').val()) if(check == false) { bootbox.alert({ message: 'Please check your email', size: 'small' }); return false; } } if($('#message').val()==''){ bootbox.alert({ message: 'Please enter your message', size: 'small' }); return false; } const form_data = { name: $('#name').val(), phone: $('#phone').val(), email: $('#email').val(), message: $('#message').val(), owner_id: '130432', wed_id: '750588', owner_link: decodeURIComponent(window.location.href) }; $.ajax({ url: 'https://www.livinginsider.com/a_contact.php', type: 'post', data: form_data, dataType: 'json', success: function (data) { var obj = data if (obj.result == 1) { bootbox.alert({ message: 'Send email successful.', size: 'small', callback: function(){ $('#name').val(''); $('#phone').val(''); $('#email').val(''); $('#message').val(''); $('#contractOwnerModal').modal('hide'); } }); } else { bootbox.alert({ message: 'Please try again', size: 'small' }); } }, error: function (err) { bootbox.alert({ message: err, size: 'small' }); } }); } function send_mail_photo_contact(){ if($('#contact-name').val()==''){ bootbox.alert({ message: 'Please enter your name', size: 'small' }); return false; } if($('#contact-phone').val()==''){ bootbox.alert({ message: 'Please enter your phone no.', size: 'small' }); return false; } else{ if($('#contact-phone').val().length != 9 && $('#contact-phone').val().length != 10){ bootbox.alert({ message: 'Please fill in the phone number to complete 10 digits.', size: 'small' }); return false; } var check = isPhone($('#contact-phone').val()) if(check == false) { bootbox.alert({ message: 'Please check your phone', size: 'small' }); return false; } } if($('#contact-email').val()==''){ bootbox.alert({ message: 'Please enter your email', size: 'small' }); return false; } else{ var check = isEmail($('#contact-email').val()) if(check == false) { bootbox.alert({ message: 'Please check your email', size: 'small' }); return false; } } if($('#contact-detail').val()==''){ bootbox.alert({ message: 'Please enter your message', size: 'small' }); return false; } const form_data = { name: $('#contact-name').val(), phone: $('#contact-phone').val(), email: $('#contact-email').val(), message: $('#contact-detail').val(), owner_id: '130432', wed_id: '750588', owner_link: decodeURIComponent(window.location.href) }; $.ajax({ url: 'https://www.livinginsider.com/a_contact.php', type: 'post', data: form_data, dataType: 'json', beforeSend: function() { $('.contact-btn-block-footer').html(` Emailing to the owner of the post.`); $( ".contact-btn-block-footer" ).prop( "disabled", true ); }, success: function (data) { var obj = data if (obj.result == 1) { bootbox.alert({ message: 'Send email successful.', size: 'small', callback: function(){ $('#contact-name').val(''); $('#contact-phone').val(''); $('#contact-email').val(''); $('#contact-detail').val(''); $('.contact-btn-block-footer').html(` Send email to owner post.`); $( ".contact-btn-block-footer" ).prop( "disabled", false ); } }); } else { bootbox.alert({ message: 'Please try again', size: 'small' }); } }, error: function (err) { bootbox.alert({ message: err, size: 'small' }); } }); } function isEmail(email) { var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; if(filter.test(email)){ return true; } else { return false; } } function isPhone(phone) { var filter = /([0-9]{10})|(\([0-9]{3}\)\s+[0-9]{3}\-[0-9]{4})/; if(filter.test(phone)){ return true; } else { return false; } } function actionEdit(web_id, currentpage){ // sessionStorage.setItem("currentpage", currentpage); location.href = 'https://www.livinginsider.com/living_edit.php?topic_id='+web_id+'&currentID='+web_id; } function check_switch(web_id) { const mem_id = ''; const device_id = ''; const sub_mem_id = ''; const sub_device_id = ''; $.ajax({ url: 'https://api.livinginsider.com/living_close_reason.php', type: 'post', data: { mem_id: mem_id, device_id: device_id, device_type: 1, lang:"EN", sub_mem_id: sub_mem_id, sub_device_id: sub_device_id }, dataType: 'json', success: function (data) { if(data.result_code == 0){ let result = ` `; data.reason.forEach(e => { result += `