// var APIUrl = 'http://localhost/qianjin-api/api/'; const listOfImage = []; var cloudFrontURL = "https://dnmr4h3lrek8m.cloudfront.net/" var APIUrl = 'https://zak-ems-api.herokuapp.com/api/'; // var APIUrl = "http://localhost/qianjin-api/api/"; function viewStaffDetails(id) { window.location.href = "staff-details.html?id=" + id } var staffsData; function $_GET(q, s) { s = s ? s : window.location.search; var re = new RegExp("&" + q + "=([^&]*)", "i"); return (s = s.replace(/^\?/, "&").match(re)) ? (s = s[1]) : (s = ""); } function getStaff(searchType, searchContent) { var noUrl = "https://dnmr4h3lrek8m.cloudfront.net/no-image.png"; if (searchType == "all") { $.ajax({ url: APIUrl + "getAllStaffFeatured", async: false, dataType: "json", type: "post", success: function (data) { staffsData = data; var staffHtml = ""; staffsData.forEach(staff => { let id = " " let profile_pic_url = " "; let staffName = " "; let area = " "; let location = " "; let location_cn = " "; let price = " "; let price2 = " "; let customer_view = " "; id = staff['id']; profile_pic_url = staff['key'] == null ? noUrl : staff['key']; profile_pic_url = cloudFrontURL + profile_pic_url; staffName = staff['name']; area = staff['area']; location = staff['location']; location_cn = staff['location_cn']; price = staff['price']; price2 = staff['price2']; customer_view = staff['customer_view']; is_featured = staff['is_featured'] === "t" ? "visible" : "hidden"; is_massage = staff['is_massage'] === "t" ? "visible" : " hidden"; // let area= staff['area']; featuredLabelSetting = '' othersLabelSetting = '' staffHtml += '
  • ' + featuredLabelSetting + othersLabelSetting + '

    ' + staffName + '

    ' + location + '  


    ' + location_cn + '  

    ' + area + '

    ' + price + '

    ' + price2 + '

  • '; }); $('#staffList').append(staffHtml); } }); } else if (searchType == "category") { $.ajax({ url: APIUrl + "getAllStaffCategoryBased", async: false, dataType: "json", type: "post", data: { "area": searchContent }, success: function (data) { staffsData = data; var staffHtml = ""; staffsData.forEach(staff => { let id = " " let profile_pic_url = " "; let staffName = " "; let area = " "; let location = " "; let location_cn = " "; let price = " "; let price2 = " "; let customer_view = " "; id = staff['id']; profile_pic_url = staff['key'] == null ? noUrl : staff['key']; profile_pic_url = cloudFrontURL + profile_pic_url; staffName = staff['name']; area = staff['area']; location = staff['location']; location_cn = staff['location_cn']; price = staff['price']; price2 = staff['price2']; customer_view = staff['customer_view']; is_featured = staff['is_featured'] === "t" ? "visible" : "hidden"; is_massage = staff['is_massage'] === "t" ? "visible" : " hidden"; // let area= staff['area']; featuredLabelSetting = '' othersLabelSetting = '' staffHtml += '
  • ' + featuredLabelSetting + othersLabelSetting + '

    ' + staffName + '

    ' + location + '  


    ' + location_cn + '  

    ' + area + '

    ' + price + '

    ' + price2 + '

  • '; }); $('#staffList').append(staffHtml); } }); } else if (searchType == "search") { $.ajax({ url: APIUrl + "getAllStaffCategoryBasedV2", async: false, dataType: "json", type: "post", data: { "search": searchContent }, success: function (data) { staffsData = data; var staffHtml = ""; if (staffsData.length > 0) { console.log(staffsData); staffsData.forEach(staff => { let id = staff['id']; let profile_pic_url = staff['key'] == null ? noUrl : staff['key']; profile_pic_url = cloudFrontURL + profile_pic_url; let staffName = staff['name']; let area = staff['area']; let location = staff['location']; let price = staff['price']; let price2 = staff['price2']; // let area= staff['area']; let customer_view = " "; customer_view = staff['customer_view']; staffHtml += '

  • ' + location + '

    ' + staffName + '

    ' + location + '  (' + customer_view + ')

    ' + area + '

    ' + price + '

    ' + price2 + '

  • '; }); $('#staffList').append(staffHtml); } } }); } } function getStaffOthers() { var noUrl = "https://qianjin-gallery.s3.ap-southeast-1.amazonaws.com/no-image.png"; $.ajax({ url: APIUrl + "getAllStaffOthers", async: false, dataType: "json", type: "post", success: function (data) { staffsData = data; var staffHtml = ""; if (staffsData.length > 0) { staffsData.forEach(staff => { let id = staff['id']; let profile_pic_url = staff['key'] == null ? noUrl : staff['key']; profile_pic_url = cloudFrontURL + profile_pic_url; let staffName = staff['name']; let area = staff['area']; let location = staff['location']; let location_cn = staff['location_cn']; let price = staff['price']; let price2 = staff['price2']; // let area= staff['area']; is_featured = staff['is_featured'] === "t" ? "visible" : "hidden"; is_massage = staff['is_massage'] === "t" ? "visible" : " hidden"; // let area= staff['area']; let customer_view = " "; customer_view = staff['customer_view']; featuredLabelSetting = '' othersLabelSetting = '' staffHtml += '
  • ' + featuredLabelSetting + othersLabelSetting + '

    ' + staffName + '

    ' + location + '  


    ' + location_cn + '  

    ' + area + '

    ' + price + '

    ' + price2 + '

  • '; }); } $('#staffListOthers').append(staffHtml); } }); } function getPopularStaff() { var noUrl = "https://qianjin-gallery.s3.ap-southeast-1.amazonaws.com/no-image.png"; $.ajax({ url: APIUrl + "getAllPopularStaff", async: false, dataType: "json", type: "post", success: function (data) { staffsData = data; var staffSideHtml = ""; staffsData.forEach(staff => { let id = staff['id']; let profile_pic_url = staff['key'] == null ? noUrl : staff['key']; profile_pic_url = cloudFrontURL + profile_pic_url; let staffName = staff['name']; let area = staff['area']; let location = staff['location']; let location_cn = staff['location_cn']; let price = staff['price']; let price2 = staff['price2']; // let area= staff['area']; is_featured = staff['is_featured'] === "t" ? "visible" : "hidden"; is_others = staff['is_others'] === "t" ? "visible" : " hidden"; // let area= staff['area']; featuredLabelSetting = '' othersLabelSetting = '' staffSideHtml += '
  • ' + featuredLabelSetting + othersLabelSetting + '

    ' + staffName + '

    ' + location + ' 


    ' + location_cn + '  

    ' + area + '

    ' + price + '

    ' + price2 + '

  • ' }); $('#popularStaffList').append(staffSideHtml); } }); } function $_GET(q, s) { s = s ? s : window.location.search; var re = new RegExp("&" + q + "=([^&]*)", "i"); return (s = s.replace(/^\?/, "&").match(re)) ? (s = s[1]) : (s = ""); } /////* Declare variables *///// function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) { vars[key] = value; }); return vars; } function callWhatsapp(phoneNo) { window.open("https://wa.me/" + phoneNo); console.log(phoneNo) event.preventDefault(); } function openPhotoSwipe(url) { var pswpElement = document.querySelectorAll('.pswp')[0]; // build items array console.log(listOfImage) console.log(url) console.log() const index = listOfImage.findIndex((element, index) => { if (element.src === url) { return true } }) console.log(index) // define options (if needed) var options = { // history & focus options are disabled on CodePen index: index, history: false, focus: false, showAnimationDuration: 1, hideAnimationDuration: 0 }; var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, listOfImage, options); gallery.init(); }; function getComment() { $.ajax({ url: APIUrl + 'getComment', type: 'POST', dataType: 'JSON', data: { "staff_id": staffId, }, //TODO:: CompanyPhoneNo, Attention_MarketingOfficer, Attention_Company // to do API.php user, createDateTime, completeUser, completeDateTime, attentionTo success: function (data) { // window.location = "staff-view.html"; const format1 = "YYYY-MM-DD HH:mm:ss" var commentFormHtml = ""; commentFormHtml += '

    Your comment

       
    Submit
    ' $('#listOfComment').append(commentFormHtml); data.forEach(comment => { var commentHtml = ""; let dateTime1 = moment(comment["date_time"]).format(format1); commentHtml += '

    ' + comment.name + '

    ' + dateTime1 + '

    ' + comment.message + '

    Reply
    ' getReply(comment.id, commentHtml) }); }, error: function (data) { alert("Add staff fail"); } }); } function getStaffData() { var staffId = $_GET('id'); if (staffId == "") { window.location.href = "index.html" } $.ajax({ url: APIUrl + "getStaff", async: false, dataType: "json", type: "post", data: { "id": staffId }, success: function (data) { const is_active = data['personal'][0].is_active; console.log("is_active",is_active); if(is_active=="f"){ window.location ="index.html";} else{ var staffPersonal = data['personal'][0]; var staffGallery = data['gallery']; var staffServices = data['services']; var staffPersonalHtml = ""; var staffPersonalContactHtml = ""; var staffServicesHtml = ""; var staffPersonalImageHtml = ""; var staffImageHtml = ""; var staffVideoHtml = ""; staffPersonalImageHtml += '
    '; // let id = staff['id']; // let profile_pic_url = staff['profile_pic_url']; if (staffGallery.length > 0) { staffGallery.forEach(image => { if (image.type === "image") { let url = image.url; staffPersonalImageHtml += '
    ' let photoSwipeData = { src: url, w: 964, h: 1024 } listOfImage.push(photoSwipeData); url = ''; } // staffHtml += '
  • ' + staffName + '

    ' + area + '

    ' + location + '

    ' + price + '

    Add to cart


  • '; // console.log(staff) }) } $('#profile_pic').append(staffPersonalImageHtml); let accommodation = staffPersonal['accommodation'] === null ? "" : staffPersonal['accommodation']; let age = staffPersonal['age'] === null ? "" : staffPersonal['age']; let area = staffPersonal['area'] === null ? "" : staffPersonal['area']; let breast_size = staffPersonal['breast_size'] === null ? "" : staffPersonal['breast_size']; let height = staffPersonal['height'] === null ? "" : staffPersonal['height']; let language = staffPersonal['language'] === null ? "" : staffPersonal['language']; let location = staffPersonal['location'] === null ? "" : staffPersonal['location']; let location_cn = staffPersonal['location_cn'] === null ? "" : staffPersonal['location_cn']; location = location+" "+location_cn; let mobile_no = staffPersonal['mobile_no'] === null ? "" : staffPersonal['mobile_no']; mobile_no = mobile_no.replace(/\s+/g, ''); let name = staffPersonal['name'] === null ? "" : staffPersonal['name']; let preference_race = staffPersonal['preference_race'] === null ? "" : staffPersonal['preference_race']; let price = staffPersonal['price'] === null ? "" : staffPersonal['price']; let price2 = staffPersonal['price2'] === null ? "" : staffPersonal['price2']; price = price + " " + price2; staffPersonalHtml += '

    Name : ' + name + '


    ' staffPersonalContactHtml = '
        ' $('#profile_data').append(staffPersonalHtml); $('#profile_dataContact').append(staffPersonalContactHtml); let tableRowCount = 0 if (staffServices.length > 0) { staffServices.forEach(service => { if (tableRowCount == 0) { staffServicesHtml += '' + service.service_name + '' tableRowCount++; } else if (tableRowCount == 1) { staffServicesHtml += ' ' + service.service_name + '' tableRowCount = 0; } }) if (tableRowCount == 1) { staffServicesHtml += ' ' } $('#tbodyServices').append(staffServicesHtml); } let tableImageRowCount = 0 let tableVidRowCount = 0 if (staffGallery.length > 0) { staffGallery.forEach(object => { if (object.type == "image") { if (tableImageRowCount == 0) { staffImageHtml += '' tableImageRowCount++; } else if (tableImageRowCount == 1) { staffImageHtml += ' '; tableImageRowCount++; } else if (tableImageRowCount == 2) { staffImageHtml += ' '; tableImageRowCount = 0; } } else if (object.type == "video") { if (tableVidRowCount == 0) { staffVideoHtml += ' ' tableVidRowCount++; } else if (tableVidRowCount == 1) { staffVideoHtml += ' '; tableVidRowCount = 0; } } }) if (tableImageRowCount == 1) { staffImageHtml += ' '; } if (tableImageRowCount == 2) { staffImageHtml += ' '; } } $('#tbodyGalleryImg').append(staffImageHtml); $('#tbodyGalleryVid').append(staffVideoHtml); if(staffPersonal['is_comment']=="t"||staffPersonal['is_comment']== true){ document.getElementById("comments").style.display = "block"; getComment(); } else{ // document.getElementById("comments").style.display = "none"; } } } }); } function website_visitor() { $.ajax({ url: APIUrl + "websiteVisitor", async: false, dataType: "json", type: "post", success: function (data) { } }); } $(document).ready(function () { $("body").fadeIn(400); $('#myCarousel').carousel() $('#newProductCar').carousel() /* Home page item price animation */ $('.thumbnail').mouseenter(function () { $(this).children('.zoomTool').fadeIn(); }); $('.thumbnail').mouseleave(function () { $(this).children('.zoomTool').fadeOut(); }); // Show/Hide Sticky "Go to top" button $(window).scroll(function () { if ($(this).scrollTop() > 200) { $(".gotop").fadeIn(200); } else { $(".gotop").fadeOut(200); } }); // Scroll Page to Top when clicked on "go to top" button $(".gotop").click(function (event) { event.preventDefault(); $.scrollTo('#gototop', 1500, { easing: 'easeOutCubic' }); }); $("#topbar").load("topbar2.html", function () { console.log("Topbar loaded"); }); });