Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: results Arguments: properties Description: [sessionkey = 0, msg = 1, type = 2, address = 3, price = 4, beds = 5, baths = 6, rooms = 7, size = 8, lotSize = 9, features = 10, description = 11] Page type: html Render function: maybeathome.results Module: maybeathome Page source: <!DOCTYPE html> <html lang="en"> <webl>WubCall("maybeathome.header", ["results"] + properties.args);</webl> <!-- Results Form Starts --> <form class="form-inline clearfix results-form" action="/webl/WubHub_DoIt" method="post"> <input name="cmdline" value="maybeathome.searchProperties(sessionkey, type, address, price, beds, baths, rooms, size, lotSize, features, description)" type="hidden"/> <webl> var sessionkey = properties.args[0] ? nil; // wubinfo.cookies.sessionkey ? nil; if (sessionkey != nil) then `<input type="hidden" name="sessionkey" value="` + sessionkey + `" />` + "\n"; else `<input type="hidden" name="sessionkey" value="nil" />` + "\n"; end; </webl> <div class="form-group house-wrapper"> <label class="sr-only" for="buy">Buy</label> <select class="form-control" id="buy" name="type" multiple> <option selected data-localize="buy.existingHouse">House</option> <option data-localize="buy.existingApartment">Apartment</option> <option data-localize="buy.newHouse">New House</option> <option data-localize="buy.newApartment">New Apartment</option> </select> </div> <div class="form-group city-wrapper"> <label class="sr-only" for="city" data-localize="buy.location">Location</label> <input type="text" class="form-control" id="address" name="address" data-localize="buy.location" onFocus="geolocate()" <webl>if Size(properties.args) > 0 then `value="` + properties.args[3] + `"` else "" end; </webl> placeholder="Neighborhood, City, Department or Area"> </div> <div class="form-group price-wrapper"> <label class="sr-only" for="maxPrice" data-localize="buy.maxPrice">Max Price</label> <input type="text" class="form-control" id="price" data-localize="buy.maxPrice" name="price" <webl>if Size(properties.args) > 0 then `value="` + properties.args[4] + `"` else "" end; </webl> placeholder="Max Price"> </div> <div class="form-group beds-wrapper"> <label class="sr-only" for="beds" data-localize="buy.beds">Beds</label> <input type="text" class="form-control" id="beds" data-localize="buy.beds" name="beds" <webl>if Size(properties.args) > 0 then `value="` + properties.args[5] + `"` else "" end; </webl> placeholder="Beds"> </div> <div class="form-group baths-wrapper"> <label class="sr-only" for="baths" data-localize="buy.g">Baths</label> <input type="text" class="form-control" id="baths" data-localize="buy.baths" name="baths" <webl>if Size(properties.args) > 0 then `value="` + properties.args[6] + `"` else "" end; </webl> placeholder="Baths"> </div> <div class="form-group rooms-wrapper"> <label class="sr-only" for="rooms" data-localize="buy.rooms">Rooms</label> <input type="text" class="form-control" id="rooms" data-localize="buy.rooms" name="rooms" <webl>if Size(properties.args) > 0 then `value="` + properties.args[7] + `"` else "" end; </webl> placeholder="Rooms"> </div> <div class="form-group size-wrapper"> <label class="sr-only" for="size" data-localize="buy.size">Size</label> <input type="text" class="form-control" id="size" data-localize="buy.size" name="size" <webl>if Size(properties.args) > 0 then `value="` + properties.args[8] + `"` else "" end; </webl> placeholder="Size"> </div> <div class="form-group lot-size-wrapper"> <label class="sr-only" for="lotSize" data-localize="buy.lotSize">Lot Size</label> <input type="text" class="form-control" id="lotSize" data-localize="buy.lotSize" name="lotSize" <webl>if Size(properties.args) > 0 then `value="` + properties.args[9] + `"` else "" end; </webl> placeholder="Lot"> </div> <div class="form-group price-wrapper"> <label class="sr-only" for="availability" data-localize="buy.availability">Availability</label> <input type="text" class="form-control" id="availability" name="availability" data-localize="buy.availability" placeholder="Availability"> </div> <button type="submit" class="btn btn-success btn-custom"><i class="glyphicon glyphicon-search"></i></button> </form> <!-- Results Form Ends --> <!-- Map Wrapper Starts --> <div class="map-wrapper clearfix"> <div class="map-info-wrapper perfect-scroll chat-info-wrapper"> <webl> var msg = ""; if Size(properties.args) > 1 then msg = properties.args[1] end; if (msg != "") then `<p class='message'>` + msg + "</p>\n" else "" end; </webl> <webl> var res = ""; var count = 0; var sessionkey = sessionkey = properties.args[0] ? nil; var userInfo = WubCall("siteutil.getSessionInfo", ["maybeathome", sessionkey]); var lang = wubinfo.cookies.countryCode ? ""; var soldLbl = "Sold!"; if (lang == `"fr"`) then soldLbl = "Vendu!" end; var userId = userInfo.username ? nil; every listing in properties.listings do var pics = listing.pictures ? []; var street = listing.street ? "NONE FOUND"; var uid = listing.userId ? nil; var id = listing["_id"] ? listing.listingId ? "itemId"; var sold = listing.sold ? nil; var soldWrapper = ""; var dataSold = ""; var markAsSoldButton = ""; if (uid == userId) and (userId != nil) then if (sold != "true") then markAsSoldButton = ` <li> <span class="property-id hidden">` + id + `</span> <label class="btn btn-success btn-xs btn-toggle-sold" for ="` + id + `"> <input type="checkbox" name="sold" id="` + id + `"><span class="toggleSold" data-localize="results.modal.markAsSold">Mark as sold</span> </label> </li>`; else markAsSoldButton = ` <li> <span class="property-id hidden">` + id + `</span> <label class="btn btn-success btn-xs btn-toggle-sold" for ="` + id + `"> <input type="checkbox" name="sold" id="` + id + `"><span class="toggleSold" data-localize="results.modal.relist">Relist</span> </label> </li>`; end end; if (sold == "true") then soldWrapper = `<div class="ribbon"><span data-localize="results.modal.sold">Sold!</span></div>`; dataSold = ` data-status="sold"`; end; while uid != userId and Str_StartsWith(street, `\d`) do street = Select(street, 1, Size(street)) end; if pics != [] then res = res + ` <div class="container-fluid map-info-inner-wrapper" id="result` + ToString(count) + `"> <div class="row"> <div class="col-sm-6"> <div class="details-wrapper"> <h3>` + WubCall("formatNum", [listing.currency ? "$", listing.price ? "0"]) + `</h3> <p>` + street + `</p> <address> <span class="bed">` + WubCall("formatNum", ["int", listing.beds ? 0]) + `</span> <span class="bed" data-localize="buy.d_beds"> beds</span>, <span class="bath">` + WubCall("formatNum", ["int", listing.baths ? 0]) + `</span> <span class="bath" data-localize="buy.d_baths"> baths</span> <br> <span data-localize="buy.d_size">Size:</span> <span class="size"> ` + WubCall("formatNum", ["int", listing.size ? 0] ) + " " + listing.measurement + `</span><br><span data-localize="buy.d_lotSize">Lot: </span> <span class="lot-size"> ` + WubCall("formatNum", ["int", listing.lotSize]) + " " + listing.measurement + `</span><br> <input class="type" type="hidden" value="` + (listing.type ? "home") + `"> <input class="features" type="hidden" value="` + (listing.features ? "")+ `"> <input class="address" type="hidden" value="` + (listing.address ? "") + `"> <input class="addressLine2" type="hidden" value="` + (listing.addressLine2 ? "") + `"> <input class="price" type="hidden" value="` + WubCall("formatNum", [listing.currency ? "$", listing.price ? "0"]) + `"> <input class="description" type="hidden" value="` + Wub_ReplaceAll((listing.description ? ""), `"`, "'") + `"> </address> </div> </div> <div class="col-sm-6 image-wrapper"` + dataSold + `> <img class="img-responsive" src="` + pics["0"].image0 + `" alt="house-small"/>` + soldWrapper + ` </div> </div> <!-- Nav Tabs --> <div class="btn-wrapper"> <ul class="nav nav-tabs"> <li class="active"> <span class="property-id hidden">` + id + `</span> <a href="#details" role="tab" data-toggle="tab" class="btn btn-success btn-xs btn-details" data-localize="results.details">Details</a> </li> <li> <a href="#calendarWrapper" role="tab" data-toggle="tab" class="btn btn-success btn-xs btn-calender" data-localize="results.calendar" id="calender-menu">Calendar</a> </li> <li> <a href="#messageWrapper" role="tab" data-toggle="tab" class="btn btn-success btn-xs btn-messages" data-localize="results.messages">Messages</a> </li> <li> <a href="#mapWrapper" role="tab" data-toggle="tab" class="btn btn-success btn-xs btn-map" data-localize="results.map">Map</a> </li>` + markAsSoldButton + ` <!--<li class="book-list-item"> --> <!-- <form class="form form-inline form-stripe" action="./charge.php" method="POST"> --> <!-- <input type="hidden" name="pId" value="` + id + `"> --> <!-- </form> --> <!-- </li> --> </ul> </div> </div> `; else res = res + ToString(listing) + "<p>\n"; end; count = count + 1; end; res; </webl> </div> <!-- Tab Panes --> <div class="tab-content perfect-scroll"> <!-- Details Tab Pane Starts --> <div role="tabpanel" class="tab-pane active" id="details"> <div class="details-tab-wrapper"> <!-- h4 class="details-header" data-localize="results.modal.head"></h4 --> <div class="details-body"> <div class="well"> <div class="row"> <div class="col-md-6"> <p class="row"> <strong class="col-sm-4" data-localize="sell.type"></strong> <span class="col-sm-8" id="type"></span> </p> <p class="row"> <strong class="col-sm-4" data-localize="sell.address"></strong> <span class="col-sm-8" id="address"></span> </p> <p class="row"> <strong class="col-sm-4" data-localize="sell.sizes"></strong> <span class="col-sm-4" id="size"></span> <span class="col-sm-4" id="lotSize"></span> </p> </div> <div class="col-md-6"> <p class="row"> <strong class="col-sm-4" data-localize="sell.bedsBaths"></strong> <span class="col-sm-4" id="beds"></span> <span class="col-sm-4" id="baths"></span> <span class="col-sm-4" id="rooms"></span> </p> <p class="row"> <strong class="col-sm-4" data-localize="sell.price"></strong> <span class="col-sm-8" id="price"></span> </p> <p class="row"> <strong class="col-sm-4" data-localize="sell.features"></strong> <span class="col-sm-8" id="features"></span> </p> </div> </div> <div class="bx-slider-wrapper"> <ul class="bxslider clearfix"></ul> </div> <p class="row"> <strong class="col-sm-2" data-localize="sell.description"></strong> <span class="col-sm-10 perfect-scroll" id="description"></span> </p> </div> </div> </div> </div> <!-- Details Tab Pane Ends --> <!-- Calendar Wrapper Tab Pane Starts --> <div role="tabpanel" class="tab-pane" id="calendarWrapper"> <div class="full-calendar-wrapper"> <div id="fullCalModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <form class="custom-form-wrapper"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> <span aria-hidden="true">×</span> <span class="sr-only">close</span> </button> <h4 id="modalTitle" class="modal-title"></h4> </div> <div class="modal-body"> <div class="form-group radio-wrapper"> <label class="radio-inline" > <input type="radio" name="book" id="markAvailability" value="markAvailability" checked/><span data-localize="req.markAvailability">Mark Availability</span> </label> <label class="radio-inline"> <input type="radio" name="book" value="book" id="book" /><span data-localize="req.book">Book</span> </label> </div> <div class="form-group radio-wrapper availability-wrapper"> <label class="radio-inline"> <input type="radio" name="availability" id="available" value="available" checked/><span data-localize="req.available">Available</span> </label> <label class="radio-inline"> <input type="radio" name="availability" value="unavailable" id="unavailable" /><span data-localize="req.unavailable">Unavailable</span> </label> </div> <div class="form-group"> <p style="color:red;" id="error-notification"></p> <label for="startDate" data-localize="req.startDate">Start Date</label> <div class='input-group date' id='startDate'> <input type='text' class="form-control" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> <div class="form-group"> <label for="endDate" data-localize="req.endDate">End Date</label> <div class='input-group date' id='endDate'> <input type='text' class="form-control" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> <!--<div class="form-group"> <label for="message">Message</label> <textarea rows="3" class="form-control" id="message"></textarea> </div>--> <div class="form-group buyer-userName-wrapper"> <label for="message" data-localize="req.renterUsername">Renter Username</label> <input type='text' class="form-control" id="buyeruserName" /> </div> <div class="form-group buyer-userName-wrapper"> <label for="propertyPrice" data-localize="req.rentalPrice">Rental Price</label> <input type='text' class="form-control" id="propertyPrice" /> </div> </div> <div class="modal-footer"> <!--<a id="eventUrl" href="consumer.html" class="btn btn-primary">Confirm</a>--> <a id="confirm" href="javascript:void(0);" class="btn btn-primary" data-localize="req.confirm">Confirm</a> <button type="button" class="btn btn-default" data-dismiss="modal" data-localize="req.cancel">Cancel</button> </div> </form> </div> </div> </div> <div id="calendar"></div> </div> </div> <!-- Calendar Wrapper Tab Pane Ends --> <!-- Message Wrapper Tab Pane Starts --> <div role="tabpanel" class="tab-pane" id="messageWrapper"> <div class="row chat-box-content"> <!-- toPane here --> <div class="col-md-9 col-sm-8 col-xs-8"> <div class="chat-scroll-wrapper"> <ul class="media-list chat-media-list"> </ul> </div> </div> </div> <div class="row"> <div class="col-sm-12"> <form class="form-horizontal custom-form-wrapper"> <div class="form-group"> <div class="col-sm-10 col-xs-10"> <textarea id="messageBox" class="form-control" rows="3"></textarea> </div> <div class="col-sm-2 col-xs-2"> <button type="button" class="btn btn-block btn-success btn-send-message">Send</button> </div> </div> </form> </div> </div> </div> <!-- Message Wrapper Tab Pane Ends --> <!-- Map Wrapper Tab Pane Starts --> <div role="tabpanel" class="tab-pane" id="mapWrapper"> <div id="googleMap"></div> </div> <!-- Map Wrapper Tab Pane Ends --> </div> </div> <!-- Map Wrapper Ends --> <webl>WubCall("maybeathome.footer", ["results"] + OPTIONALARGS); </webl> <!-- Schedule Modal Starts --> <div class="modal fade modal-wrapper" id="scheduleModal" tabindex="-1" role="dialog" aria-labelledby="scheduleModalLabel"> <div class="modal-dialog modal-lg" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <!--<span aria-hidden="true">×</span>--> <span data-localize="results.modal.close"></span> </button> <h4 class="modal-title" id="myModalLabel" data-localize="results.modal.head"></h4> </div> <div class="modal-body"> <div class="well"> <div class="row"> <div class="col-sm-6"> <p class="row"> <strong class="col-sm-4" data-localize="sell.type"></strong> <span class="col-sm-8" id="type"></span> </p> <p class="row"> <strong class="col-sm-4" data-localize="sell.address"></strong> <span class="col-sm-8" id="address"></span> </p> <p class="row"> <strong class="col-sm-4" data-localize="sell.sizes"></strong> <span class="col-sm-4" id="size"></span> <span class="col-sm-4" id="lotSize"></span> </p> </div> <div class="col-sm-6"> <p class="row"> <strong class="col-sm-4" data-localize="sell.bedsBaths"></strong> <span class="col-sm-4" id="beds"></span> <span class="col-sm-4" id="baths"></span> <span class="col-sm-4" id="rooms"></span> </p> <p class="row"> <strong class="col-sm-4" data-localize="sell.price"></strong> <span class="col-sm-8" id="price"></span> </p> <p class="row"> <strong class="col-sm-4" data-localize="sell.features"></strong> <span class="col-sm-8" id="features"></span> </p> </div> </div> <div class="bx-slider-wrapper"> <ul class="bxslider clearfix"></ul> </div> <p class="row"> <strong class="col-sm-2" data-localize="sell.description"></strong> <span class="col-sm-10 perfect-scroll" id="description"></span> </p> </div> </div> <div class="modal-footer"> <!--<div class="row"> <div class="col-sm-4"> <address data-localize="results.modal.address1"></address> </div> <div class="col-sm-4"> <address data-localize="results.modal.address2"></address> </div> <div class="col-sm-4"> <address data-localize="results.modal.address3"></address> </div> </div>--> <div class="row"> <div class="col-sm-12"> <button type="button" class="btn btn-schedule" onclick="markSold();" data-localize="results.modal.sold"></button> <button type="button" class="btn btn-schedule" data-localize="results.modal.schedule"></button> </div> </div> </div> </div> </div> </div> <!-- Schedule Modal Ends --> <webl>WubCall("maybeathome.autocomplete", []); </webl> <script type="text/javascript"> /*-- Perfect Scrollbar Initialization --*/ function initPerfectScroll() { $(".perfect-scroll").perfectScrollbar({ wheelSpeed: 20, wheelPropagation: false, suppressScrollX: true, minScrollbarLength: 25, scrollYMarginOffset: 20, scrollXMarginOffset: 20 }); } initPerfectScroll(); /*-- Modal BX Slider Initialization --*/ var scheduleSlider = $("#scheduleModal .bxslider").bxSlider({ minSlides: 2, maxSlides: 2, slideWidth: 485, slideMargin: 0, pager: false }); $(document).on("click", ".view-details", function () { $('.nav li.active').removeClass('active'); $(".btn-wrapper .nav li" ).first().addClass('active') var modalTitle,type,size,lotSize,beds,baths, rooms, price, features, description, type, address, address2; modalTitle = $(".active-info-wrapper h3").text() + " -- " + $(".active-info-wrapper p").text(); type = $(".active-info-wrapper .type").text(); size = $(".active-info-wrapper .size").text(); lotSize = $(".active-info-wrapper .lot-size").text(); beds = $(".active-info-wrapper .bed").text(); baths = $(".active-info-wrapper .bath").text(); rooms = $(".active-info-wrapper .room").text(); price = $(".active-info-wrapper .price").val(); features = $(".active-info-wrapper .features").val(); description = $(".active-info-wrapper .description").val(); type = $(".active-info-wrapper .type").val(); address = $(".active-info-wrapper .address").val(); address2 = $(".active-info-wrapper .addressLine2").val().trim(); if (address2 != "") { address = address + ", " + address2; } $("#scheduleModal #address").text(address); $("#scheduleModal #type").text(type); $("#scheduleModal #price").text(price); $("#scheduleModal #features").text(features); $("#scheduleModal #description").text(description); $("#scheduleModal #type").text(type); $("#scheduleModal #size").text(size); $("#scheduleModal #lotSize").text(lotSize); $("#scheduleModal #beds").text(beds); $("#scheduleModal #baths").text(baths); $("#scheduleModal #rooms").text(rooms); $(".modal-title").text(modalTitle); $('#scheduleModal').on('shown.bs.modal', function () { setTimeout(function () { scheduleSlider.reloadSlider(); }, 200); }); }); var selectedItemId = "<webl>properties.listings[0].listingId ? `?`</webl>"; var selectedItemOwner = "<webl>properties.listings[0].userId ? `?`</webl>"; var sessionkey = "<webl>var sessionkey = properties.args[0] ? nil</webl>"; var initSub = "<webl> var sessionkey = sessionkey = properties.args[0] ? nil; var userInfo = WubCall("siteutil.getSessionInfo", ["maybeathome", sessionkey]); if userInfo != nil then if userInfo.arg0 == "buyer" then properties.listings[0].userId else "*" end; else "" end;</webl>"; var role = "<webl> var sessionkey = sessionkey = properties.args[0] ? nil; var userInfo = WubCall("siteutil.getSessionInfo", ["maybeathome", sessionkey]); if userInfo != nil then userInfo.arg0 else "" end;</webl>"; var username = "<webl> var sessionkey = sessionkey = properties.args[0] ? nil; var userInfo = WubCall("siteutil.getSessionInfo", ["maybeathome", sessionkey]); if userInfo != nil then userInfo.username; else "unknown" end;</webl>"; /*-- Send Message --*/ $(".btn-send-message").click(function () { var messageRequestedStay = $("#messageBox").val(); if (messageRequestedStay != '') { $(".chat-media-list").append('<li class="media">' + '<div class="media-left">' + '<a href="javascript:void(0);">' + username + '</a>' + '</div>' + '<div class="media-body">' + '<p>' + messageRequestedStay + '</p>' + '</div>' + '</li>'); } $.post("postMessage.php", {text: messageRequestedStay, from: username, to: selectedItemOwner, listingId: selectedItemId }); $("#messageBox").val(''); /*-- Set Message Wrapper Auto Scroll --*/ var scrollHeight = $(".tab-content .chat-media-list").height(); $(".chat-scroll-wrapper").scrollTop(scrollHeight).perfectScrollbar("update"); }); /*-- Datepicker Initialization --*/ function initDatepicker() { $('#startDate').datetimepicker({ format: 'YYYY-MM-DD' }); $('#endDate').datetimepicker({ format: 'YYYY-MM-DD' }); } /*-- Full Calendar Initialization --*/ function initFullCalendar(calendarParam) { var todayDate = moment().startOf('day'); var YM = todayDate.format('YYYY-MM'); var YESTERDAY = todayDate.clone().subtract(1, 'day').format('YYYY-MM-DD'); var TODAY = todayDate.format('YYYY-MM-DD'); var TOMORROW = todayDate.clone().add(1, 'day').format('YYYY-MM-DD'); $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,listWeek' }, /*eventMouseover: function (data, event, view) { tooltip = '<div class="tooltiptopicevent calender-tooltip">'+data.title+'</div>'; $("body").append(tooltip); $(this).mouseover(function (e) { $(this).css('z-index', 10000); $('.tooltiptopicevent').fadeIn('500'); $('.tooltiptopicevent').fadeTo('10', 1.9); }).mousemove(function (e) { $('.tooltiptopicevent').css('top', e.pageY + 10); $('.tooltiptopicevent').css('left', e.pageX + 20); }); }, eventMouseout: function (data, event, view) { $(this).css('z-index', 8); $('.tooltiptopicevent').remove(); },*/ dayClick: function (date,event,view) { var modalTitle = "Date"; var eventsData = calendarParam ,that = $(this),calendarDate = moment(date._d).utc().format('YYYY-MM-DD'); console.log(role); if(role == "buyer"){ $("#fullCalModal .buyer-userName-wrapper").hide(); $('#fullCalModal').modal("show"); eventsData = $('#calendar').fullCalendar('getEventSources'); $(eventsData).each(function (k, v) { var geteventsData = v.origArray; $(geteventsData).each(function(k1,v1){ if (calendarDate == v1.start) { $("#fullCalModal .radio-wrapper").hide(); $("#fullCalModal .buyer-userName-wrapper").hide(); $('#fullCalModal').modal("show"); $('#startDate input').val(calendarDate); $('#endDate input').val(calendarDate); return false; } }); }); } if(role != "buyer"){ $("#fullCalModal .buyer-userName-wrapper").hide(); $('#fullCalModal').modal("show"); /* Set the clicked date to both the startDate & endDate for seller */ $('#startDate input').val(calendarDate); $('#endDate input').val(calendarDate); } if ($(this).hasClass("disabled")) { return false; } $('#modalTitle').html(modalTitle); console.log(event,'tilte',event.title); $('#message').val(event.title); //$('#fullCalModal').modal(); $("#startDate").on("dp.change", function (e) { event.start = moment(e.date).format(); $(eventsData).each(function(k,v){ if (event.start == v.start) { return false; } }); }); $("#endDate").on("dp.change", function (e) { event.end = moment(e.date).format(); event.title = $("#message").val(); $(eventsData).each(function(k,v){ if (event.end == v.end) { return false; } }); }); }, editable: selectedItemOwner == "<webl>var sessionkey = sessionkey = properties.args[0] ? nil; var userInfo = WubCall("siteutil.getSessionInfo", ["maybeathome", sessionkey]); if userInfo != nil then userInfo.username else "UNKNOWN" end;</webl>", eventLimit: true, /*-- Allow "More" Link When Too Many Events --*/ navLinks: true, events:calendarParam, timezone:"UTC", /*eventRender: function eventRender(event, element, view) { console.log ('cominggg') }*/ /*events: [ { title: 'available', start: "2018-03-08" }, { title: 'unavailable', start: YM + '-07', end: YM + '-10' }, { id: 999, title: 'unavailable', start: YM + '-09T16:00:00' }, { id: 999, title: 'available', start: YM + '-16T16:00:00' }, { title: 'available', start: YESTERDAY, end: TOMORROW }, { title: 'available', start: TODAY + 'T10:30:00', end: TODAY + 'T12:30:00' }, { title: 'available', start: TODAY + 'T12:00:00' }, { title: 'unavailable', start: TODAY + 'T14:30:00' }, { title: 'available', start: TODAY + 'T17:30:00' }, { title: 'unavailable', start: TODAY + 'T20:00:00' }, { title: 'available', start: TOMORROW + 'T07:00:00' }, { title: 'unavailable', start: YM + '-28' } ]*/ }); } /*-- Send Calendar Data --*/ function sendCalendarData(){ var url = 'http://maybeathome.com/booking.php', eventsData = [],propertyId,bookingId,startDate,endDate,message, propertyId = $('.active-info-wrapper').children(".btn-wrapper").find('li:first-child .property-id').text(), bookingId, startDate = $("#startDate").find("input").val(), endDate = $("#endDate").find("input").val(), title = $(".radio-wrapper input[name=availability]:checked").val(), calenderEventsDate=[], listDate = [], dateMove = new Date(startDate), calendarDate = startDate, buyeruserName = $("#buyeruserName").val(), propertyPrice = $("#propertyPrice").val(); /*-- Get Date Range And Push In Array --*/ while (calendarDate < endDate){ var calendarDate = dateMove.toISOString().slice(0,10); calenderEventsDate.push(calendarDate); dateMove.setDate(dateMove.getDate()+1); }; if(startDate == endDate || endDate == ""){ calenderEventsDate.push(startDate); } console.log(calenderEventsDate,title); if( role != "buyer"){ //$("#fullCalModal .radio-wrapper").show(); /*-- If Mark Availability Is Checked --*/ if($(".radio-wrapper input[name=book]:checked").val() == 'markAvailability'){ //$(".availability-wrapper").show(); $.ajax({ method: "POST", url: url, data:{ "propertyId":propertyId, "startDate":calenderEventsDate, // "endDate": endDate, "title":title, "user": "<webl> var sessionkey = sessionkey = properties.args[0] ? nil; var userInfo = WubCall("siteutil.getSessionInfo", ["maybeathome", sessionkey]); if userInfo != nil then userInfo.arg0 else "" end;</webl>" }, success: function (data) { propertyId = $('.active-info-wrapper').children(".btn-wrapper").find('li:first-child .property-id').text(); console.log(data,"endDate",endDate); eventsData = data,availDate = false; console.log('propertyId',propertyId) var url = 'http://maybeathome.com/booking.php/'+propertyId; console.log('url',url) var eventsData = [],eventClass; $.ajax({ method: "GET", url: url, success: function (data) { console.log("data inside",data); $('#fullCalModal').modal("hide"); if (localStorage.getItem("changedCode") !== null) { /*-- Get Changed Country Code --*/ countryCode = JSON.parse(localStorage.getItem("changedCode")); if(countryCode == "fr"){ $(data).each(function(k,v){ console.log(k,v); if(v.title == "available"){ v.title = "disponible"; console.log(v.title); } else{ v.title = v.title.replace(/Booked:/gi, 'reservé:'); } }); console.log(data); } else if(countryCode == "us"){ $(data).each(function(k,v){ console.log(k,v); if(v.title == "available"){ v.title = "available"; console.log(v.title); } else{ v.title = v.title.replace(/Booked:/gi, 'Booked:'); } }); console.log(data); } else if(countryCode == "uk"){ $(data).each(function(k,v){ console.log(k,v); if(v.title == "available"){ v.title = "available"; console.log(v.title); } else{ v.title = v.title.replace(/Booked:/gi, 'Booked:'); } }); console.log(data); } } eventsData = data; $('#calendar').fullCalendar('removeEvents'); $('#calendar').fullCalendar('addEventSource', eventsData); $('#calendar').fullCalendar('rerenderEvents'); } }); if(eventsData.user == 'user'){ propertyId = eventsData.property_id; bookingId = eventsData.booking_id.$id; message = eventsData.message; console.log("user"); console.log(eventsData.user); $('.active-info-wrapper .btn-wrapper a[href="#messageWrapper"]').tab('show'); $("#messageBox").val(message); } } }); } /*-- If Mark Booking Is Checked --*/ if($(".radio-wrapper input[name=book]:checked").val() == 'book'){ //$(".availability-wrapper").hide(); $.ajax({ method: "GET", url: 'http://maybeathome.com/booking.php?payment=0&property='+propertyId+'&startDate='+startDate+'&endDate='+endDate+'&username='+buyeruserName+'&price='+propertyPrice+'', success: function (data) { $('#fullCalModal').modal("hide"); $('#startDate input').val(''); $('#endDate input').val(''); console.log('coming while booking',data); eventsData = data; message = eventsData.message; if (localStorage.getItem("changedCode") !== null) { /*-- Get Changed Country Code --*/ countryCode = JSON.parse(localStorage.getItem("changedCode")); if(countryCode == "fr"){ message = message.replace(/To reserve this property from/gi, 'Pour réserver cette propriété de '); message = message.replace(/For/gi, 'pour '); message = message.replace(/click on the link provided then press the/gi, 'cliquez sur le lien fourni puis appuyez sur le bouton '); message = message.replace(/Pay with Card/gi, 'Payer avec la carte '); message = message.replace(/button to book it/gi, 'bouton pour le réserver '); } else if(countryCode == "us"){ message = message.replace(/Pour réserver cette propriété de/gi, 'To reserve this property from '); message = message.replace(/pour/gi, 'For '); message = message.replace(/cliquez sur le lien fourni puis appuyez sur le bouton/gi, 'click on the link provided then press the '); message = message.replace(/Payer avec la carte/gi, 'Pay with Card '); message = message.replace(/bouton pour le réserver/gi, 'button to book it '); } else if(countryCode == "uk"){ message = message.replace(/Pour réserver cette propriété de/gi, 'To reserve this property from '); message = message.replace(/pour/gi, 'For '); message = message.replace(/cliquez sur le lien fourni puis appuyez sur le bouton/gi, 'click on the link provided then press the '); message = message.replace(/Payer avec la carte/gi, 'Pay with Card '); message = message.replace(/bouton pour le réserver/gi, 'button to book it '); } } $('.active-info-wrapper .btn-wrapper a[href="#messageWrapper"]').tab('show'); $("#messageBox").val(message+ '<a href="' + eventsData.link + '" target="_blank" onClick="window.open("' + eventsData.link + '","Rent","resizable,height=600,width=800"); return false;">Click Here</a>'); //$(".contact-list li:first-of-type").trigger("click"); // '<a target="_blank" href='+eventsData.link+'>Click Here</a>.'); }, //$("#messageBox").val(message+ //'<button type="button" style="padding:0" class="btn btn-link" id="open-modal">Click Here </button>' //+' <div class="modal fade" id="open-modalbox" tabindex="-1" role="dialog">' //+'<div class="modal-dialog" role="document">' //+'<div class="modal-content">' //+'<div class="modal-header">' //+'<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>' //+'<h4 class="modal-title">Pay Here </h4>' //+'</div>' //+'<div class="modal-body">' //+'<a href="' + eventsData.link + '" class="btn btn-primary">Pay with Card</a>' //+'</div>' //+'<div class="modal-footer">' // +'<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>' // +'</div>' // +'</div>' // +'</div>' // +'</div>'); // '<a target="_blank" href='+eventsData.link+'>Click Here</a>.'); //}, error:function(error){ $("#error-notification").text(error.responseJSON.message) $('#startDate input').val(''); $('#endDate input').val(''); } }); } } if(role == "buyer"){ var url = 'http://maybeathome.com/booking.php'; $.ajax({ method: "POST", url: url, data:{ "propertyId":propertyId, "startDate":calenderEventsDate, "user":"buyer", "userName":username }, success: function (data) { $("#fullCalModal").modal('hide'); console.log('data',data) eventsData = data; message = eventsData.message; $('.active-info-wrapper .btn-wrapper a[href="#messageWrapper"]').tab('show'); $(".contact-list li:first-of-type").trigger("click"); console.log('eventsData.message',eventsData.message); if (localStorage.getItem("changedCode") !== null) { /*-- Get Changed Country Code --*/ countryCode = JSON.parse(localStorage.getItem("changedCode")); if(countryCode == "fr"){ //$(".chat-media-list .media-body p").text().replace(/I want to book this property from date /gi, 'Je veux réserver cette propriété à partir de la date '); message = message.replace(/I want to book this property from date /gi, 'Je veux réserver cette propriété à partir de la date '); } } $("#messageBox").val(message); }, error:function(error){ $("#error-notification").text(error.responseJSON.message) $('#startDate input').val(''); $('#endDate input').val(''); } }); } } /*-- Full Calendar Shown Events --*/ $('#fullCalModal').on('shown.bs.modal', function () { initDatepicker(); if(role == "buyer"){ $("#error-notification").text(""); $("#fullCalModal .radio-wrapper").hide(); } if(role != "buyer"){ $("#error-notification").text(""); $("#fullCalModal .radio-wrapper").show(); $("#book").prop("checked", false); $("#markAvailability").prop("checked", true); } $(".radio-wrapper input[name=book]").change(function(){ if($(".radio-wrapper input[name=book]:checked").val() == 'book'){ $(".availability-wrapper").hide(); $("#fullCalModal .buyer-userName-wrapper").show(); }else{ $(".availability-wrapper").show(); $("#fullCalModal .buyer-userName-wrapper").hide(); } }); }); $(document).on('click','#confirm', function () { sendCalendarData(); }); /*-- Full Calendar Hidden Events --*/ $('#fullCalModal').on('hidden.bs.modal', function () { //sendCalendarData(); }); /*-- Google Map Marker Infowindow Initialization --*/ var map, marker, position, infowindow,imgUrl; var Markers = []; var locations = [ <webl> var res = ""; var count = 0; every listing in properties.listings do count = count + 1; res = res + ` [ 'Single Family House', '` + (listing.address ? "") + `</p><br><a href="" class="view-details" data-toggle="tab" data-target="#details" data-localize="results.details">View Details</a>', ` + (listing.lat ? "0") + `, ` + (listing.lng ? "0") + `, 0 ]`; if (count < Size(properties.listings)) then res = res + ",\n " end; end; res; </webl> ]; /*-- Map Initialization --*/ function initMap() { var origin; if (locations.length > 0) { origin = new google.maps.LatLng(locations[0][2], locations[0][3]); } else { origin = new google.maps.LatLng(37.84, -122.23); } var mapOptions = { zoom: 12, center: origin }; map = new google.maps.Map(document.getElementById('googleMap'), mapOptions); infowindow = new google.maps.InfoWindow(); for (var i = 0; i < locations.length; i++) { var currentposition = new google.maps.LatLng(locations[i][2], locations[i][3]); marker = new google.maps.Marker({ position: currentposition, map: map }); marker.setMap(map); google.maps.event.addListener(marker, 'click', (function (marker, i) { return function () { infowindow.setContent(locations[i][1]); infowindow.setOptions({maxWidth: 200}); infowindow.open(map, marker); if ($("#mapWrapper").hasClass("active")) { /*-- Set Active Tab --*/ $(".btn-wrapper .nav-tabs li a[href='#mapWrapper']").tab("show"); } switch (i) { <webl> var count = 0; var res = ""; every listing in properties.listings do var notMe = ""; var j = 0; while (j < Size(properties.listings)) do if (j != count) then if (notMe != "") then notMe = notMe + "," end; notMe = notMe + "#result" + ToString(j); end; j = j + 1; end; res = res + ` case ` + ToString(count) + `: $('#result` + ToString(count) + `').addClass("active-info-wrapper"); $('` + notMe + `').removeClass("active-info-wrapper"); selectedItemId = "` + ToString(listing.listingId ? "?") + `"; selectedItemOwner = "` + ToString(listing.userId ? "?") + `"; if ( $('#result` + ToString(count) + `').offset() ) { $('.map-info-wrapper').animate({ scrollTop: $('#result` + ToString(count) + `').offset().top - $('.map-info-wrapper').offset().top - 5 + $('.map-info-wrapper').scrollTop() }); } break;` + "\n"; count = count + 1; end; res; </webl> } refreshMessages(sessionkey, initSub, selectedItemId); } })(marker, i)); Markers.push(marker); } locate(0); setTimeout(function(){ $(".map-info-inner-wrapper:first-of-type").trigger("click"); },200); /*-- BX Slider Initialization --*/ var slider = $("#details .bxslider").bxSlider({ minSlides: 2, maxSlides: 2, slideWidth: 485, slideMargin: 0, pager: false }); setTimeout(function () { slider.reloadSlider(); }, 200); refreshMessages(sessionkey, initSub, "<webl>properties.listings[0].listingId ? `?`</webl>"); $(".map-info-inner-wrapper").click(function () { var paneIndex = $(this).parents(".map-info-wrapper").siblings(".tab-content").children(".tab-pane.active").index(); paneIndex = parseInt(paneIndex); $(this).children(".btn-wrapper").find(".nav-tabs li:eq(" + paneIndex + ") a").tab('show'); var homeDiv = $(this).attr('id'), locationIndex; if (homeDiv == 'firstResult') { locationIndex = 4 locate(locationIndex) $('#firstResult').addClass("active-info-wrapper"); $('#thirdResult, #fifthResult,#seventhResult,#ninthResult').removeClass("active-info-wrapper"); $('.map-info-wrapper').stop(); } <webl> var count = 0; var res = ""; every listing in properties.listings do var notMe = ""; var j = 0; while (j < Size(properties.listings)) do if (j != count) then if (notMe != "") then notMe = notMe + "," end; notMe = notMe + "#result" + ToString(j); end; j = j + 1; end; var pics = listing.pictures ? [. "0" = [] .]; var ps = ""; every p in pics["0"] do if ps != "" then ps = ps + "," end; ps = ps + "'" + pics["0"][p] + "'" end; res = res + ` else if (homeDiv == 'result` + ToString(count) + `') { locationIndex = ` + ToString(count) + ` selectedItemId = "` + ToString(listing.listingId ? "?") + `"; selectedItemOwner = "` + ToString(listing.userId ? "?") + `"; locate(locationIndex) $('#result` + ToString(count) + `').addClass("active-info-wrapper"); $('` + notMe + `').removeClass("active-info-wrapper"); $('.map-info-wrapper').stop(); imgUrl = [` + ps + `]; }` + "\n"; count = count + 1; end; res; </webl> /*-- Details Tab Pane Data --*/ modalTitle = $(".active-info-wrapper h3").text() + " -- " + $(".active-info-wrapper p").text(); type = $(".active-info-wrapper .type").text(); size = $(".active-info-wrapper .size").text(); lotSize = $(".active-info-wrapper .lot-size").text(); beds = $(".active-info-wrapper .bed").text(); baths = $(".active-info-wrapper .bath").text(); rooms = $(".active-info-wrapper .room").text(); price = $(".active-info-wrapper .price").val(); features = $(".active-info-wrapper .features").val(); description = $(".active-info-wrapper .description").val(); type = $(".active-info-wrapper .type").val(); address = $(".active-info-wrapper .address").val(); address2 = $(".active-info-wrapper .addressLine2").val().trim(); if (address2 != "") { address = address + ", " + address2; } while ((selectedItemOwner != username) && (address.charAt(0) >= '0') && (address.charAt(0) <= '9')) { address = address.substring(1, address.length) } $("#details #address").text(address); $("#details #type").text(type); $("#details #price").text(price); $("#details #features").text(features); $("#details #description").text(description); $("#details #type").text(type); $("#details #size").text(size); $("#details #lotSize").text(lotSize); $("#details #beds").text(beds); $("#details #baths").text(baths); $("#details #rooms").text(rooms); $(".modal-title").text(modalTitle); // $("#details .details-header").html(headText + ' ' + paragraphText); // $("#details .details-footer .col-sm-4:first-of-type address").html(addressTxt); $("#scheduleModal .bx-slider-wrapper .bxslider li").remove(); $("#details .bx-slider-wrapper .bxslider li").remove(); for (i = 0; i < imgUrl.length; i++) { $("#details .bx-slider-wrapper .bxslider").append("<li><img src=" + imgUrl[i] + " alt='image' /></li>"); $("#scheduleModal .bx-slider-wrapper .bxslider").append("<li><img src=" + imgUrl[i] + " alt='image' /></li>"); } setTimeout(function () { slider.reloadSlider(); }, 200); refreshMessages(sessionkey, initSub, selectedItemId); }); // initAutocomplete(); } /*-- Locate Marker Initialization --*/ function locate(marker_id) { setTimeout(function () { var myMarker = Markers[marker_id]; var markerPosition = myMarker.getPosition(); map.setCenter(markerPosition); google.maps.event.trigger(myMarker, 'click'); }, 500); } function initChatPerfectScroll() { $(".chat-scroll-wrapper").perfectScrollbar({ wheelSpeed: 20, wheelPropagation: false, suppressScrollX: true, minScrollbarLength: 25, scrollYMarginOffset: 20, scrollXMarginOffset: 20 }); } initChatPerfectScroll(); /*-- Set Message Wrapper Auto Scroll --*/ var scrollHeight = $(".chat-media-list").height(); $(".chat-scroll-wrapper").scrollTop(scrollHeight).perfectScrollbar("update"); $('.btn-wrapper a[data-toggle="tab"]').on('shown.bs.tab', function (e) { e.target; /*-- Newly Activated Tab --*/ e.relatedTarget; /*-- Previous Active Tab --*/ //initFullCalendar(); initPerfectScroll(); }); $(".btn-wrapper a[href='#calendarWrapper']").on('shown.bs.tab', function (e) { e.target; /*-- Newly Activated Tab --*/ e.relatedTarget; /*-- Previous Active Tab --*/ /*--- Replacing the â into '-' ---*/ $(document).on('click', '.fc-listWeek-button', function(){ var a = $($('#calendar .fc-center').children()[0]).html().replace('â','-'); $($('#calendar .fc-center').children()[0]).html(a) }) $(document).on('click', '.fc-next-button', function(){ var a = $($('#calendar .fc-center').children()[0]).html().replace('â','-'); $($('#calendar .fc-center').children()[0]).html(a) }) $(document).on('click', '.fc-prev-button', function(){ var a = $($('#calendar .fc-center').children()[0]).html().replace('â','-'); $($('#calendar .fc-center').children()[0]).html(a) }) $("#calendar").fullCalendar("destroy"); var propertyId = $('.active-info-wrapper').children(".btn-wrapper").find('li:first-child .property-id').text(); console.log(propertyId,role,'role'); var url = 'booking.php/'+propertyId+'/'+role+'/'+username; eventsData = []; $.ajax({ method: "GET", url: url, success: function (data) { console.log(data); var getCalendarData = data; localStorage.setItem("getCalendarData",JSON.stringify(getCalendarData)); if (localStorage.getItem("changedCode") !== null) { /*-- Get Changed Country Code --*/ countryCode = JSON.parse(localStorage.getItem("changedCode")); if(countryCode == "fr"){ $(data).each(function(k,v){ console.log(k,v); if(v.title == "available"){ v.title = "disponible"; console.log(v.title); } else{ v.title = v.title.replace(/Booked:/gi, 'reservé:'); } }); console.log(data); } else if(countryCode == "us"){ $(data).each(function(k,v){ console.log(k,v); if(v.title == "available"){ v.title = "available"; console.log(v.title); } else{ v.title = v.title.replace(/Booked:/gi, 'Booked:'); } }); console.log(data); } else if(countryCode == "uk"){ $(data).each(function(k,v){ console.log(k,v); if(v.title == "available"){ v.title = "available"; console.log(v.title); } else{ v.title = v.title.replace(/Booked:/gi, 'Booked:'); } }); console.log(data); } } eventsData = data; initFullCalendar(eventsData); if (localStorage.getItem("changedCode") !== null) { /*-- Get Changed Country Code --*/ countryCode = JSON.parse(localStorage.getItem("changedCode")); //console.log("countryCode",countryCode); $('#calendar').fullCalendar('option', 'locale', countryCode); } } }); }); $(".btn-wrapper a[href='#details']").on('shown.bs.tab', function (e) { e.target; /*-- Newly Activated Tab --*/ e.relatedTarget; /*-- Previous Active Tab --*/ setTimeout(function () { // slider.reloadSlider(); }, 200); }); $(".btn-wrapper a[href='#mapWrapper']").on('shown.bs.tab', function (e) { e.target; /*-- Newly Activated Tab --*/ e.relatedTarget; /*-- Previous Active Tab --*/ google.maps.event.trigger(map, 'resize'); }); $(".btn-wrapper a[href='#messageWrapper']").on('shown.bs.tab', function (e) { e.target; /*-- Newly Activated Tab --*/ e.relatedTarget; /*-- Previous Active Tab --*/ $(".tab-content").perfectScrollbar("destroy"); initChatPerfectScroll(); setTimeout(function(){ $(".contact-list li:first-of-type").trigger("click"); },500); }); function selectOwner(elt, sub) { if(elt.nextElementSibling == null && elt.previousElementSibling == null){ selectedItemOwner = sub; refreshMessages(sessionkey, sub, selectedItemId); }else { $('.contact-list li.active').removeClass('active'); $(elt).addClass('active'); selectedItemOwner = sub; refreshMessages(sessionkey, sub, selectedItemId); } } function refreshMessages(sessionkey, sub, selectedItem) { if (selectedItem == "?") { selectedItem = "-" } $.ajax({ url: 'http://www.maybeathome.com/site/text("' + String(sessionkey) + '","' + String(sub) + '","' + String(selectedItem) + '")', cache: false, success: function(html){ $(".chat-box-content").html(html); //Insert chat log into the #chatbox div var scrollHeight = $(".tab-content .chat-media-list").height(); $(".chat-scroll-wrapper").scrollTop(scrollHeight).perfectScrollbar("update"); if (localStorage.getItem("changedCode") !== null) { /*-- Get Changed Country Code --*/ countryCode = JSON.parse(localStorage.getItem("changedCode")); if(countryCode == "fr"){ $(".chat-media-list .media").each(function(){ var messageText = $(this).children(".media-body").find("p").html(); messageText = messageText.replace(/I want to book this property from date/gi, 'Je veux réserver cette propriété à partir de la date '); messageText = messageText.replace(/To reserve this property from/gi, 'Pour réserver cette propriété de '); messageText = messageText.replace(/click on the link provided then press the/gi, 'cliquez sur le lien fourni puis appuyez sur le bouton '); messageText = messageText.replace(/Pay with Card/gi, 'Payer avec la carte '); messageText = messageText.replace(/button to book it/gi, 'bouton pour le réserver '); messageText = messageText.replace(/For/gi, 'pour '); messageText = messageText.replace(/Click Here/gi, 'Cliquez ici '); $(this).children(".media-body").find("p").html(messageText); }); } else if(countryCode == "us"){ $(".chat-media-list .media").each(function(){ var messageText = $(this).children(".media-body").find("p").html(); messageText = messageText.replace(/Je veux réserver cette propriété à partir de la date/gi, 'I want to book this property from date '); messageText = messageText.replace(/Pour réserver cette propriété de/gi, 'To reserve this property from '); messageText = messageText.replace(/cliquez sur le lien fourni puis appuyez sur le bouton/gi, 'click on the link provided then press the '); messageText = messageText.replace(/Payer avec la carte/gi, 'Pay with Card '); messageText = messageText.replace(/bouton pour le réserver/gi, 'button to book it '); messageText = messageText.replace(/pour/gi, 'For '); messageText = messageText.replace(/Cliquez ici/gi, 'Click Here '); $(this).children(".media-body").find("p").html(messageText); }); } else if(countryCode == "gb"){ $(".chat-media-list .media").each(function(){ var messageText = $(this).children(".media-body").find("p").html(); messageText = messageText.replace(/Je veux réserver cette propriété à partir de la date/gi, 'I want to book this property from date '); messageText = messageText.replace(/Pour réserver cette propriété de/gi, 'To reserve this property from '); messageText = messageText.replace(/cliquez sur le lien fourni puis appuyez sur le bouton/gi, 'click on the link provided then press the '); messageText = messageText.replace(/Payer avec la carte/gi, 'Pay with Card '); messageText = messageText.replace(/bouton pour le réserver/gi, 'button to book it '); messageText = messageText.replace(/pour/gi, 'For '); messageText = messageText.replace(/Cliquez ici/gi, 'Click Here '); $(this).children(".media-body").find("p").html(messageText); }); } $('.contact-list li').css("cursor","pointer"); //$('.contact-list li:first-of-type').addClass('active'); $(".tab-content").perfectScrollbar("destroy"); initChatPerfectScroll(); } }, }); } //$(document).on("click",".contact-list li",function(){ //$('.contact-list li').removeClass('active'); //$(this).addClass('active'); //}); $(document).on("click","#open-modal",function(){ console.log("Yahoo"); $("#open-modalbox").modal("toggle"); }); /*-- Mark as sold scripts --*/ $(document).ready(function(){ $.ajax({ method: "GET", url: 'restAPI.php', dataType: "json", success: function (response) { if(response.status == 200){ $.each(response.data, function(key, value){ //var each_data = '<p>Hello bro</p>'; var sold_status = ""; var selectedClass = ""; if(value.sold === 'true'){ sold_status = "checked"; selectedClass = "selected"; } var id = value._id.$id; /*console.log(value._id.$id);*/ /*$(".itemId").text(id); $(".btn-toggle-sold").attr("for",id); $(".btn-toggle-sold input").attr("id",id);*/ //console.log(value._id.$id); /*console.log(sold_status);*/ var each_data = '<div class="container-fluid map-info-inner-wrapper" id="firstResult"><span class="itemId">'+id+'</span> <div class="row"> <div class="col-sm-6"> <div class="details-wrapper"> <h3 data-localize="results.head1"></h3> <p data-localize="results.text1"></p><address data-localize="results.address1"></address> </div></div><div class="col-sm-6 image-wrapper" data-status="sold"> <img class="img-responsive" src="assets/images/property-img1.png" alt="house-small"/> <div class="ribbon"><span>Sold!</span></div></div></div><div class="btn-wrapper"> <ul class="nav nav-tabs"> <li class="active"> <a href="#details" role="tab" data-toggle="tab" class="btn btn-success btn-xs btn-details" data-localize="results.details"></a> </li><li> <a href="#calendarWrapper" role="tab" data-toggle="tab" class="btn btn-success btn-xs btn-calender" data-localize="results.calendar"></a> </li><li> <a href="#messageWrapper" role="tab" data-toggle="tab" class="btn btn-success btn-xs btn-messages" data-localize="results.messages"></a> </li><li> <a href="#mapWrapper" role="tab" data-toggle="tab" class="btn btn-success btn-xs btn-map" data-localize="results.map"></a> </li><li> <label class="btn btn-success btn-xs btn-toggle-sold '+selectedClass+'" data-localize="results.markAsSold"> <input id="'+id+'" type="checkbox" '+sold_status+'><label for="'+id+'">Mark as sold</label></label> </li></ul> </div></div>'; // $(".chat-info-wrapper").append(each_data); id=null; }); } } }); }); $(document).on("click",".btn-toggle-sold input",function () { /*console.log("here");*/ var sold_status = $(this).prop("checked"); var lang = <webl>wubinfo.cookies.countryCode ? `""`</webl> var relist = "Relist"; var markAsSold = "Mark as sold"; var soldLbl = "Sold!" if (lang == "fr") { relist = "Relister" markAsSold = "Déclarer vendu" soldLbl = "Vendu!" } /*console.log(sold_status); */ $(this).parent("label").toggleClass("selected"); var that = $(this); function checkStatus() { if (that.siblings("span").text() == relist) { that.parent("label").children("span").text(markAsSold); that.parents(".map-info-inner-wrapper").find(".image-wrapper").removeAttr("data-status"); that.parents(".map-info-inner-wrapper").find(".image-wrapper").children(".ribbon").remove(); } else { that.parent("label").children("span").text(relist); that.parents(".map-info-inner-wrapper").find(".image-wrapper").append('<div class="ribbon"><span>' + soldLbl + '</span></div>'); that.parents(".map-info-inner-wrapper").find(".image-wrapper").attr("data-status", "sold"); } } /** * Ajax request for mark as sold prperty data * * @access public * @return mark as sold prperty data * @since 1.0.0 */ //var itemId = $(this).parents('.btn-wrapper').find('.property-id').text(); var itemId = $(this).attr('id'); if($(this).siblings("span").text() == relist){ sold_status = false; }else{ sold_status = true; } var url = 'restAPI.php/'+itemId; $.post(url, {sold: sold_status},function (data) { checkStatus(); }); }); var js_strip_data = "pk_test_Kt5OZDy0B2naRwedHKJkBn8A"; var stripScript = document.createElement("script"); stripScript.type = "text/javascript"; stripScript.src = "https://checkout.stripe.com/checkout.js"; stripScript.setAttribute("class","stripe-button"); stripScript.setAttribute("data-key",js_strip_data); stripScript.setAttribute("data-description","Access for a year"); stripScript.setAttribute("data-amount",5000); stripScript.setAttribute("data-locale","auto"); stripScript.setAttribute("data-label","Book"); $(".chat-info-wrapper .form-stripe").each(function(){ $(this).append(stripScript); }); </script> <webl> if (Size(properties.listings) > 0) then ` <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAO2RntyX5IUgDJmXO-i39U06wwIhKwdEE&libraries=places&callback=initMap" async defer></script> <!--<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCm4RI3_gF_IhpNIwCtL6wbpSHv_hKAYm0&callback=initMap" async defer></script>--> ` else `` end; </webl> </body> </html>