text: ProjectController=function(b){$this=this;this.settings=b;this.data=[];this.searchVar={};this.lstPoint="";this.currPageIndex=0;this.detailView=$("#detailView");this.itemView=$(".item-view");this.listView=$(".list-view");this.pageView=$(".page-view");this.resultMessage=$(".projectTotalResult");this.viewMap=$("#viewMap");this.pnlViweMap=$("#pnlMapView");this.ProjectMap=$("#map").MapControler({zoom:this.settings.context.zoom,center:this.settings.context.center,lstPoint:this.settings.context.lstPoint});this.ProjectMap.callbackMapChange=function(f,g,d,e,c){$this.callBackDrawEvent(d,f,e,g,$this.ProjectMap.lstPoint,c,$this.ProjectMap.isMapIdle)};this.ProjectMap.callBackClearPointEvent=function(){$this.callBackClearPointEvent()};this.ProjectMap.callbackShowProjectDetailInfoWindow=function(d){$this.itemView.children("a").attr("href",d.detailLink);var c="https://file4.batdongsan.com.vn/images/no-photo.jpg";if(d.avatar!==undefined&&d.avatar!=null&&d.avatar.length>0){c=d.avatar.replace("resize/110x110","resize/320x255").replace("resize/255x180","resize/320x255").replace("crop/110x110","crop/320x255").replace("crop/255x180","crop/320x255").replace("crop255x180","crop320x255").replace("crop110x110","crop320x255").replace("thumb110x110","thumb320x255").replace("thumb255x180","thumb320x255")}$this.itemView.children("a").children("img").attr("src",c);$this.itemView.children("a.title").text(d.title);$this.itemView.children("a.title").attr("href",d.detailLink);$this.itemView.children("https://content.batdongsan.com.vn/Modules/Project/Frontend/ProjectList/js/span.add").text(d.address);$this.itemView.children("span.price").children("b").text(d.price);$this.detailView.children("a.lnkdetail").attr("href",d.detailLink);$this.itemView.show();$this.detailView.children("a.lnkdetail").show();if($this.detailView.css("display")=="none"){$this.detailView.show();$this.ProjectMap.resizeMap();$this.ProjectMap.map.setCenter(new google.maps.LatLng(d.lat,d.lon))}$this.ChangeUrlForNewContext()};try{if(google){this.pnlViweMap.show();this.Initialize()}}catch(a){}};ProjectController.prototype.Initialize=function(){this.ProjectMap.initialize();this.searchVar={cate:this.settings.context.catid,city:this.settings.context.city,dist:this.settings.context.district,projectid:this.settings.context.projectid,zoom:this.settings.context.zoom,center:this.settings.context.center,lstPoint:this.settings.context.lstPoint,searchType:this.settings.context.searchType,isSearchForm:this.settings.context.searchType==searchTypeEnum.SearchForm,isPageLoad:true,type:this.settings.context.type};if(this.settings.context.type=="projectbybounds"){this._SearchAction({type:"projectbybounds",cate:this.settings.context.catid,projectid:this.settings.context.projectid,page:this.settings.context.page,minlat:this.settings.context.minlat,minlong:this.settings.context.minlon,maxlat:this.settings.context.maxlat,maxlong:this.settings.context.maxlon,lstPoint:"",isSearchForm:false,isPageLoad:true})}else{if(this.settings.context.type=="projectbyshape"){this._SearchAction({type:"projectbyshape",cate:this.settings.context.catid,projectid:this.settings.context.projectid,page:this.settings.context.page,minlat:this.settings.context.minlat,minlong:this.settings.context.minlon,maxlat:this.settings.context.maxlat,maxlong:this.settings.context.maxlon,lstPoint:this.settings.context.lstPoint,isSearchForm:false,isPageLoad:true})}else{var a=[];$(".list-view li").each(function(){var b=$(this);if(b.hasClass("invi")){a.push({id:b.attr("pid"),title:b.attr("tle"),lat:b.attr("lat"),lon:b.attr("lon"),avatar:b.attr("ava"),address:b.attr("add"),price:b.attr("pri"),detailLink:b.attr("lnk"),zoom:15,distr:b.attr("distr"),city:b.attr("cty")})}else{a.push({id:b.attr("pid"),title:b.children("div.detail").children("div.bigfont").children("a").text(),lat:b.attr("lat"),lon:b.attr("lon"),avatar:b.children("div.thumb").children("a").children("img").attr("src"),address:b.children("div.detail").children("https://content.batdongsan.com.vn/Modules/Project/Frontend/ProjectList/js/div.add").text(),price:b.children("div.detail").children("div.price").children(".price").text(),detailLink:b.children("div.thumb").children("a").attr("href"),zoom:15,distr:b.attr("distr"),city:b.attr("city")})}});this.data=this.ProjectMap.showMapProject(a);if(this.settings.context.projectid!="0"){this.ShowProjectInfo(this.settings.context.projectid,true)}else{}}}};ProjectController.prototype.SearchProjectByShape=function(e,c,d,a,b){if(this.lstPoint!=null&&this.lstPoint.length>0){var f={};if(e!=undefined){f.page=e}else{f.page=1}f.cate=this.settings.context.catid;if(this.settings.context.priceMax!==undefined&&this.settings.context.priceMax>0){f.pmax=this.settings.context.priceMa}if(this.settings.context.priceMin!==undefined&&this.settings.context.priceMin>0){f.pmin=this.settings.context.priceMin}f.type="projectbyshape";f.minlat=c;f.minlong=d;f.maxlat=a;f.maxlong=b;f.lstPoint=this.lstPoint;f.isSearchForm=false;f.isPageLoad=false;this._SearchAction(f)}};ProjectController.prototype.SearchProjectByBounds=function(e,c,d,a,b){var f={};if(e!=undefined){f.page=e}else{f.page=1}f.cate=this.settings.context.catid;if(this.settings.context.priceMax!==undefined&&this.settings.context.priceMax>0){f.pmax=this.settings.context.priceMa}if(this.settings.context.priceMin!==undefined&&this.settings.context.priceMin>0){f.pmin=this.settings.context.priceMin}f.type="projectbybounds";f.minlat=c;f.minlong=d;f.maxlat=a;f.maxlong=b;f.lstPoint=this.lstPoint;f.isSearchForm=false;f.isPageLoad=false;this._SearchAction(f)};ProjectController.prototype._SearchAction=function(b){this.searchVar=b;this.searchVar.Version="062016";var a=this;this.viewMap.block(loadingHtml);this.ChangeUrlForNewContext();b.v=new Date().getTime();$.ajax({url:mapHostUrl+"/api/p_sync",data:this.searchVar,dataType:"json",type:getAjaxMethod(),success:function(d,f,e){if(d!=undefined&&d!=null){a.data=a.ProjectMap.showMapProject(d.data);var c="Có "+d.total+" dự án được tìm thấy";a.resultMessage.html(c);a.ChagePageIndex(1);if(b.isPageLoad&&b.projectid!=""){a.ShowProjectInfo(b.projectid,true)}if(b.isPageLoad||b.isSearchForm){a.ProjectMap.isShowRefreshButton=false;a.ProjectMap.btnUpdateMapIdleResult.hide()}}a.viewMap.unblock()},error:function(d,e,c){a.viewMap.unblock()}})};ProjectController.prototype.ChagePageIndex=function(f,b){var g=10;var e=this.data.length/g;e=Math.ceil(e);this.currPageIndex=f;this.pageView.html("");this.listView.html("");if(e<1){return}if(f>e){return}this.currPageIndex=f;var h=(f-1)*g;if(h<=0){h=0}var c=h+g;var a=this;for(var d=h;d<c&&d<this.data.length;d++){this.listView.append(this.BuildProjectDetail(this.data[d],d,d==this.data.length-1))}this.BuildPaging(this.data.length,f);if(b){$(".prj-list")[0].scrollIntoView()}this.searchVar.page=f;this.ChangeUrlForNewContext()};ProjectController.prototype.ChangeMapPostition=function(b){this.ProjectMap.DeleteShape();var d=10;var c="Việt Nam";if(b.city!=""){d=12;var a=this.hdbCity.getText();if(a.toLowerCase()=="tp.hcm"){a="Hồ Chí Minh"}c=a+", "+c;if(b.dist!=""&&b.dist!="0"){d=14;c=this.hdbDistrict.getText()+", "+c}}else{var c="Hà Nội, Việt Nam"}if(b.isPageLoad){b.zoom=d}this.ProjectMap.ChangeMapByAddress(c,d)};ProjectController.prototype.BuildProjectDetail=function(e,c,d){var f="";f+="<li>";f+='<div class="thumb">';f+='<a href="'+e.detailLink+'" title="'+e.title+'">';var b="https://file4.batdongsan.com.vn/images/no-photo.jpg";if(e.avatar!==undefined&&e.avatar!=null&&e.avatar.length>0){b=e.avatar.replace("resize/110x110","resize/255x180").replace("crop/110x110","crop/255x180").replace("crop110x110","crop255x180").replace("thumb110x110","thumb255x180")}f+='<img src="'+b+'"/>';f+="</a>";f+="</div>";f+='<div class="detail">';f+='<div class="bigfont">';f+='<a href="'+e.detailLink+'">'+e.title+"</a>";f+="</div>";f+="<div>"+e.address+"</div>";f+='<div class="price">';f+='<span class="left">Giá từ: </span><strong>'+e.price+"</strong>";f+="</div>";if(e.investor.length>0){f+="<div>";f+='<span class="left">Chủ đầu tư: </span>'+e.investor;f+="</div>"}f+='<div class="area">';f+='<span class="left">Diện tích: </span>'+e.area;f+="</div>";f+='<div class="prgrs">';f+='<span class="left">Tiến độ: </span>'+e.progress;f+="</div>";f+='<div class="mt10">';if(e.loan.length>0){f+='<a href="'+e.detailLink+'/p6" class="btnGreen">Ưu đãi từ '+e.loan+"</a>"}f+="</div>";f+="</div>";f+='<div class="clear">&nbsp;</div>';var a="map";if(this.searchVar.type=="projectbyshape"||this.searchVar.type=="projectbybounds"){if(this.settings.context.catid==e.catid){a+=" map_hover"}else{}}else{}f+='<a class="'+a+'" href="javascript:controllerObj.ProjectMap.showProjectById('+e.id+", true);$('.map-view')[0].scrollIntoView();\"></a>";f+="</li>";return f};ProjectController.prototype.BuildPaging=function(g,d){var e=10;if(g>e){d=Math.max(1,d);var b=parseInt(g/e);if(b*e<g){b++}d=Math.min(d,b);if(b>1){var f=Math.max(1,d-2);var c=Math.min(b,d+2+(2-(d-f)));if(c>=b){f=Math.max(1,c-5)}if(f>1){this.pageView.append('<a href="javascript:controllerObj.ChagePageIndex('+1+', true);"><div style="margin-left: 2px;width: auto;color: #000000;text-decoration: none;height: 23px;line-height: 23px;float: left;padding-left: 6px;padding-right: 6px;border: 1px solid #ccc;">...</div></a>');this.pageView.append('<a href="javascript:controllerObj.ChagePageIndex('+(d-1)+', true);"><div style="margin-left: 2px;width: auto;color: #000000;text-decoration: none;height: 23px;line-height: 23px;float: left;padding-left: 6px;padding-right: 6px;border: 1px solid #ccc;">&lt;</div></a>')}for(var a=f;a<=c;a++){if(a==d){this.pageView.append('<a href="#"><div style="margin-left: 2px;width: auto;color: #000000;text-decoration: none;height: 23px;line-height: 23px;float: left;padding-left: 6px;padding-right: 6px;border: 1px solid #ccc;" class="style-pager-row-selected">'+(a)+"</div></a>")}else{this.pageView.append('<a href="javascript:controllerObj.ChagePageIndex('+a+', true);"><div style="margin-left: 2px;width: auto;color: #000000;text-decoration: none;height: 23px;line-height: 23px;float: left;padding-left: 6px;padding-right: 6px;border: 1px solid #ccc;">'+(a)+"</div></a>")}}if(c<b){this.pageView.append('<a href="javascript:controllerObj.ChagePageIndex('+(d+1)+', true);"><div style="margin-left: 2px;width: auto;color: #000000;text-decoration: none;height: 23px;line-height: 23px;float: left;padding-left: 6px;padding-right: 6px;border: 1px solid #ccc;">&gt;</div></a>');this.pageView.append('<a href="javascript:controllerObj.ChagePageIndex('+(b)+', true);"><div  style="margin-left: 2px;width: auto;color: #000000;text-decoration: none;height: 23px;line-height: 23px;float: left;padding-left: 6px;padding-right: 6px;border: 1px solid #ccc;">...</div></a>')}}}};ProjectController.prototype.FindProjectInfoById=function(b){for(var a=0;a<this.data.length;a++){if(this.data.id==b){return this.data[a]}}};ProjectController.prototype.ChangeUrlForNewContext=function(){try{var b=(this.searchVar.cate!=undefined?this.searchVar.cate:this.settings.context.catid);b+=";"+(this.searchVar.city!=undefined?this.searchVar.city:"");b+=";"+(this.searchVar.dist!=undefined?this.searchVar.dist:"");b+=";"+(this.ProjectMap.isDrawing?(this.searchVar.lstPoint!=undefined?this.searchVar.lstPoint:""):"");b+=";"+this.ProjectMap.getZoom();b+=";"+this.ProjectMap.getCenter();b+=";"+(this.searchVar.page!=undefined?this.searchVar.page:1);b+=";"+(this.ProjectMap.currentPjID!=undefined?this.ProjectMap.currentPjID:"");b+=";"+(this.searchVar.isSearchForm?0:1);bound=this.ProjectMap.getCornerBounds();b+=";"+bound.minLat;b+=";"+bound.minLong;b+=";"+bound.maxLat;b+=";"+bound.maxLong;b+=";"+(this.searchVar.type!==undefined?this.searchVar.type:"");b+=";"+(this.searchVar.pmax!==undefined?this.searchVar.pmax:"");b+=";"+(this.searchVar.pmin!==undefined?this.searchVar.pmin:"")}catch(a){b=""}if(b.length>0){window.location.href=window.location.pathname+window.location.search+"#"+b}};ProjectController.prototype.ShowHideViewList=function(b,a){if(this.detailView.hasClass("detail-view-hidden")&&(b==undefined||b==true)){this.detailView.removeClass("detail-view-hidden");this.detailView.unbind("click");google.maps.event.trigger(this.ProjectMap.map,"resize")}else{if(b==undefined||b==false){this.detailView.addClass("detail-view-hidden");google.maps.event.trigger(this.ProjectMap.map,"resize")}}};ProjectController.prototype.ShowProjectInfo=function(d,b){var c=this.FindProjectInfoById(d);if(c!=null){this.ProjectMap.ShowProject(c,b)}else{var a=this;$.ajax({url:mapHostUrl+"/api/p_sync",data:{type:"projectInfo",projectId:d,v:new Date().getTime()},dataType:"json",type:"GET",success:function(e,g,f){if(e!=null&&e!=undefined){a.ProjectMap.ShowProject(e,b)}},error:function(f,g,e){writelog(g);writelog(e)},complete:function(){}})}};ProjectController.prototype.callBackClearPointEvent=function(a){this.lstPoint="";this.resultMessage.html("");if(a){this.ProjectMap.isMapIdle=false}else{this.ProjectMap.isMapIdle=true}};ProjectController.prototype.callBackDrawEvent=function(d,f,e,g,c,a){var b=this.ProjectMap.isMapIdle;if(b!=undefined&&!b){}this.lstPoint=c;if(this.ProjectMap.isDrawing){this.SearchProjectByShape(1,f,g,d,e)}else{this.SearchProjectByBounds(1,f,g,d,e)}};