PageSourceSearch

https://www.datingbuzzafrica.com/js/ajax.r40242.js

js datingbuzzafrica.com collected 2026-10-04 02:54:45 UTC 51,117 bytes, 1,246 lines download raw bytes

1// $Id: ajax.js 40050 2026-06-04 09:23:13Z brendon $
2
3function nodeValue (node, name) {
4	var children = node.getElementsByTagName(name);
5	if (children.length > 0 && children.item(0).childNodes.length > 0) {
6		return children.item(0).childNodes.item(0).nodeValue;
7	}
8	return "";
9}
10
11// Generate a really basic uniqueID formed by the concatenation of a random number and the current timestamp
12// (if you need a more robust universally unique ID, then have a look at the UUID class in 'vendor/uuid.js')
13function generateUID () {
14	var now = Date.parse(new Date());
15	var randomNumber = Math.floor(Math.random() * 111)
16	
17	return randomNumber+''+now;  // ensure that a concatenated string is returned
18}
19
20// Loads the specified 'url'
21function loadUrl (url) {
22	if (url == null) {
23		// just perform a page reload
24		location.reload(true);
25	} else {
26		location.href = url;
27	}
28}
29
30function outerHTML(element) {
31	if (element) {
32		var container = document.createElement("div");
33		container.appendChild(element.cloneNode(true));
34		return container.innerHTML;
35	} else {
36		return '';
37	}
38}
39
40// Constructs and returns an anchor string
41function buildAnchor (href, anchorText, titleText) {
42	return "<a href=\""+href+"\""+(titleText != null && titleText.length > 0 ? "title=\""+titleText+"\"" : "")+" onclick=\"return ajaxRequest(this.href);\">"+anchorText+"</a>";
43}
44
45function rwdBuildAnchor (json, anchorText, moreBox, options) { 
46	options = $.extend({}, json, options);
47	var action = (options.action == 'add' || options.action == 'block') ? "" : " active";
48	if (options.currPage == "find_favourites") {
49		if (moreBox) {
50			return "<a class=\"favouritesOnly"+action+"\" title=\"\" href=\""+options.href+"\" onclick=\"return ajaxRequest(this.href);\"><svg><use xlink:href=\""+(action == " active" ? "#icon_removePhotoInvite" : "#icon_photoInvite")+"\" /></svg><span>"+anchorText+"</span></a>";
51		} else {
52			return "<a class=\"favourite"+action+"\" title=\"\" href=\""+options.href+"\" onclick=\"return ajaxRequest(this.href);\"><svg><use xlink:href=\""+(action == " active" ? "#icon_favourited" : "#icon_favourite")+"\" /></svg><span>"+anchorText+"</span></a>";
53		}
54	} else if (options.currPage == "find_invites") {		
55		var subClassName = "cancelInvite";
56		if (options.href && options.href.indexOf("subscribe") !== -1) {
57			subClassName = "cancelInvite launchSubscribeModal";
58		}
59		if (moreBox) {
60			return "<a class=\""+subClassName+"\" href=\""+options.href+"\" ><svg><use xlink:href=\"#icon_photoInvite\" /></svg><span>"+anchorText+"</span></a>";
61		} else {
62			return "<a class=\""+subClassName+"\" href=\""+options.href+"\" onclick=\"return ajaxRequest(this.href);\"><svg><use xlink:href=\""+(action == " active" ? "#icon_removePhotoInvite" : "#icon_photoInvite")+"\" /></svg><span>"+anchorText+"</span></a>";
63		}
64	} else if (options.currPage == "find_block") {
65		return "<a class=\"blockReport block\" href=\""+options.href[0]+"\" onclick=\"return ajaxRequest(this.href);\">"+anchorText+"</a>";
66	} else if (options.currPage == "find_photoLikes") {
67		return "<div class=\"photoLikesWrapper\"><a class=\"like"+action+"\" href=\""+options.href+"\" onclick=\"return ajaxRequest(this.href);\"><svg><use xlink:href=\""+(action == " active" ? "#icon_liked" : "#icon_like")+"\" /></svg></a><span class=\"numofLikes\">"+copyItems["field_like"]+" ("+options.numOfLikes+")</span></div>";
68	}
69}
70
71// Toggle classes on an element, update its contents and return it
72function toggleElement (element, addClass, removeClass, updateContent) {
73	if (typeof jQuery == 'undefined' && typeof element == 'string') {
74		if (!document.getElementById) {
75			return ;
76		}
77		element = document.getElementById(element);
78	}
79	
80	if (typeof jQuery != 'undefined') {
81		element = (typeof element == 'string') ? $('#' + element) : element;	
82
83		if (addClass != null && addClass.length > 0) {
84			element.addClass(addClass);
85		}
86		if (updateContent != null && updateContent.length > 0) {
87			element.html(updateContent);
88		}
89		if (removeClass != null && removeClass.length > 0) {
90			element.removeClass(removeClass);
91		}
92	}
93		
94	return element;
95}
96
97function rwdToggleElement (element, updateContent) {
98	if (typeof jQuery == 'undefined' && typeof element == 'string') {
99		if (!document.getElementById) {
100			return ;
101		}
102		element = document.getElementById(element);
103	}
104	
105	if (typeof jQuery != 'undefined') {
106		element = (typeof element == 'string') ? $('#' + element) : element;
107
108		if (updateContent != null && updateContent.length > 0) {
109			element.replaceWith(updateContent);
110		}
111	}
112	
113	return element;
114}
115
116// Add to search page removed results array
117function addToRemovedResults (m) {
118	if (typeof removedResults != "undefined") {
119		removedResults.push(m);
120	}
121}
122
123// Remove from search page removed results array
124function removeFromRemovedResults () {
125	if (typeof removedResults != "undefined") {
126		removedResults.pop();
127	}
128}
129
130// Restore a profile result
131function restoreResult (profileBox, m) {
132	if (typeof jQuery != 'undefined') {
133		if (typeof results != 'undefined' && typeof results["total"] != 'undefined' && typeof results["thisPage"] != 'undefined') {
134			if (results["total"] > 0) {
135				results["total"]++;
136			}
137			
138			// update the results total on the page
139			youHaveElement = $('#youHave');
140			if (results["total"] < 3 && (youHaveElement.length != 0) && copyItems["youHave"] && copyItems["resultsOne"] && copyItems["resultsSome"]) {
141				if (results["total"] == 1) {
142					youHaveElement.html(copyItems["youHave"] + ' ' + copyItems["resultsOne"]);
143				} else {
144					youHaveElement.html(copyItems["youHave"] + ' <span id="totalResults">' + results["total"] + '</span> ' + copyItems["resultsSome"]);
145				}
146			} else if (totalResultsElement = $('#totalResults')) {
147				totalResultsElement.html(results["total"]);
148			}
149		}
150		
151		// when the user clicks 'undo', the profile card is reinstated
152		if (profileBox) {
153			var restoreBox = $('#restoremID' + m);
154			profileBox.show(); 
155			restoreBox.hide();
156			removeFromRemovedResults();
157		}
158
159		// hide/show tip box (relating to results) on the page
160		if (typeof results != 'undefined' && typeof results["total"] != 'undefined') {
161			if (resultsTipElement = $('#resultsTip')) {
162				if (results["total"] > 10 && !resultsTipElement.hasClass('toggle')) {
163					resultsTipElement.addClass('toggle');
164				} else if (results["total"] <= 10 && resultsTipElement.hasClass('toggle')) {
165					resultsTipElement.removeClass('toggle');
166				}
167			}
168		}
169		
170		if (typeof results != 'undefined' && typeof results["thisPage"] != 'undefined') {
171			results["thisPage"]++;
172			if (results["thisPage"] >= 1) {
173				keepNotificationAreaVisible = true;
174				
175				// hide resultNav at top and bottom of page
176				$("div.pagingBox").each(function(index, resultNav) {
177					$(resultNav).show();
178				});
179			}
180		}
181	}
182}
183
184// Remove an element from one of our results pages
185function removeResult (profileBox, m, restoreHref, mobile, removalNote, readditionNote) {
186	if (typeof jQuery != 'undefined') {
187		if (typeof results != 'undefined' && typeof results["total"] != 'undefined') {
188			if (results["total"] > 0) {
189				results["total"]--;
190			}
191			
192			// update the results total on the page
193			youHaveElement = $('#youHave');
194			if (results["total"] < 3 && (youHaveElement.length != 0) && copyItems["youHave"] && copyItems["resultsOne"] && copyItems["resultsSome"]) {
195				if (results["total"] == 1) {
196					youHaveElement.html(copyItems["youHave"] + ' ' + copyItems["resultsOne"]);
197				} else {
198					youHaveElement.html(copyItems["youHave"] + ' <span id="totalResults">' + results["total"] + '</span> ' + copyItems["resultsSome"]);
199				}
200			} else if (totalResultsElement = $('#totalResults')) {
201				totalResultsElement.html(results["total"]);
202			}
203		}
204		
205		if (profileBox) {
206			var restoreBox = $('#restoremID' + m);
207			var svg = "<svg><use xlink:href=\"#icon_success\"></use></svg>";
208			var restoreProfileAnchor = buildAnchor(restoreHref, copyItems["profile_und
208oRemoval"], copyItems["profile_restoreProfile"]);
209			var confirmNote = "<div>" + svg + removalNote + "</div>";
210			confirmNote += "<div>" + restoreProfileAnchor + "</div>";
211			var profileCardContainer = $('#mID' + m).parent();
212			addToRemovedResults(m);			
213			profileBox.hide();
214			restoreBox.show();
215			restoreBox.html(confirmNote);	
216		}
217		
218		// hide/show tip box (relating to results) on the page
219		if (typeof results != 'undefined' && typeof results["total"] != 'undefined') {
220			if (resultsTipElement = $('#resultsTip')) {
221				if (results["total"] > 10 && !resultsTipElement.hasClass('toggle')) {
222					resultsTipElement.addClass('toggle');
223				} else if (results["total"] <= 10 && resultsTipElement.hasClass('toggle')) {
224					resultsTipElement.removeClass('toggle');
225				}
226			}
227		}
228		
229		if (typeof results != 'undefined' && typeof results["thisPage"] != 'undefined') {
230			results["thisPage"]--;
231			if (results["thisPage"] < 1) {
232				if (pages["thisPageNum"] >= pages["total"]) {
233					pages["thisPageNum"]--;
234				}
235				keepNotificationAreaVisible = true;
236				
237				// hide resultNav at top and bottom of page
238				$("div.pagingBox").each(function(index, resultNav) {
239					$(resultNav).hide();
240				});
241			}
242		}
243	}
244}
245
246// Our main Ajax handler function
247/**
248 * Explanation of parameters below:
249 * href 	- A string containing the URL to which the request is sent
250 * postData - Data to be sent to the server (type: Object literal)
251 * options 	- A set of key/value pairs that configure the Ajax request (type: Object literal)
252 */	
253function ajaxRequest (href, postData, options) {
254	if (typeof jQuery != 'undefined' && href) {
255		if (!beforeUnloadFired) {
256		var json,
257			failedResponse,
258			defaults = {
259				noRetry: false,
260				showNotification: false,
261				method: 'post',
262				data: {},
263				url: href
264			};
265		// Merge defaults and options, without modifying defaults
266		options = $.extend({}, defaults, options);
267		if (options.method == "post") {
268			if (href.indexOf("?") !== -1) {
269				// get query string parameters
270				var obj = getAllUrlParams(href);
271				options.url = obj.url;
272				options.data = obj.data;
273			} else if (postData) {
274				// use postData parameter
275				if (typeof postData == 'object') {
276					// check if object is empty
277					if (Object.keys(postData).length > 0) {
278						options.data = postData;
279					}
280				} else {
281					var obj = {};
282					postData.replace(/([^=&]+)=([^&]*)/g, function(param, key, value) {
283						obj[decodeURIComponent(key)] = decodeURIComponent(value);
284					}); 
285					options.data = obj;
286				}
287			}
288		}
289		// Assign handlers immediately after making the request
290		var req = $.ajax({
291			url: options.url,
292			method: options.method,
293			async: true,
294			data: options.data,
295			headers: {'Accept':'application/json'}
296		})
297		.done(function(data, textStatus, jqXHR) {
298			var meta = {
299				contentType: jqXHR.getResponseHeader('Content-Type') || ''
300			};
301			if (meta.contentType.indexOf('application/json') !== -1) {
302				json = {};
303				$.extend(json, jQuery.parseJSON(jqXHR.responseText) || {});
304				var activityIndicator = ajaxDone(json);
305				if (!options.showNotification) {
306					options.showNotification = activityIndicator;
307				}
308			} else {
309				failedResponse = {
310					handler: textStatus,
311					xhr: jqXHR
312				};
313			}
314		})
315		.fail(function(jqXHR, textStatus, errorThrown) {
316			failedResponse = {
317				handler: textStatus,
318				xhr: jqXHR
319			};
320		})
321		.always(function() {
322			if (typeof failedResponse != 'undefined') {
323				failedResponse.url = href;
324				$.extend(failedResponse, options);
325				handleAjaxErrors(failedResponse);
326			}
327			if (options.showNotification) {
328				var onTimeout = function () {
329					notify(json, 3);  // 2nd argument sets length of time (in seconds) that the on-screen notification is displayed
330				};
331				setTimeout(onTimeout, 50);  // ever-so-slightly reduces flicker when switching from "working" text to the on-screen notification
332
333				if (!keepNotificationAreaVisible) {
334					keepNotificationAreaVisible = !keepNotificationAreaVisible;
335				}
336			}
337			ajaxAlways(json);
338		});
339		}
340		return false;  // prevent anchor being followed
341	}
342	
343	return true;  // cause anchor to be followed if jQuery isn't available
344}
345
346// Handle successes: toggle states of our action links, and update them
347function ajaxDone (json) {
348	if (typeof jQuery != 'undefined') {
349		if (json.result) {
350			if (json.currPage != 'find_search' && json.currPage != 'join' && json.currPage != 'splash' && json.currPage != 'find_popular' && !(json.currPage == 'info_success' && json.action == "nextStories") && !json.sendPhotoRequest && !json.paging) {
351				var itemIndex = json.currPage+'_'+json.action;
352				var toolTipText = (typeof titleItems != 'undefined' && typeof titleItems[itemIndex] != 'undefined' && titleItems[itemIndex].length > 0) ? titleItems[itemIndex] : null;
353				var anchorText = (typeof json.href != 'undefined' && json.href != null) ? buildAnchor(json.href, anchorItems[itemIndex], toolTipText) : '';
354				//rwd2015
355				var rwdAnchorText = (typeof json.href != 'undefined' && json.href != null) ? rwdBuildAnchor(json, anchorItems[itemIndex], false) : '';
356			}
357
358			switch (json.currPage) {
359				case 'find_favourites':
360					if (json.paging) {
361						ajaxBuildPagingResults(json);
362					} else {
363						if (json.action == 'add') {
364							if (json.from == 'find_favourites' || json.from == 'find_mutuals') {
365								removeResult($('#mID'+json.m), json.m, json.href, json.rwd, json.removalNote, json.readditionNote);
366							} else if (json.from == 'view' || json.from == 'find_morePhotos' || json.from == 'profile_summary') {
367								if (json.rwd) {
368									rwdToggleElement($('#mID'+json.m).find('a.favourite'), rwdAnchorText);
369									if ($(".profileMiniBar").length) {
370										rwdToggleElement($('.profileMiniBar').find('a.favourite'), rwdAnchorText);
371									}
372									// Add as favourite to view Favourites-Only photos
373									if (json.ss != "guest") {
374										var favouriteAnchorText = (typeof json.href != 'undefined' && json.href != null) ? rwdBuildAnchor(json, copyItems['favouriteAlbumInvite'], true) : '';
375										var favouriteElement = $('#mID'+json.m).find('a.favouritesOnly');
376										rwdToggleElement(favouriteElement, favouriteAnchorText);
377										if ($(".profileMiniBar").length) {
378											var favouriteElement = $('.profileMiniBar').find('a.favouritesOnly');
379											rwdToggleElement(favouriteElement, favouriteAnchorText);
380										}
381									}
382								} else {
383									toggleElement('favourite', 'addFavButton', 'remFavButton', anchorText+(json.note ? '<span class="note">'+json.note+'</span>' : ''));
384								}
385								if (typeof noteItems != 'undefined' && typeof noteItems["favPrivPhotos_remove"] != 'undefined') {
386									// this is not applicable to messages/conversation thread, since we don't deal with photo invitees there
387									toggleElement('favPrivPhotos', 'addFavPhotoButton', 'remFavPhotoButton').find('div > p').html(noteItems["favPrivPhotos_remove"]);
388								}
389								// Update start chatting link
390								if (typeof chatListener != 'undefined') {
391									var href = json.href;
392									var hrefParts = href.split('/s/');
393									var baseurl = hrefParts[0];
394									var url = baseurl + '/s/chat/chatRoster.php?a=inRoster&m=' + json.m + '&f=' + json.f;
395									result = ajaxRequest(url);
396								}
397							} else if (json.from == 'read' || json.from == 'mail_conversation') {
398								if (json.rwd) {
399									rwdToggleElement($('#mID'+json.m).find('a.favourite'), rwdAnchorText);
400									if ($(".profileMiniBar").length) {
401										rwdToggleElement($('.profileMiniBar').find('a.favourite'), rwdAnchorText);
402									}
403									if (json.ss != "guest") {
404										var favouriteAnchorText = (typeof json.href != 'undefined' && json.href != null) ? rwdBuildAnchor(json, copyItems['favouriteAlbumInvite'], true) : '';
405										var favouriteElement = $('#mID'+json.m).find('a.favouritesOnly');
406										rwdToggleElement(favouriteElement, favouriteAnchorText);
407										if ($(".profileMiniBar").length) {
408											var favouriteElement = $('.profileMiniBar').find('a.favouritesOnly');
409											rwdToggleElement(favouriteElement, favouriteAnchorText);
410										}
411									}
412								} else {
413									toggleElement('favourite', 'addFavButton', 'remFavButton', anchorText);
414								}
415							} else {
416								if (json.rwd) {
417									rwdToggleElement($('#mID'+json.m).find('a.favourite'), rwdAnchorText);
418								} else {
419									toggleElement($('#mID'+json.m).find('li.remFavButton'), 'addFavButton', 'remFavButton', anchorText);
420								}
421							}
422						} else if (json.action == 'inRoster') {
423							chatAnchorElement = $('#chatAnchor');
424							if (json.value == 1) {
425								chatAnchorElement.click(subscribeToChat);
426							} else if (json.value == 2) {
427								chatAnchorElement.click(howToChat);
428							} else if (json.value == 3) {
429								chatAnchorElement.click(startChatting);
430							}
431							return false;  // disables notification area
432						} else if (json.rwd && json.action == 'remove' && (json.from == 'find_favourites' || json.from == 'find_mutuals')) {
433							restoreResult($('#mID'+json.m), json.m);
434							removeFromRemovedResults();
435						} else {
436							if (json.areMutualFans == true && typeof json.mutualFanAlert != "undefined" && typeof json.mutualFanAlert != "") {
437								notifyMutualFan(json.mutualFanAlert);
438							}
439							if (json.from == 'view' || json.from == 'find_morePhotos' || json.from == 'profile_summary') {
440								if (json.rwd) {
441									var elementLink = $('#mID'+json.m);
442									rwdToggleElement($('#mID'+json.m).find('a.favourite'), rw
442dAnchorText);
443
444									// Remove access to Favourites-Only photos
445									if (json.ss != "guest") {
446										var favouriteAnchorText = (typeof json.href != 'undefined' && json.href != null) ? rwdBuildAnchor(json, copyItems['favouriteAlbumRemove'], true) : '';
447										var favouriteElement = $('#mID'+json.m).find('a.favouritesOnly');
448										rwdToggleElement(favouriteElement, favouriteAnchorText);
449
450										if (typeof elementLink.find('a.favouritesOnly')[0] != "undefined") {
451											var onClickStr = elementLink.find('a.favouritesOnly')[0].getAttribute('onclick');
452											onClickStr = onClickStr.replace('return', 'return confirm(copyItems[\'confirmFavourite\']) &&');
453											elementLink.find('a.favouritesOnly')[0].setAttribute('onclick', onClickStr);
454										}
455									}
456									if ($(".profileMiniBar").length) {
457										var elementLink = $('.profileMiniBar');
458										rwdToggleElement($('.profileMiniBar').find('a.favourite'), rwdAnchorText);
459
460										// Remove access to Favourites-Only photos
461										if (json.ss != "guest") {
462											var favouriteAnchorText = (typeof json.href != 'undefined' && json.href != null) ? rwdBuildAnchor(json, copyItems['favouriteAlbumRemove'], true) : '';
463											var favouriteElement = $('.profileMiniBar').find('a.favouritesOnly');
464											rwdToggleElement(favouriteElement, favouriteAnchorText);
465
466											if (typeof elementLink.find('a.favouritesOnly')[0] != "undefined") {
467												var onClickStr = elementLink.find('a.favouritesOnly')[0].getAttribute('onclick');
468												onClickStr = onClickStr.replace('return', 'return confirm(copyItems[\'confirmFavourite\']) &&');
469												elementLink.find('a.favouritesOnly')[0].setAttribute('onclick', onClickStr);
470											}
471										}
472									}
473								} else {
474									toggleElement('favourite', 'remFavButton', 'addFavButton', anchorText+(json.note ? '<span class="note">'+json.note+'</span>' : ''));
475								}
476								if (typeof noteItems != 'undefined' && typeof noteItems["favPrivPhotos_add"] != 'undefined') {
477									// this is not applicable to messages/conversation thread, since we don't deal with photo invitees there
478									toggleElement('favPrivPhotos', 'addFavPhotoButton', 'remFavPhotoButton').find('div > p').html(noteItems["favPrivPhotos_add"]);
479								}
480								// Update start chatting link
481								if (typeof chatListener != 'undefined') {
482									var href = json.href;
483									var hrefParts = href.split('/s/');
484									var baseurl = hrefParts[0];
485									var url = baseurl + '/s/chat/chatRoster.php?a=inRoster&m=' + json.m + '&f=' + json.f;
486									result = ajaxRequest(url);
487								}
488							} else if (json.from == 'read' || json.from == 'mail_conversation') {
489								if (json.rwd) {
490									var elementLink = $('#mID'+json.m);
491									rwdToggleElement($('#mID'+json.m).find('a.favourite'), rwdAnchorText);
492									if (json.ss != "guest") {
493										var favouriteAnchorText = (typeof json.href != 'undefined' && json.href != null) ? rwdBuildAnchor(json, copyItems['favouriteAlbumRemove'], true) : '';
494										var favouriteElement = $('#mID'+json.m).find('a.favouritesOnly');
495										rwdToggleElement(favouriteElement, favouriteAnchorText);
496									}
497									if ($(".profileMiniBar").length) {
498										var elementLink = $('.profileMiniBar');
499										rwdToggleElement($('.profileMiniBar').find('a.favourite'), rwdAnchorText);
500										if (json.ss != "guest") {
501											var favouriteAnchorText = (typeof json.href != 'undefined' && json.href != null) ? rwdBuildAnchor(json, copyItems['favouriteAlbumRemove'], true) : '';
502											var favouriteElement = $('.profileMiniBar').find('a.favouritesOnly');
503											rwdToggleElement(favouriteElement, favouriteAnchorText);
504										}
505									}
506								} else {
507									toggleElement('favourite', 'remFavButton', 'addFavButton', anchorText);
508								}
509							} else {
510								if (json.rwd) {
511									rwdToggleElement($('#mID'+json.m).find('a.favourite'), rwdAnchorText);
512								} else {
513									toggleElement($('#mID'+json.m).find('li.addFavButton'), 'remFavButton', 'addFavButton', anchorText);
514								}
515							}
516						}
517					}
518					break;
519				case 'find_block':
520					if (json.paging) {
521						ajaxBuildPagingResults(json);
522					} else {
523						if (json.action == 'add') {
524							if (json.from == 'find_block') {
525								removeResult($('#mID'+json.m), json.m, json.href[0], (json.rwd || json.mobile), json.removalNote);
526							} else {
527								if (json.rwd) {
528									var elementLink = $('#mID'+json.m).find('span.blockReport');
529									var blockElement = elementLink.find('a.block');
530									var reportLink = elementLink.find('a.report');
531									rwdToggleElement(blockElement, rwdAnchorText);
532									
533									var onClickStr = elementLink.find('a.block')[0].getAttribute('onclick');
534									onClickStr = onClickStr.replace('return', 'return confirm(copyItems[\'confirmBlock\']) &&');
535									elementLink.find('a.block')[0].setAttribute('onclick', onClickStr);
536
537									if ($(".profileMiniBar").length) {
538										var elementLink = $(".profileMiniBar").find('span.blockReport');
539										if (elementLink.length) {
540											var blockElement = elementLink.find('a.block');
541											var reportLink = elementLink.find('a.report');
542											rwdToggleElement(blockElement, rwdAnchorText);
543
544											var onClickStr = elementLink.find('a.block')[0].getAttribute('onclick');
545											onClickStr = onClickStr.replace('return', 'return confirm(copyItems[\'confirmBlock\']) &&');
546											elementLink.find('a.block')[0].setAttribute('onclick', onClickStr);
547										}
548									}
549
550									var moreBoxElement = $('.moreBox');
551
552									// Toggle on private photo and favourite photo invites
553									var privateViewingOnlyElement = moreBoxElement.find("#privateViewingInvite");
554									var favouriteOnlyInviteElement = moreBoxElement.find("#favouriteOnlyInvite");
555									var privateViewingOnlyAnchor = privateViewingOnlyElement.find('.disabled');
556									var favouriteOnlyInviteAnchor = favouriteOnlyInviteElement.find('.disabled');
557									if (!privateViewingOnlyElement.hasClass("blockedUser") && !favouriteOnlyInviteElement.hasClass("blockedUser")) {
558										if (privateViewingOnlyAnchor.attr('data-href') && privateViewingOnlyAnchor.attr('data-href').indexOf("subscribe") !== -1) {
559											toggleElement(privateViewingOnlyElement,null,null,"<a class=\"cancelInvite launchSubscribeModal\" href=\""+privateViewingOnlyAnchor.attr('data-href')+"\">" + privateViewingOnlyAnchor.html() + " </a>");
560										} else {
561											toggleElement(privateViewingOnlyElement,null,null,"<a class=\"cancelInvite\" href=\""+privateViewingOnlyAnchor.attr('data-href')+"\" onclick=\"return ajaxRequest(this.href)\">" + privateViewingOnlyAnchor.html() + " </a>");
562										}
563										toggleElement(favouriteOnlyInviteElement,null,null,"<a class=\"favouritesOnly\" href=\""+favouriteOnlyInviteAnchor.attr('data-href')+"\" onclick=\"return ajaxRequest(this.href)\">" + favouriteOnlyInviteAnchor.html() + " </a>");
564										toggleElement(moreBoxElement.find(".blockViewControl"),null,"disableDisplay");
565									}
566								} else {
567									var blockElement = $('#block');
568									var reportSpan = outerHTML(blockElement.find('span.abuseSeperator')[0]);
569									var reportLink = outerHTML(blockElement.find('a:last')[0]);
570									blockElement = toggleElement(blockElement, 'addBlockButton', 'remBlockButton', (reportSpan != "" ? anchorText+reportSpan+reportLink : anchorText)+((blockElement.find('span.note').length != 0) && json.note ? '<span class="note">'+json.note+'</span>' : ''));
571									var onClickStr = blockElement.find('a:first')[0].getAttribute('onclick');
572									onClickStr = onClickStr.replace('return', 'return confirm(copyItems[\'confirmBlock\']) &&');
573									blockElement.find('a:first')[0].setAttribute('onclick', onClickStr);
574								}
575							}
576						} else {
577							if (json.from == 'find_block') {
578								restoreResult($('#mID'+json.m), json.m);
579								removeFromRemovedResults();
580							}
581							// First toggle the block/unblock
582							if (json.rwd) {
583								var elementLink = $('#mID'+json.m).find('span.blockReport');
584								var blockElement = elementLink.find('a.block');
585								var reportLink = elementLink.find('a.report');
586								rwdToggleElement(blockElement, rwdAnchorText);
587
588								// Now toggle the add/remove favourites
589								// for blocks, href is an array, 1st element is the block URL, 2nd element is the favourites URL
590								var favHref = json.href[1];
591								favHref = favHref.replace("remove", "add");
592								var options = {currPage: "find_favourites", href: favHref, action: "block"};
593								var favouriteAnchorText = (typeof favHref != 'undefined' && favHref != null) ? rwdBuildAnchor(json, anchorItems['find_favourites_add'], false, options) : '';
594								var favouriteElement = $('#mID'+json.m).find('a.favourite');
595								rwdToggleElement(favouriteElement, favouriteAnchorText);
596
597								if ($(".profileMiniBar").length) {
598									var elementLink = $('.profileMiniBar').find('span.blockReport');
599									if (elementLink.length) {
600										var blockElement = elementLink.find('a.block');
601										var reportLink = elementLink.find('a.report');
602										rwdToggleElement(blockElement, rwdAnchorText);
603									}
604
605									// Now toggle the add/remove favourites
606									// for blocks, href is an array, 1st element is the block URL, 2nd element is the favourites URL
607									var favouriteElement = $('.profileMiniBar').find('a.favourite');
608									rwdToggleElement(favouriteElement, favouriteAnchorText);
609								}
610
611								// Now toggle the add/remove Private-View invites
612								// for blocks, href is an array, 1st element is the block URL, 2nd element is the favourites URL
613								var moreBoxElement = $('.moreBox');
614								var invHref = moreBoxElement.find('.cancelInvite').attr('href');
615								if (typeof invHref !== typeof undefined && invHref !== false) {
616									invHref = invHref.replace("remove", "add");
617									var options = {currPage: "find_invites", href: invHref, action: "block"};
618									var inviteAnchorText = (typeof invHref != 'undefined' && invHref != null) ? rwdBuildAnchor(json, anchorItems['find_invites_add'], true, options) : '';
619									var inviteElement = $(moreBoxElement).find('a.cancelInvite');
620									rwdToggleElement(inviteElement, inviteAnchorText);
621								}
622
623								// Toggle the like/unlike photos
624								// for blocks, href is an array, 1st element is the block URL, 2nd element is the favourites URL, 3rd element is the photo likes URL
625								var photoLikeElement = $('#carousel-'+json.m).find('.photoLikes');
626								photoLikeElement.each(function(i, obj) {
627									var photoID = $(obj).attr("id");
628									photoID = photoID.replace(/\D/g, '');
629									if (photoID) {
630										if (typeof json.photoLikes[photoID] != "undefined") {
631											var photoLikeHref = json.photoLikes[photoID].href;
632											photoLikeHref = photoLikeHref.replace("remove", "add");
633											var photoLikeTitle = json.photoLikes[photoID].toolTip;
634											var photoLikeNum = json.photoLikes[photoID].numOfLikes;
635										} else {
636											var photoLikeHref = $('#photoLikes-'+photoID).find('a.like').attr("href");
637											photoLikeHref = photoLikeHref.replace("remove", "add");
638											var photoLikeTitle = copyItems['find_photoLikes_no_likes'];
639											var photoLikeNum = "0";
640										}
641										var options = {currPage: "find_photoLikes", href: photoLikeHref, action: "block", numOfLikes: photoLikeNum, toolTip: photoLikeTitle};
642										var photoLikeAnchorText = (typeof photoLikeHref != 'undefined' && photoLikeHref != null) ? rwdBuildAnchor(json, anchorItems['find_photoLikes_add'], false, options) : '';
643										rwdToggleElement($(obj).find(".photoLikesWrapper"), photoLikeAnchorText);
644										// tooltips must be initialized
645										if (typeof window.jQuery.fn.tipsy != 'undefined') {
646											if ($('.numofLikes').length) {
647												setTimeout(function() { 
648													$(obj).find(".numofLikes").tipsy({gravity: window.$.fn.tipsy.autoBounds("auto", 's'), opacity: 1, html: true});
649												});
650											}
651										}
652										// update total photo likes
653										var primaryPhotoLikes = $("#mID"+json.m).find(".information .image .primaryPhotoLikes .picCount");
654										if (primaryPhotoLikes.length) {
655											primaryPhotoLikes.html(json.totalPhotoLikes);
656										}
657									}
658								});
659
660								// Remove access to Favourites-Only photos
661								if (json.ss != "guest") {
662									var favHref = moreBoxElement.find('.favouritesOnly').attr('href');
663									if (typeof favHref !== typeof undefined && favHref !== false) {
664										favHref = favHref.replace("remove", "add");
665										var options = {currPage: "find_favourites", href: favHref, action: "block"};
666										var favouriteAnchorText = (typeof favHref != 'undefined' && favHref != null) ? rwdBuildAnchor(json, copyItems['favouriteAlbumInvite'], true, options) : '';
667										var favouriteElement = $(moreBoxElement).find('a.favouritesOnly');
668										rwdToggleElement(favouriteElement, favouriteAnchorText);
669									}
670								}
671
672								// Toggle off private photo and favourite photo invites
673								var privateViewingOnlyElement = moreBoxElement.find("#privateViewingInvite");
674								var favouriteOnlyInviteElement = moreBoxElement.find("#favouriteOnlyInvite");
675								var privateViewingOnlyAnchor = privateViewingOnlyElement.find('.cancelInvite');
676								var favouriteOnlyInviteAnchor = favouriteOnlyInviteElement.find('.favouritesOnly');
677								toggleElement(privateViewingOnlyElement,"disableDisplay",null,"<span class=\"disabled\" data-href=\""+privateViewingOnlyAnchor.attr('href')+"\"> " + privateViewingOnlyAnchor.html() + " </span>");
678								toggleElement(favouriteOnlyInviteElement,"disableDisplay",null,"<span class=\"disabled\" data-href=\""+favouriteOnlyInviteAnchor.attr('href')+"\"> " + favouriteOnlyInviteAnchor.html() + " </span>");
679								toggleElement(moreBoxElement.find(".blockViewControl"),"disableDisplay",null);
680							} else {
681								var blockElement = $('#block');
682								var reportSpan = outerHTML(blockElement.find('span.abuseSeperator')[0]);
683								var reportLink = outerHTML(blockElement.find('a:last')[0]);
684								
685								blockElement = toggleElement(blockElement, 'remBlockButton', 'addBlockButton', (reportSpan != "" ? anchorText+reportSpan+reportLink : anchorText)+((blockElement.find('span.note').length != 0) && json.note ? '<span class="note">'+json.note+'</span>' : ''));
686								
687								// Now toggle the add/remove favourites
688								// for blocks, href is an array, 1st element is the block URL, 2nd element is the favourites URL
689								var favHref = json.href[1];
690								favHref = favHref.replace("remove", "add");
691								var favouriteToolTipText = (typeof titleItems != 'undefined' && typeof titleItems['find_favourites_add'] != 'undefined' && titleItems['find_favourites_add'].length > 0) ? titleItems['find_favourites_add'] : null;
692								var favouriteAnchorText = (typeof favHref != 'undefined' && favHref != null) ? buildAnchor(favHref, anchorItems['find_favourites_add'], favouriteToolTipText) : '';
693								var favouriteElement = $('#favourite');
694								toggleElement(favouriteElement, 'addFavButton', 'remFavButton', favouriteAnchorText);
695							}
696						}
697					}
698					break;
699				case 'find_fans':
700					if (json.paging) {
701						ajaxBuildPagingResults(json);
702					} else {
703						if (json.action == 'hide') {
704							restoreResult($('#mID'+json.m), json.m);
705							removeFromRemovedResults();
706						} else {
707							removeResult($('#mID'+json.m), json.m, json.href, (json.rwd || json.mobile), json.removalNote, json.readditionNote);
708						}
709					}
710					break;
711				case 'find_matches':
712				case 'find_newMatches':
713				case 'find_matchesForMe':
714				case 'find_matchesForThem':
715					if (json.paging) {
716						ajaxBuildPagingResults(json);
717					} else {
718						if (json.action == 'exclude') {
719							restoreResult($('#mID'+json.m), json.m);
720							removeFromRemovedResults();
721						} else {
722							removeResult($('#mID'+json.m), json.m, json.href, (json.rwd || json.mobile), json.removalNote);
723						}
724					}
725					break;
726				case 'find_invites':
727					if (json.paging) {
728						ajaxBuildPagingResults(json);
729					} else {
730						if (json.action == 'add') {
731							if (json.from == 'find_invites') {
732								removeResult($('#mID'+json.m), json.m, json.href, (json.rwd || json.mobile), json.removalNote);
733							} else {
734								if (json.rwd) {
735									rwdToggleElement($('.moreBox').find('a.cancelInvite'), rwdAnchorText);
736								} else {
737									toggleElement('invPrivPhotos', 'addInvPhotoButton', 'remInvPhotoButton', anchorText+(json.note ? '<span class="note">'+json.note+'</span>' : ''));
738								}
739							}
740						} else {
741							if (json.rwd) {
742								if (json.from != "view") {
743									restoreResult($('#mID'+json.m), json.m);
744								}
745								removeFromRemovedResults();
746								rwdToggleElement($('.moreBox').find('a.cancelInvite'), rwdAnchorText);
747							} else {
748								restoreResult($('#mID'+json.m), json.m);
749								removeFromRemovedResults();
750								toggleElement('invPrivPhotos', 'remInvPhotoButton', 'addInvPhotoButton', anchorText+(json.note ? '<span class="note">'+json.note+'</span>' : ''));
751							}
752						}
753					}
754					break;
755				case 'find_search':
756					if (json.paging) {
757						ajaxBuildPagingResults(json);
758						break;
759					} else {
760						if (typeof copyItems != 'undefined') {
761							var infoRegex = /^(result_searchSaved|result_searchEdited|result_searchDeleted)$/;
762							if (json.result == 'result_searchLoaded') {
763								loadedSearch = true;
764								updateForm(json);
765							} else if (json.result.match(infoRegex)) {
766								// Provide notification inside div
767								var errRegex = /^err_/;
768								var textDivID = 'savedSearchInfo';
769								if (json.result.match(errRegex)) {
770									textDivID = 'savedSearchErr';
771								} else if (json.result == 'result_searchSaved' || json.result == 'result_searchEdited') {
772									textDivID = 'savedSearchSuccess';
773									enableButton('deleteSearchButton');
774								}
775								displayMsg(textDivID, copyItems[json.result]);
776								getSearchListOptions(json.i);
777								if (json.result == 'result_searchSaved') {
778									updateSavedStatus(false);
779								} else if (json.result == 'result_searchDeleted') {
780									$('#saveSearchOption').prop('selectedIndex', '0');
781									disableButton('deleteSearchButton');
782								}
783							} else if (json.result = 'result_searchListLoaded') {
784								refreshSearchList(json);
785								updateText('savedSearchTxt', copyItems['find_search_savedSearchList'] + ':', true);
786								show('saveSearchOption');
787							}
788						}
789						return false;  // disables notification area
790					}
791				case 'join':
792					var bodyJoin = "";
793					if ($('#usernameTaken_bodyJoin').length) {
794						bodyJoin = "_bodyJoin";
795					}
796					if (!json.usernameOk) {
797						$('#usernameTaken'+bodyJoin).html(copyItems['err_usernameTaken_select'] + json.result);
798						$('#usernameTaken'+bodyJoin).show();
799					} else {
800						$('#usernameTaken'+bodyJoin).hide();
801					}
802					return false;  // disables notification area
803				case 'info_poll':
804					if (json.pollPage == "info_poll") {
805						$('#memberPolls' + json.pollID).html(json.html);
806					} else {
807						$('#memberPolls').html(json.html);
808					}
809					break;
810				case 'find_ratings':
811					if (json.paging) {
812						ajaxBuildPagingResults(json);
813					} else {
814						if (json.rwd) {
815							if (json.clear) {
816								starBarSetup(json.m, true);
817							}
818						}
819					}
820					break;
821				case 'find_popular':
822					if (json.rwd) {
823						$('#featuredProfileCards').html(json.html);
824					}
825					return false;  // disables notification area
826				case 'mail_write':
827					if (json.sendPhotoRequest) {
828						rwdAnchorText = "<span>"+anchorItems['field_photoAlreadyRequested']+"</span>";
829						rwdToggleElement($('.textOverImage.summary').find("a"), rwdAnchorText);
830					}
831					break;
832				case 'find_byName':
833				case 'find_modified':
834				case 'find_new':
835				case 'find_keyword':
836				case 'find_birthdays':
837				case 'find_gallery':
838				case 'find_notes':
839				case 'find_history':
840				case 'find_historyByMe':
841				case 'find_historyImpress':
842				case 'find_invitedMe':
843				case 'find_mutuals':
844				case 'find_rogues':
845				case 'find_blocker':
846				case 'find_loggedIn':
847				case 'mail_conversations':
848				case 'find_photoLikesByMe':
849					if (json.paging) {
850						ajaxBuildPagingResults(json);
851					}
852					break;
853				case 'info_success':
854					if (json.paging) {
855						ajaxBuildPagingResults(json);
856						break;
857					} else if (json.action == "nextStories") {
858						$('#supportSuccessStories').html(json.html);
859					}
860					return false;  // disables notification area
861				case 'profile_photos':
862					window.location.href = json.redirectURL;
863					return false;
864				case 'find_photoLikes':
865					if (json.paging) {
866						ajaxBuildPagingResults(json);
867					} else {
868						if (json.rwd) {
869							$('#photoLikes-'+json.i).html(rwdAnchorText);
870							// tooltips must be initialized
871							if (typeof window.jQuery.fn.tipsy != 'undefined') {
872								if ($('.numofLikes').length) {
873									setTimeout(function() { 
874										$('.numofLikes').tipsy({gravity: window.$.fn.tipsy.autoBounds("auto", 's'), opacity: 1, html: true});
875									});
876								}
877							}
878							// update total photo likes
879							var primaryPhotoLikes = $("#mID"+json.m).find(".information .image .primaryPhotoLikes .picCount");
880							if (primaryPhotoLikes.length) {
881								primaryPhotoLikes.html(json.totalPhotoLikes);
882							}
883						}
884					}
885					break;
886			}
887		} else if (json.err) {
888			switch (json.currPage) {
889				case 'find_search':
890					if (typeof copyItems != 'undefined') {
891						if (json.err == 'err_searchAlreadyExists') {
892							var replace = confirm(copyItems['confirm_savedSearchReplace']);
893							if (replace) {
894								enableButton('saveSearchButton')
895								saveForm('form1', true);
896								disableButton('saveSearchButton')
897							} else {
898								errRegex = /^err_/;
899								var textDivID = 'savedSearchInfo';
900								if (json.err.match(errRegex)) {
901									textDivID = 'savedSearchErr';
902								}
903								displayMsg(textDivID, copyItems[json.err]);
904								enableButton('saveSearchButton')
905							}
906						} else {
907							errRegex = /^err_/;
908							var textDivID = 'savedSearchInfo';
909							var alertBanner = "info";
910							if (json.err.match(errRegex)) {
911								textDivID = 'savedSearchErr';
912							}
913							if (json.err.match(/^(find_search_maxReached10|find_search_maxReached2)$/)) {
914								alertBanner = "warning";
915								textDivID = 'savedSearchErr';
916							} else if (json.err.match(/^(err_searchNotFound|err_invalidRequest|err_sameAsIdealMatch)$/)) {
917								alertBanner = "error";
918							}
919							displayMsg(textDivID, copyItems[json.err], alertBanner);
920							enableButton('saveSearchButton');
921						}
922					}
923					return false;  // disables notification area
924				case 'find_photoLikes':
925				case 'find_favourites':
926					if (json.err == "err_nonNegMismatchBlock") {
927						alert(json.nonNegMismatchAlert);
928						return false;
929					}
930					return true;
931				case 'mail_write':
932					if (json.sendPhotoRequest) {
933						alert(copyItems[json.err]);
934					}
935					return false;
936			}
937		}
938	}
939	return true;
940}
941
942// Handle failures: confirm that there was a problem
943function handleAjaxErrors (failedResponse) {
944	// Over-ride the global variable based on the ajax response
945	// The "onBeforeUnload" events are not supported on iOS
946	isEventSupported = ('onbeforeunload' in window && typeof window.onbeforeunload == 'object');
947	if (!isEventSupported) {
948		if (failedResponse.xhr.readyState == 0 && failedResponse.xhr.status == 0 && !beforeUnloadFired) {
949			beforeUnloadFired = true;
950		}
951	}
952	// Ignore incomplete requests, likely due to navigating away from the page
953	if (!beforeUnloadFired) {
954		if (failedResponse.noRetry) {
955			ajaxNoRetry();
956		} else {
957			ajaxRetry(failedResponse.url);
958		}
959	} else {
960		beforeUnloadFired = false;
961	}
962}
963
964// Perform a regular page load
965function ajaxRetry (url) {
966	if (confirm(copyItems["err_ajaxGeneralFailure"])) {
967		loadUrl(url);  // try loading the URL normally
968	}
969}
969
970
971// Only display an error alert, do not allow user to retry
972function ajaxNoRetry () {
973	alert(copyItems["err_ajaxGeneralFailureNoRetry"]);
974}
975
976
977// Callback function to remove stale status messages
978function removeStatusMsg (msgID) {
979	if (typeof jQuery != 'undefined') {
980		$('#' + msgID).remove();
981		statusMsgCount--;
982		
983		// check whether the notification area needs to be hidden
984		if (statusMsgCount < 1 && notificationAreaVisibile) {
985			keepNotificationAreaVisible = false;
986			notificationArea.hide();
987			notificationAreaVisibile = !notificationAreaVisibile;
988		}
989	}
990}
991
992// Build and show an appropriate status message in the notification area on completion of an Ajax action
993function notify (jsonObject, timeout) {
994	if (typeof jQuery != 'undefined') {
995		// build a unique ID for each new status message
996		var statusMsgID = 'status'+generateUID();
997
998		// set tooltip text if available
999		var toolTipText = null;
1000		if (typeof copyItems != 'undefined') {
1001			var copyItemKey = (jsonObject.result) ? 'success' : 'error';
1002			toolTipText = (typeof copyItems[copyItemKey] != 'undefined' && copyItems[copyItemKey].length > 0) ? copyItems[copyItemKey] : null;
1003		}
1004		
1005		// insert a new list item at the end of the unordered list
1006		if (jsonObject.currPage != 'join') {
1007			$('#notification').append('<li'+((toolTipText != null) ? ' title="'+toolTipText+'"' : '')+' id="'+statusMsgID+'" class="'+((jsonObject.result) ? 'successful' : 'unsuccessful')+'">'+copyItems[((jsonObject.result) ? jsonObject.result : jsonObject.err)]+'</li>');
1008		}
1009		statusMsgCount++;
1010		
1011		// ensure that the notification area is visible
1012		if (!notificationAreaVisibile) {
1013			notificationArea.show();
1014			notificationAreaVisibile = !notificationAreaVisibile;
1015		}
1016		
1017		// manage the cleanup of stale status messages via a callback function
1018		if (typeof jQuery != 'undefined') {
1019			$('#' + statusMsgID).delay(700).fadeOut( 300, function() {
1020				removeStatusMsg(statusMsgID);  // easier to call this directly from within an anonymous function
1021			});
1022		} else {
1023			// fallback
1024			var onTimeout = function () {
1025				$('#' + statusMsgID).hide();
1026				removeStatusMsg(statusMsgID);
1027			};
1028			setTimeout(onTimeout, timeout * 1000);
1029		}
1030	}
1031}
1032
1033function ajaxBuildPagingResults (json) {
1034	var lastContainer = firstContainer = 0;
1035	// determine after which container is the next batch of results inserted
1036	$('#pagingResults').children().each(function() {
1037		var pagingResult = this.id.replace( /^\D+/g, '');
1038		pagingResult = parseInt(pagingResult);
1039		if (json.p > pagingResult) { 
1040			lastContainer = pagingResult;
1041		} else {
1042			firstContainer = pagingResult;
1043			return false;
1044		}
1045	});
1046
1047	if (json.p < json.thisPage) {
1048		// scrolling up the browser is auto jumping when new content is prepended
1049		// storing the scroll position before the prepend
1050		var anchorContainer = $("#pagingResult" + firstContainer);
1051		var anchorTopBefore = anchorContainer[0].getBoundingClientRect().top;
1052		var scrollBefore = window.pageYOffset;
1053		var heightBefore = document.body.scrollHeight;
1054
1055		$(json.html).insertBefore($("#pagingResult" + firstContainer));
1056
1057		// correct the shift
1058		var heightDiff = document.body.scrollHeight - heightBefore;
1059		document.documentElement.scrollTop = scrollBefore + heightDiff;
1060		document.body.scrollTop = scrollBefore + heightDiff; // Safari fallback
1061	} else {
1062		$(json.html).insertAfter($("#pagingResult" + lastContainer));
1063	}
1064
1065	if (json.p) {
1066		//load more button
1067		if (!json.lastPage) {
1068			if (json.p > json.thisPage) {
1069				$('.pagingLoadMore').hide();
1070				var totalPages = pages["total"];
1071				if (typeof totalPages != 'undefined' && resultsPages.indexOf(totalPages.toString()) == -1) {
1072					$(".pagingLoadMore:last").show();
1073				}
1074			}
1075		} else {
1076			// if last page of results then hide all load more buttons
1077			$('.pagingLoadMore').hide();
1078		}
1079
1080		// remove previous progress bar
1081		if ($(".stickyFooter").length) {
1082			$(".stickyFooter").first().remove();
1083			// initialize new sticky pagination bar
1084			$("#navBarResult"+json.p).stickyPanels({
1085				paginationBar: true
1086			});
1087		}
1088
1089		// select arrow style change
1090		if (typeof changeSelectorDropDownArrows == "function") {
1091			changeSelectorDropDownArrows();
1092		}
1093
1094		// scroll to pageNum
1095		$(".pagingBox.pagingBoxHeader").removeClass();
1096		if (!json.scroll) {
1097			if ($("#pagingResult"+json.p).length) {
1098				animateScrolling(json.p);
1099			}
1100		} else {
1101			isFetching = false;
1102		}
1103
1104		// userNotes and Ratings
1105		if (json.currPage != "find_gallery" && json.currPage != "mail_conversations" && json.currPage != "info_success") {
1106			starBarSetup();
1107			unwSetup();
1108		}
1109	}
1110}
1111
1112// Alert a user when the profile just favourited is a mutual fan.
1113function notifyMutualFan (alertContent) {
1114	if ($("#mFanModalWrap").length) {
1115		// Populate the modal with the response html
1116		$("#mFanModalWrap .modalContentWrap").html(alertContent.html);
1117	}
1118	if (typeof $.fn.easyModal != "undefined") {
1119		// not able to close the modal using the back button, modal launches on page load
1120		// popstate will not trigger on back button if no user interaction
1121		// initialize easyModal
1122		var modalOptions = easyModalOptions(true);
1123		// removes the previously attached event
1124		$('#mFanModalWrap').off().easyModal(modalOptions);
1125	}
1126	// Display the modal
1127	$("#mFanModalWrap").trigger('openModal');
1128}
1129
1130function getAllUrlParams (url) {
1131	// get query string from url
1132	var queryString = url ? url.split('?')[1] : '';
1133	// we'll store the parameters here
1134	var urlParams = {};
1135	// if query string exists
1136	if (queryString) {
1137		urlParams.url = url.split("?")[0];
1138		// stuff after # is not part of query string, so get rid of it
1139		queryString = queryString.split('#')[0];
1140		// split our query string into its component parts
1141		var arr = queryString.split('&');
1142		var obj = {};
1143		for (var i = 0; i < arr.length; i++) {
1144			// separate the keys and the values
1145			var results = arr[i].split('=');
1146			// set parameter name and value
1147			var paramName = decodeURIComponent(results[0]);
1148			var paramValue = decodeURIComponent(results[1]);
1149			if (!obj[paramName]) {
1150				// if it doesn't exist, create property
1151				obj[paramName] = paramValue;
1152			} else if (obj[paramName] && typeof obj[paramName] === 'string') {
1153				// if property does exist and it's a string, convert it to an array
1154				obj[paramName] = [obj[paramName]];
1155				obj[paramName].push(paramValue);
1156			} else {
1157				// otherwise add the property
1158				obj[paramName].push(paramValue);
1159			}
1160		}
1161		urlParams.data = obj;
1162	}
1163	return urlParams;
1164}
1165
1166// Define global variables
1167var notificationArea = null;
1168var activityIndicator = null;
1169var notificationAreaVisibile = null;
1170var activityIndicatorVisible = null;  // set these all to null initially; they get properly set onLoad
1171var keepNotificationAreaVisible = false;  // used determine whether or not the notification area should be hidden
1172var statusMsgCount = 0;  // number of status messages being shown inside the notification area
1173var removedResults = new Array;  // Profiles removed from a search result page
1174var beforeUnloadFired = false;
1175
1176if (typeof jQuery != 'undefined') {
1177	$(document).ready(function() {
1178		notificationArea = $("#notification");
1179		activityIndicator = $("#activityIndicator");
1180		notificationAreaVisibile = (notificationArea.css("display") == "block");
1181		activityIndicatorVisible = (activityIndicator.css("display") == "block");
1182		
1183		// these responders execute on creation and on completion of each Ajax request
1184		$(document).ajaxSend(function (event, XMLHttpRequest, ajaxOptions) {
1185		   if (notificationArea && activityIndicator && jQuery.active == 1) {
1186				// on creation of the first Ajax request...
1187				// show the activity indicator
1188				var ajaxURL  = ajaxOptions.url;
1189				if (ajaxURL.indexOf("realTimeMessaging.php") >= 0 || ajaxURL.indexOf("conversation.php") >= 0 || ajaxURL.indexOf("photos.php") >= 0 || ajaxURL.indexOf("fileUploadStatus.php") >= 0) {
1190					return false;
1191				}
1192				if (!activityIndicatorVisible) {
1193					activityIndicator.show();
1194					activityIndicatorVisible = !activityIndicatorVisible;
1195				}
1196				
1197				// show the notification area
1198				if (!notificationAreaVisibile) {
1199					notificationArea.show();
1200					notificationAreaVisibile = !notificationAreaVisibile;
1201				}
1202			}
1203		}).ajaxComplete(function (event, XMLHttpRequest, ajaxOptions) {
1204		   if (notificationArea && activityIndicator && jQuery.active == 1) {
1205				// on completion of the last Ajax request...
1206				// provided there are no status messages being displayed, hide the notification area
1207				if (!keepNotificationAreaVisible && notificationAreaVisibile) {
1208					notificationArea.hide();
1209					notificationAreaVisibile = !notificationAreaVisibile;
1210				}
1211				
1212				// hide the activity indicator
1213				if (activityIndicatorVisible) {
1214					activityIndicator.hide();
1215					activityIndicatorVisible = !activityIndicatorVisible;
1216				}
1217			}
1218		});
1219
1220		// Handle the error from an ajax request, when the user navigates away from the page
1221		$(window).on('beforeunload', function(e) {
1222			beforeUnloadFired = true;
1223		});
1224	});	
1225}
1226
1227function ajaxAlways (json) {
1228	if (typeof jQuery != 'undefined') {
1229		if (typeof json != 'undefined') {
1230			switch (json.currPage) {
1231				case 'find_search':
1232					if (typeof json.i != 'undefined') {
1233						var element = $('#saveSearchOption');
1234						element.children('option').each(function(index, option){
1235							if (option.value == json.i) {
1236								option.selected = true;
1237							} else {
1238								option.selected = false;
1239							}
1240						});
1241					}
1242					break;
1243			}
1244		}
1245	}
1246}

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.