PageSourceSearch

https://langdevelopmentgroup.com/wp-content/plugins/real-estate-ma…/assets/front/js/compare.js?ver=6.4.12

js langdevelopmentgroup.com collected 2026-10-05 22:13:18 UTC 7,317 bytes, 199 lines download raw bytes

1jQuery(document).ready(function($) {
2	var remComparedProperties = JSON.parse(localStorage.getItem('remComparedProperties')) || [];
3
4	remComparedProperties.forEach(function(property) {
5	    var html = '<tr class="items_compare" id="compare-' + property.id + '" data-property_id="' + property.id + '">';
6	    html += '<td><img src="' + property.imageUrl + '"></td>';
7	    html += '<td><span class="compare-title">' + property.title + '</span><span class="compare-price">'+property.price+'</span></td>';
8	    html += '<td><button class="remove-from-compare-btn"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
9	    html += '</tr>';
10	    
11	    // Append the row to the table
12	    $('.property-box').append(html);
13
14	    $(".ich-settings-main-wrap").find(`a[data-property_id='${property.id}']`).addClass('active');
15	    $(".ich-settings-main-wrap").find(`a[data-property_id='${property.id}'] i`).addClass('active').removeClass('fa-plus').addClass('fa-check');
16	});
17
18	if ($(".prop-compare-wrapper .items_compare").length > 1) {
19		$('.compare_open').show();
20	};
21
22	// property compare button click
23	// 1st check if already in compare box then exit
24	// 2nd creating and adding hmtl to compare box
25	// 3rd animate the compare box if 2 proerpties selected
26	$( 'body' ).on('click', '.rem-compare-btn', function(e) {
27		event.preventDefault();
28
29		if (!$(this).hasClass('active')) {
30			$(this).addClass('active');
31			$(this).find('i').removeClass('fa-plus').addClass('fa-check');
32		} else {
33			return;
34		};
35		var p_id = $(this).data('property_id');
36		var the_box = $(this).closest('.rem-property-box');
37		var html = get_compare_box_html(p_id, the_box);
38		$(".property-box").append(html);
39
40		// open side area
41		if ($(".prop-compare-wrapper .items_compare").length > 1) {
42			$( ".prop-compare-wrapper" ).animate({
43			right: "0"
44			}, 500 );
45			$('.compare_close').show();
46		};
47
48		var imgurl = the_box.find('.rem-f-image').attr('src');
49		var title = the_box.find('.property-title').text();
50		var price = the_box.find('.property-price').html();
51
52		remAddToComparison(p_id, title, imgurl, price);
53	});
54
55	// comapre box open button click
56	// 1s open comapre box
57	// 2nd hide open button
58	// 3rd show close button
59	$( 'body' ).on('click', '.compare_open', function() {
60	  $( ".prop-compare-wrapper" ).animate({
61	    right: "0"
62	  }, 500 );
63	  $('.compare_open').hide();
64	  $('.compare_close').show();
65	});
66
67	// compare box close button click
68	// 1st close box
69	// 2nd open button show
70	// 3rd close button show
71	$( 'body' ).on('click', '.compare_close', function() {
72	  $( ".prop-compare-wrapper" ).animate({
73	    right: "-301"
74	  }, 500 );
75	  $('.compare_open').show();
76	  $('.compare_close').hide();
77	});
78	
79	// building html for adding listing information in compare box
80	function get_compare_box_html(p_id, the_box){
81		var imgurl = the_box.find('.rem-f-image').attr('src');
82		var title = the_box.find('.property-title').text();
83		var price = the_box.find('.property-price').html();
84		var html = '<tr class="items_compare" id="compare-'+p_id+'" data-property_id="'+p_id+'">';
85					html += '<td><img src="'+imgurl+'"></td>';
86					html += '<td><span class="compare-title">'+title+'</span><span class="compare-price">'+price+'</span></td>';
87					html += '<td><button class="remove-from-compare-btn"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
88				html += '</tr>';
89		return html;
90	}
91
92	// Function to add a property to the comparison list
93	function remAddToComparison(propertyId, title, imageUrl, price) {
94	    // Get the current list of compared properties from local storage
95	    var remComparedProperties = JSON.parse(localStorage.getItem('remComparedProperties')) || [];
96
97	    // Create an object to store the property details
98	    var property = {
99	        id: propertyId,
100	        title: title,
101	        imageUrl: imageUrl,
102	        price: price,
103	    };
104
105	    // Add the property object to the list
106	    remComparedProperties.push(property);
107
108	    // Save the updated list back to local storage
109	    localStorage.setItem('remComparedProperties', JSON.stringify(remComparedProperties));
110	}
111
112	// Function to remove a property from the comparison list
113	function remRemoveFromComparison(propertyId) {
114	    // Get the current list of compared properties from local storage
115	    var remComparedProperties = JSON.parse(localStorage.getItem('remComparedProperties')) || [];
116
117	    // Find the index of the property in the list
118	    var index = remComparedProperties.findIndex(function(property) {
119	        return property.id === propertyId;
120	    });
121
122	    // If the property is in the list, remove it
123	    if (index !== -1) {
124	        remComparedProperties.splice(index, 1);
125
126	        // Save the updated list back to local storage
127	        localStorage.setItem('remComparedProperties', JSON.stringify(remComparedProperties));
128	    }
129	}
130
131	// property information in compare box will reomve when x button clicked
132	// remove active class from property compare button
133	// compare box closed if property information form box will removed or box have only one proeprty info
134	$('body').on('click', '.remove-from-compare-btn', function(event) {
135		event.preventDefault();
136
137		var id = $(this).closest('.items_compare').data('property_id');
138		$('a[data-property_id="'+id+'"]').removeClass('active');
139		$('a[data-property_id="'+id+'"] i').removeClass('fa-check').addClass('fa-plus');
140		$(this).closest('.items_compare').remove();
141		if ($(".prop-compare-wrapper .items_compare").length <= 1){
142			$( ".prop-compare-wrapper" ).animate({
143				right: "-301"
144			}, 500 );
145			$('.compare_open').hide();
146			$('.compare_close').hide();
147		}
148		remRemoveFromComparison(id);
149	});
150
151	$('body').on('click', '.compare_clear_button', function(event) {
152		event.preventDefault();
153		$('.rem-compare-btn.active').each(function(index, el) {
154			$(this).removeClass('active');
155			$(this).find('i').removeClass('fa-check').addClass('fa-plus');
156			$('.rem-compare-table table').html("");
157			$( ".prop-compare-wrapper" ).animate({
158				right: "-301"
159			}, 500 );
160			$('.compare_open').hide();
161			$('.compare_close').hide();
162		});
163		localStorage.removeItem('remComparedProperties');
164	});
165
166	// init comapre model
167	// geting all selected property ids and send ajax request 
168	// geting required data and put on modal body
169	$("#rem-compare-modal").iziModal({
170 		zindex : 999,
171 		padding: 10,
172 		// theme : "light",
173 		width : '80%',
174 		fullscreen : true,
175 		// openFullscreen: true,
176 		overlayColor: "rgba(0,0,0,0.6)",
177 		transitionOut: "bounceInUp",
178 		transitionOut: "fadeOutDown",
179	    onOpening: function(modal){
180	 		var property_ids = [];
181	 		$('.items_compare').each( function(index, val) {
182	 			 property_ids.push($(this).data('property_id') );
183	 		
184	 		});
185	 		var data = {
186	 			'action' : 'rem_compare_properties',
187	 			'property_ids' : property_ids,
188	 			'nonce' : rem_compare.nonce
189	 		}
190	        modal.startLoading();
191	        $.post(rem_compare.ajaxurl, data , function(resp) {
192	        	
193	            $("#rem-compare-modal .iziModal-content tbody").html(resp);
194	 			// stop loading
195	            modal.stopLoading();
196	        });
197	    }
198	});
199});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.