PageSourceSearch

https://www.savvyhomesolutions.com/modules/ProtectedPropertyDetails/js/ProtectedPropertyDetails.js?1

js savvyhomesolutions.com collected 2026-10-09 23:14:14 UTC 10,397 bytes, 308 lines download raw bytes

1/**
2 * This script catches clicks on the homepage and processes them for the ProtectedPropertyDetails module
3 * @author Christopher Millward
4 */
5var is_superbox_loaded = false;
6var global_target_el = null;
7
8
9function reinit_superbox() {
10  var elements = superbox_elements();
11  
12  for (var i in elements) {
13    var element = elements[i];
14    if ($(element).attr('data-op') == undefined && !$(element).hasClass("property_page")&& !$(element).hasClass("street_view_map_page")) {
15    jQuery(element.selector).click(function(event){
16      check_for_existing_user(event); // Figure out the appropriate page action to take
17      //Make body not scrollable after superbox opens
18      start_superbox_controllers();
19    });
20    }
21  }
22}
23
24jQuery(document).ready(function() {
25  reinit_superbox();
26
27  var elements = superbox_elements();
28
29  var bindSuperbox = function($el) {
30      $el.unbind('click').on('click', function(event){
31
32        if ( event.currentTarget !== this ) {
33            return;
34        }
35        check_for_existing_user(event); // Figure out the appropriate page action to take
36        
37        //Make body not scrollable after superbox opens
38        start_superbox_controllers();
39      });
40  };
41  
42  for (var i in elements) {
43    var element = elements[i];
44        
45    // Add superbox listener to element
46    
47    // Remove hashes from anchors
48    var $element = $(element.selector);
49    if ( $element.length > 0 && typeof( $element !== 'undefined' ) ) {
50        
51        $element.each(function(i, el) {
52            var $this = $(el);
53            var url = $this.attr('href').split('#');
54            $this.attr('href', url[0]);
55            bindSuperbox($this);
56        });
57        
58    } else {
59        continue;
60    }
61    
62  }
63  
64  // Load the superbox functionality
65  jQuery(function(){
66    init_superbox();
67  });
68});
69
70function superboxHeight(wHeight) {
71    wHeight = typeof(wHeight) === 'undefined' ? jQuery(window).height() : wHeight;
72    
73    var $superbox = jQuery('#superbox');
74    var $wrapper = jQuery('#superbox-wrapper');
75    $wrapper.css('height', wHeight + 'px');
76    
77    if ( wHeight < $superbox.height() || wHeight < 550 ) {
78        $wrapper.addClass('is-mobile');
79    } else {
80        $wrapper.removeClass('is-mobile');
81    }
82    // jQuery('#superbox').css({
83       // 'top' : 0,
84       // 'transform' : 'none' 
85    // });
86}
87
88/*
89 * @param $el jQuery element
90*/
91function absoluteOverride($el) {
92   var $window = jQuery(window);
93   var $superbox = jQuery('#superbox');
94   var $wrapper = jQuery('#superbox-wrapper');
95   var scroll = $window.scrollTop(),
96     top = 0,
97     sHeight = $superbox.height(),
98     wHeight = $window.height();
99   
100   if ( $window.height() < 550 ) {
101       //top = (wHeight / 2) + (sHeight / 2);
102       $wrapper.addClass('is-mobile');
103       
104   } else {
105       $wrapper.removeClass('is-mobile');
106   }
107}
108
109/**
110 * Checks to see if the user has visited the site before, and allows the user to register if not
111 */
112function check_for_existing_user(event) { 
113  var sidCookieValue = Get_Cookie('sid');
114  if (null == sidCookieValue && true == can_show_registration_form() && true == is_superbox_loaded) {  // Cookie doesn't exist
115    
116    // Save the destination and load the form 
117    var $target = jQuery(event.target);
118    var destination = '';
119    if ($target.is("img")) {
120      var $parent = $target.parent();
121      destination = $parent[0];
122      
123      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
124      var propertyURLPosition = destination.href.indexOf('destination='); 
125      if (-1 != propertyURLPosition) {
126        destination.href = destination.href.substr(propertyURLPosition + 'destination='.length);
127      }
128      
129      var page = window.location;
130      var form_url = page.protocol + "//" + page.host + "/protectedpropertydetails/register" + "?destination=" + destination;
131      $parent[0].href = form_url;
132      global_target_el = $parent[0];
133    }
134    else if ($target.is("a")) { 
135      destination = $target[0].href;
136      global_target_el = $target[0];
137      
138      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
139      var propertyURLPosition = destination.indexOf('destination='); 
140      if (-1 != propertyURLPosition) {
141        destination = destination.substr(propertyURLPosition + 'destination='.length);
142      }
143      
144      var page = window.location;
145      var form_url = page.protocol + "//" + page.host + "/protectedpropertydetails/register" + "?destination=" + destination;
146      $target[0].href = form_url;
147    } 
148  }
149}
150
151/**
152 * Checks to see if the registration form should be shown
153 * @return TRUE if the registration form should be shown, else FALSE
154 */
155function can_show_registration_form() {
156  var max_views = parseInt(Get_Cookie('max_views'));
157  var free_views = parseInt(Get_Cookie('free_views'));
158  
159  // If no max is defined, show the form for every view
160  if (null == max_views) {
161    return (true);
162  }
163  
164  if (null == free_views || isNaN(free_views)) {
165  	free_views = 0;
166  }
167  
168  if (free_views >= max_views) {
169  	return (true);
170  }
171  else {
172  	return (false);
173  }
174}
175
176/**
177 * Gets the value of a cookie
178 * @param check_name
179 * @return The value of the named cookie, or null
180 * 
181 * Code for this function was taken from http://techpatterns.com/downloads/javascript_cookies.php
182 */
183function Get_Cookie( check_name ) {
184  // first we'll split this cookie up into name/value pairs
185  // note: document.cookie only returns name=value, not the other components
186  var a_all_cookies = document.cookie.split( ';' );
187  var a_temp_cookie = '';
188  var cookie_name = '';
189  var cookie_value = '';
190  var b_cookie_found = false; // set boolean t/f default f
191
192  for ( i = 0; i < a_all_cookies.length; i++ )
193  {
194    // now we'll split apart each name=value pair
195    a_temp_cookie = a_all_cookies[i].split( '=' );
196
197
198    // and trim left/right whitespace while we're at it
199    cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
200
201    // if the extracted name matches passed check_name
202    if ( cookie_name == check_name )
203    {
204      b_cookie_found = true;
205      // we need to handle case where cookie has no value but exists (no = sign, that is):
206      if ( a_temp_cookie.length > 1 )
207      {
208        cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
209      }
210      // note that in cases where cookie is initialized but no value, null is returned
211      return cookie_value;
212      break;
213    }
214    a_temp_cookie = null;
215    cookie_name = '';
216  }
217  if ( !b_cookie_found )
218  {
219    return null;
220  }
221}
222
223/**
224 * Initialize superbox
225 */
226function init_superbox() {
227  var sidCookieValue = Get_Cookie('sid');
228  if (false == is_superbox_loaded && null == sidCookieValue && true == can_show_registration_form()) { // Cookie doesn't exist and free views have been used up, show registration form
229    var elements = superbox_elements();
230    
231    for (var i in elements) {
232      var element = elements[i]; 
233      if ($(element).attr('data-op') == undefined && !$(element).hasClass("property_page") && !$(element).hasClass("street_view_map_page")) {
234        jQuery(element.selector).attr('rel', 'superbox[iframe][' + element.width + 'x' + element.height + ']');
235      }
236    }
237    if($('.property_page').length == 0)
238    {
239    jQuery.superbox();
240    }
241    is_superbox_loaded = true;
242  }
243}
244
245/**
246 * Gets an array of elements that should be tagged with the superbox
247 * Also tries to call the superbox_elements_by_theme() function to allow each theme to modify / add to the array
248 * The returned array is structured as follows:
249 * 
250 * array[0] = {selector: element_selector, width: width_of_superbox, height: height_of_superbox}
251 * 
252 */
253function superbox_elements() {
254  var elements = new Array(); // Holds the elements
255  var default_width = 620;  // Default width of the superbox window
256  var default_height = 400; // Default height of the superbox window
257  
258  // Set the default elements that will be treated as superbox triggers
259  elements.push({'selector': '#featureimg a', 'width': default_width, 'height': default_height});
260  elements.push({'selector': 'div.column-fp a', 'width': default_width, 'height': default_height});
261  elements.push({'selector': 'div.details-button a', 'width': default_width, 'height': default_height});
262  elements.push({'selector': '.sub-p4 a', 'width': default_width, 'height': default_height});
263  elements.push({'selector': '.short-result-sub-p a', 'width': default_width, 'height': default_height});
264  elements.push({'selector': '.property-list .propertyHolder a', 'width': default_width, 'height': default_height});
265  elements.push({'selector': '.feature_img a', 'width': default_width, 'height': default_height});
266  elements.push({'selector': '.featured_img_link a', 'width': default_width, 'height': default_height});
267
268  // Allow the theme to modify the elements array
269  /* if (typeof(superbox_elements_by_theme) == typeof(Function)) {
270    superbox_elements_by_theme(elements);
271  }*/
272    
273  return elements;  
274}
275
276function redirect_visitor_register(url_redirect){
277		parent.location.href = url_redirect;
278}
279
280function pad2(number) {
281    return (number < 10 ? '0' : '') + number;
282}
283
284function redirect_open_house_register(listingId, address, date, startDate, endDate,sourceURL){
285	
286	var url = "http://www.google.com/calendar/event?action=TEMPLATE&text=" + encodeURIComponent( "Open House at " + address );
287
288	if (startDate && endDate) {
289		startDate = new Date(startDate);
290		endDate = new Date(endDate);
291		var start = startDate.getUTCFullYear()+pad2(startDate.getUTCMonth()+1)+pad2(startDate.getUTCDate())+"T"+pad2(startDate.getUTCHours())+pad2(startDate.getUTCMinutes())+"00Z";
292		var end = endDate.getUTCFullYear()+pad2(endDate.getUTCMonth()+1)+pad2(endDate.getUTCDate())+"T"+pad2(endDate.getUTCHours())+pad2(endDate.getUTCMinutes())+"00Z";
293		url += "&dates=" + encodeURIComponent( start+"/"+end );
294	} else {
295		date = new Date(date);
296		var str = date.getUTCFullYear()+pad2(date.getUTCMonth()+1)+pad2(date.getUTCDate());
297		url += "&dates=" + encodeURIComponent( str+"/"+str );
298	}
299	var detailsUrl = 'Open house at following property: '+sourceURL;
300	var idx = detailsUrl.lastIndexOf('/');
301	detailsUrl = detailsUrl.substring(0, idx+1)+'details-'+listingId;
302	
303	url += "&details=" + encodeURIComponent( detailsUrl ) +
304	"&location=" + encodeURIComponent( address ) +
305	"&trp=false";
306	
307	window.location = url;
308}

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.