PageSourceSearch

https://www.yorknational.com/modules/ProtectedPropertyDetails/js/ProtectedPropertyDetails.js

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

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.