`; $('#deleteReasonModal .modal-body').html(result); $('#deleteReasonModal').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'}); } } }); } } function confirmDelete() { var mem_id = ''; var device_id = ''; var web_id = $('#delete_web_id').val(); var reason_id = $('input[name=reason_delete_id]:checked').val(); var reason_other = $.trim($('input[name=reason_delete_name]').val()); var sub_mem_id = ''; var sub_device_id = ''; $.ajax({ url: 'https://api.livinginsider.com/my_living_topic_delete.php', type: 'POST', data: { mem_id: mem_id, device_id: device_id, device_type: 1, web_id: web_id, web_delete_reason_id: reason_id, web_delete_reason_text: reason_other, sub_mem_id: sub_mem_id, sub_device_id: sub_device_id }, dataType: 'json', success: function (data) { if (data.result_code == 0) { bootbox.alert({ message: 'Completely delete', size: 'small', callback: function () { location.reload(); } }); } else { bootbox.alert({ message: data.result_msg, size: 'small', callback: function () { location.href = 'https://www.livinginsider.com/logout.php'; } }); } }, error: function (err) { bootbox.alert({ message: err, size: 'small' }); } }); } function rangeSuccess(val){ $('#rangeSuccess').text(val); $('.focused').attr('value',val); } function Calculation_installment(){ let age = $('[name=age_c]').val(); let term = 60 - age; let loan = $('[name=price_cal]').val(); let apr = $('[name=interest]').val(); let txterror = ""; let gender = $("input[name='gender']:checked").val(); $('[name=age_c]').removeClass('red'); $('[name=price_cal]').removeClass('red'); $('[name=interest]').removeClass('red'); $('.error-show-text').text(''); $('.focused').attr('max',term); $('.focused').attr('value',term); if($.cookie("PMT_age_c")==null || $.cookie("PMT_age_c") != age){ $.cookie("PMT_age_c", age); term = 60 - age; $('.focused').attr('min',1).attr('max',term).val(1).val(term); }else{ term = $('.focused').val(); $('.focused').attr('min',1).val(1).val(term); } if(age < 20){ txterror = '** อายุของท่านน้อยเกินไป **'; $('.error-show-text').text(txterror); $('[name=age_c]').addClass('red'); $('.focused').attr('max',0); $('.focused').attr('value',0); $('#rangeSuccess').text(0); return false; } if(age >= 60){ txterror = '** อายุของท่านมากเกินไป **'; $('.error-show-text').text(txterror); $('[name=age_c]').addClass('red'); $('.focused').attr('max',0); $('.focused').attr('value',0); $('#rangeSuccess').text(0); return false; } if(age == ""){ txterror = '** กรุณาระบุอายุของท่าน **'; $('.error-show-text').text(txterror); $('[name=age_c]').addClass('red'); $('.focused').attr('max',0); $('.focused').attr('value',0); $('#rangeSuccess').text(0); return false; } if((loan != undefined && parseInt(loan.replace(/,/g, '')) < 100000)|| loan == "" ){ txterror = '** กรุณาระบุราคาอสังหาฯ มากกว่า 100,000 บาทขึ้นไป **'; $('.error-show-text').text(txterror); $('[name=price_cal]').addClass('red'); $('.focused').attr('max',0); $('.focused').attr('value',0); $('#rangeSuccess').text(0); return false; } if(apr == "" || apr == 0.00 || (apr > 0.01 && apr > 100.00)){ txterror = '** กรุณาระบุอัตราดอกเบี้ยตั้งแต่ 0.01%-100% **'; $('.error-show-text').text(txterror); $('[name=interest]').addClass('red'); $('.focused').attr('max',0); $('.focused').attr('value',0); $('#rangeSuccess').text(0); return false; } PMT(loan,term,apr,gender,age); } function PMT(loan,term,apr,gender,age){ $.ajax({ url: 'https://www.livinginsider.com/PMT_function.php', type: 'post', data: { 'loan':loan,'term':term,'apr':apr,'check_case':'PMT','gender':gender,'age':age }, dataType: 'json', beforeSend: function(jqXHR, settings) { delete jqXHR.setRequestHeader('X-CSRF-TOKEN'); }, }).fail(function(xhr,st,err){ // console.log(xhr.responseText) }).done(function(data){ graf_ccl(data.pro); $('.percentage').text(data.total_format); $('.salary-p').text(data.total_salary); $('#rangeSuccess').text(term); $('[name=range]').attr('value',term); $('.txt-Installment').text(data.total_format+" บาท/เดือน"); $('.txt-salary').text(data.total_salary+" บาท/เดือน"); $('#total-radius').attr('stroke-dasharray', data.pro+" 100"); }); } function graf_ccl (pro) { if(pro == undefined){ pro = 0; } var totalVisitors = 100; var count = totalVisitors - pro; if(count == 50){ pro = 33.33; count = 66.66; } var visitorsData = { "New vs Returning Visitors": [{ cursor: "pointer", explodeOnClick: false, innerRadius: "75%", legendMarkerType: "square", name: "New vs Returning Visitors", radius: "100%", showInLegend: false, startAngle: 90, type: "doughnut", dataPoints: [ {y:count,color: "#c7c7c7"}, {y:pro,color: "#13bb9a"} ] }], }; // var chart = new CanvasJS.Chart("chartContainer"); // chart.options.data = visitorsData["New vs Returning Visitors"]; // chart.render(); } var markers=[]; var ckActive=""; function click_gen_markers(opj){ ck = 0; $('.btn-loca-tion').removeClass('marker-active'); $('.box-name-manu-map').removeClass('active'); $(opj).addClass('active'); $('.img-notdatamap').css('display','none'); $('.box-link-google-map').each(function(index,opjs){ if($(opj).attr('data-ckmarker')==$(opjs).attr('data-imgloc')||$(opj).attr('data-ckmarker')=='All'){ $(opjs).addClass('active-open'); $(opjs).removeClass('active-close'); ck = 1 }else{ $(opjs).removeClass('active-open'); $(opjs).addClass('active-close'); } }); if(ck == 0){ $('.btn-full-screen').css('display','none'); $('.img-notdatamap').css('display','block'); }else{ $('.btn-full-screen').css('display','block'); $('.img-notdatamap').css('display','none'); } Active = $(opj).text(); if(Active!=ckActive){ ckActive = $(opj).text(); initAutocomplete(); } } function click_gen_marker_text(opjs){ $('.btn-loca-tion').removeClass('marker-active'); $(opjs).addClass('marker-active'); Active = $(opjs).attr('title'); if(Active!=ckActive){ ckActive = $(opjs).attr('title'); initAutocomplete(); } } var map = null; function initAutocomplete() { const directionsRenderer = new google.maps.DirectionsRenderer({ suppressMarkers: true, polylineOptions: { strokeColor: '#13bb9a8f', strokeWeight: 5, } }); const directionsService = new google.maps.DirectionsService(); const originalMapCenter = new google.maps.LatLng(Number('13.725793056117164'), Number('100.57054225396723')); const map = new google.maps.Map(document.getElementById("map"), { center: originalMapCenter, zoom: 14, mapTypeId: "roadmap", }); let infowindows = []; let url_center_map ='https://www.google.com/maps/search/?api=1&query='+Number('13.725793056117164')+','+Number('100.57054225396723'); if('1'=='1' && 'Lette Dwell Sukhumvit 26' != ''){ url_center_map = "https://www.google.com/maps/search/?api=1&query="+'Lette Dwell Sukhumvit 26'; } const contentString =''+$('.locationdetail-pj').text()+''; const infowindow = new google.maps.InfoWindow({ content: contentString, }); const marker = new google.maps.Marker({ position: originalMapCenter, map, icon:'https://www.livinginsider.com/assets18/images/icon/mind.svg' }); infowindow.open(map, marker); marker.addListener("click", () => { infowindow.open(map, marker); }); if($('.marker-active').length==0){ $('.box-link-google-map.active-open').each(function(i,a){ let latData = $(a).attr('data-lat'); let lngData = $(a).attr('data-lng'); let img = $(a).attr('data-imgloc'); let url = "https://www.google.com/maps/dir/?api=1&origin="+Number('13.725793056117164')+','+Number('100.57054225396723')+"&destination="+latData+','+lngData+"&travelmode=driving"; url = encodeURI(url); let html_a = ' '+$(a).attr('title')+' '; var marker = new google.maps.Marker({ position: {lat:Number(latData),lng:Number(lngData)}, map: map, icon:'https://www.livinginsider.com/assets18/images/icon/'+img }); var infowindow = new google.maps.InfoWindow({ content: html_a }); markers.push(marker); infowindows.push(infowindow); listenMarker(marker); function listenMarker(marker) { google.maps.event.addListener(marker,'click',(function(marker,infowindow){ return function() { infowindow.open(map,marker); }; })(marker,infowindow)); } }); } else{ let latData = $('.marker-active').attr('data-lat'); let lngData = $('.marker-active').attr('data-lng'); let km = $('.marker-active>p').text(); km = km.replace(" Km.", ""); let img = $('.marker-active').attr('data-imgloc'); let html_a = ' '+$('.marker-active').attr('title')+' '; let destination_originalMap = new google.maps.LatLng(Number(latData), Number(lngData)); const markerA = new google.maps.Marker({ position: destination_originalMap, map: map, icon:'https://www.livinginsider.com/assets18/images/icon/'+img }); const infowindowA = new google.maps.InfoWindow({ content: html_a }); infowindowA.open(map, markerA); markerA.addListener("click", () => { infowindowA.open(map, markerA); }); directionsRenderer.setMap(map); calculateAndDisplayRoute(directionsService, directionsRenderer, originalMapCenter,destination_originalMap,img,Number(km)); } } function calculateAndDisplayRoute(directionsService, directionsRenderer ,originalMapCenter,destination_originalMap,img_destination,km) { // var typedirections = 'WALKING'; // if(km>=1.4){ var typedirections = 'DRIVING'; // } var request = { origin: originalMapCenter, destination: destination_originalMap, travelMode: google.maps.TravelMode[typedirections], }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsRenderer.setDirections(response); makeMarker( originalMapCenter, 'https://www.livinginsider.com/assets18/images/icon/mind.svg'); makeMarker( destination_originalMap, 'https://www.livinginsider.com/assets18/images/icon/'+img_destination ); } }); } function makeMarker( position, icon ) { new google.maps.Marker({ position: position, map: map, icon: icon, }); } function openlink(opj){ $('.manage-box-link').removeClass('active'); $('.box-link-map').removeClass('active'); $('.box-map-l>i').removeClass('fa-angle-up'); $('.box-map-l>i').addClass('fa-angle-right'); let opjs = $(opj).parent(); if($('.manage-box-link',opjs).hasClass('active')==false){ $('i',opj).removeClass('fa-angle-right'); $('i',opj).addClass('fa-angle-up'); $('.manage-box-link',opjs).addClass('active'); $(opjs).addClass('active'); }else{ $('i',opj).removeClass('fa-angle-up'); $('i',opj).addClass('fa-angle-right'); $('.manage-box-link',opjs).removeClass('active'); $(opjs).removeClass('active'); $(opj).attr('data-st',0) }; } function appent_script_map(opjs){ let ckAppent = $(opjs).attr('data-ckAppent'); if($('#nearbyProperty').length>0 && ckAppent == '1'){ $( "#nearbyProperty" ).clone().prependTo( "#nearbyProperty_map" ); var html_a = ""; $("#nearbyProperty_map li").each(function(i,h){ let km = $('.marker-active>p').text(); km = km.replace(" Km.", ""); // active-open html_a += ''+ '