PageSourceSearch

https://www.refersion.com/js/app.js

js refersion.com collected 2026-10-02 02:28:25 UTC 13,600 bytes, 542 lines download raw bytes

1	////////////////////////////////
2	// LOAD MORE
3	////////////////////////////////
4
5	function load_more(record_num, ajax_url, d) {
6
7		record_num = typeof record_num !== 'undefined' ? record_num : 10;
8		$("form#search-form #record_num").val(record_num);
9
10		$.ajax({
11			type: "POST",
12			dataType: 'html',
13			url: ajax_url,
14			data: d,
15			success: function(html) {
16				if (html) {
17					$("tr#load-more").before(html);
18					// $("html, body").animate({ scrollTop: $(document).height() }, 'slow');
19				}
20			}
21		});
22
23	}
24
25	////////////////////////////////
26	// BOOTSTRAP MODAL AJAX
27	////////////////////////////////
28
29	$(document).on("click", "[data-toggle=modal]", function(event) {
30
31		event.preventDefault();
32		var url = $(this).attr("data-rel");
33		var modal_style = $(this).attr("data-modal-width");
34		var modal_id = $(this).attr("data-modal-id");
35		var disable_click_outside = $(this).attr("data-modal-prevent-clicking-outside");
36
37		if (modal_style == 'large') {
38			modal_style = 'modal-large';
39		}
40		if (typeof modal_style == "undefined") {
41			modal_style = 'modal-small';
42		}
43		var modal_id_string = '';
44		if (typeof modal_id !== "undefined") {
45			modal_id_string = 'id="' +modal_id+'" ';
46		}
47
48		if(disable_click_outside == 'true')
49		{
50			var disable_click_outside_config = 'data-backdrop="static" data-keyboard="false"';
51		}
52
53		if (url.indexOf("#") == 0) {
54			$(url).modal('open');
55		} else {
56			$.get(url, function(data) {
57				$('<div ' + modal_id_string + ' class="modal hide fade ' + modal_style + '" ' + disable_click_outside_config + '>' + data + '</div>').modal().on('hidden', function () { $(this).remove(); });
58			}).success(function() {
59				$('.modal-body input:text:visible:first').focus();
60			});
61		}
62
63	});
64
65	$(document).on("click", "[data-toggle=modal_make]", function(event) {
66
67		// Get container
68		var c = $($(this).attr('data-rel'));
69
70		// Title
71		var t = $(this).attr('data-title');
72
73		// Make and show the modal
74		makeModal(c, t);
75
76	});
77
78	// Helper function to make any container a modal
79	function makeModal(e, t) {
80
81		// Set up modal header
82		if (t !== undefined) {
83			var header = '<div class="modal-header"><a class="close" data-dismiss="modal">&times;</a><h3>' + t + '</h3></div>';
84		} else {
85			var header = '';
86		}
87
88		// Modal
89		$('<div class="modal hide fade">' + header + '<div class="modal-body" style="min-height: 50px;">' + $(e).html() + '</div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">Close</button></div></div>').modal().on('hidden', function () { $(this).remove(); });
90		$('.modal-body input:text:visible:first').focus();
91
92	}
93
94	////////////////////////////////
95	// DONUT CART
96	////////////////////////////////
97
98	$(function() {
99		if(jQuery().easyPieChart) {
100			$('.donut_chart').easyPieChart({
101				barColor: '#3A71AC',
102				trackColor: '#EEEEEE',
103				animate: 750,
104				scaleColor: false,
105				lineCap: 'square',
106				scaleLength: 10,
107				size: 110,
108				lineWidth: 15,
109				onStep: function(from, to, percent) {
110					$(this.el).find('.percent').text(Math.round(percent));
111				}
112			});
113		}
114	});
115
116	////////////////////////////////
117	// IPAD DROP DOWN BUTTON FIX
118	////////////////////////////////
119
120	$('body').on('touchstart.dropdown', '.dropdown-menu', function (e) {
121		e.stopPropagation();
122	});
123
124	////////////////////////////////
125	// HASH LINKS
126	////////////////////////////////
127
128	$(document).ready(function () {
129		if (window.location.hash) {
130			$(window.location.hash).click(); //clicks on element specified by hash
131		}
132	})
133
134	////////////////////////////////
135	// CHART
136	////////////////////////////////
137
138
139	function drawChart(cssSelector, dataVariable, ticksData) {
140
141		var result = window.regression('polynomial', regresionData);
142		var dataFinal = result.points;
143
144		var regressionData = {
145
146			// Based on the second line
147			color: "#AFAFAF",
148			label: 'Trend Line',
149			data: dataFinal,
150			points: {
151				show: false,
152				radius: 0,
153				fill: false
154			},
155
156			lines:{show:true, lineWidth:1 },
157		};
158
159		// add regresion data to graph data object.
160		dataVariable.push(regressionData);
161
162		// GRAPH FORMATING
163		$.plot($(cssSelector), dataVariable, {
164			legend: {
165				noColumns: 0,
166				backgroundOpacity: 0,
167				position: "nc",
168				show: true
169			},
170			series: {
171				shadowSize: 0
172			},
173			grid: {
174				color: '#646464',
175				borderColor: '#DDD',
176				borderWidth: 0,
177				hoverable: true
178			},
179			xaxis: {
180				mode: 'time',
181				timezone: 'browser',
182				timeformat: '%b-%d-%Y',
183				tickDecimals: 0,
184				tickColor: 'transparent',
185				ticks: ticksData
186			},
187			yaxes: [{
188				// minTickSize: 1,
189				tickLength: 0,
190				tickDecimals: 0,
191				position: 'right',
192				tickFormatter: function (val, axis) {
193					val += '';
194					x = val.split('.');
195					x1 = x[0];
196					x2 = x.length > 1 ? '.' + x[1] : '';
197					var rgx = /(\d+)(\d{3})/;
198					while (rgx.test(x1)) {
199						x1 = x1.replace(rgx, '$1' + ',' + '$2');
200					}
201					return x1 + x2;
202				}
203			},{
204				// minTickSize: 1000,
205				tickDecimals: 0,
206				position: 'left',
207				tickFormatter: function (val, axis) {
208					val += '';
209					x = val.split('.');
210					x1 = x[0];
211					x2 = x.length > 1 ? '.' + x[1] : '';
212					var rgx = /(\d+)(\d{3})/;
213					while (rgx.test(x1)) {
214						x1 = x1.replace(rgx, '$1' + ',' + '$2');
215					}
216					return x1 + x2;
217				}
218			}]
219		});
220
221		var previousPoint = null;
222
223		$(cssSelector).bind('plothover', function (event, pos, item) {
224			if (item) {
225				if (previousPoint != item.dataIndex) {
226					previousPoint = item.dataIndex;
227					$('#tooltip').remove();
228					var x = item.datapoint[0],
229						y = item.datapoint[1];
230						$('<div id="tooltip">' + y + '</div>').css({
231							top: item.pageY - 16,
232							left: item.pageX + 20
233						}).appendTo('body').fadeIn();
234				}
235			} else {
236				$('#tooltip').remove();
237				previousPoint = null;
238			}
239		});
240
241
242
243	}
244
245	////////////////////////////////
246	// APPEND SUBID TO URL
247	////////////////////////////////
248
249	function addParameter(url, param, value) {
250		var val = new RegExp('(\\?|\\&)' + param + '=.*?(?=(&|$))'), qstring = /\?.+$/;
251		if (val.test(url)) {
252			return url.replace(val, '$1' + param + '=' + value);
253		} else if (qstring.test(url)) {
254			return url + '&' + param + '=' + value;
255		} else {
256			return url + '?' + param + '=' + value;
257		}
258	}
259
260	////////////////////////////////
261	// TABS
262	////////////////////////////////
263
264	$(function() {
265		$(".tab1 li").click(function(e) {
266			e.preventDefault();
267			$(".tab1 li").removeClass("active");
268			$(this).addClass("active");
269			$($(this).attr("data-tab-group")).hide();
270			$($(this).attr("data-rel")).show();
271		});
272	});
273
274	////////////////////////////////
275	// MOBILE MENU
276	////////////////////////////////
277
278	$(document).ready(function () {
279
280		if ($.isFunction('slicknav')) {
281
282			// Main menu
283			$('.mobile_menu').slicknav({
284				prependTo: '.main-nav'
285			});
286			$("a.show_mobile_menu").click(function(e) {
287				e.preventDefault();
288				$('.mobile_menu').slicknav('toggle');
289			});
290
291			// Main menu
292			$('#header_menu .mobile').slicknav({
293				prependTo: '.desktop'
294			});
295
296		};
297
298	});
299
300	////////////////////////////////
301	// AUTO CHECK ON TABLE ROW CLICK
302	////////////////////////////////
303
304	$(document).ready(function() {
305
306		$(document.body).on('click', '.table.table-striped tr:has(> td)' ,function(event){
307
308			if (event.target.type !== 'checkbox') {
309				$(':checkbox', this).trigger('click');
310			}
311
312		});
313
314	});
315
316	////////////////////////////////
317	// TABLE ROW MORE INFO (HOVER)
318	////////////////////////////////
319
320	$(document).ready(function() {
321
322		$(document).on("click", ".table.table-striped.table-with-expandable tbody tr:not(#load-more, .table-row-mf-link)", function(e) {
323
324			// Which URL do we send?
325			var row_id = $(this).attr("data-row-id");
326			var expandable_url = $(this).attr("data-expandable-url");
327
328			// Remove all other white border tops
329			$('.table.table-striped tbody tr .border-top-none').removeClass('border-top-none');
330
331			// Remove others
332			$('.table.table-striped tbody tr td').removeClass('table-row-selected');
333			$('.table.table-striped tbody tr.table-row-mf-link').remove();
334
335			// Select all of the cells in the row
336			$(this).find('td').addClass('table-row-selected');
337
338			// Add the row that contains the more info link and expandable panel
339			$(this).after('<tr class="table-row-mf-link"><td colspan="100" class="table-expandable-panel"><p style="text-align: center; padding: 0px; margin: 0px; line-height: 0px;"><a href="#" class="table-show-more-info" data-expandable-url="' + expandable_url + '" data-rel="' + row_id + '">More Info</a></a></td></tr>');
340
341			// Remove the top borders below
342			$(this).next('.table-row-mf-link').next('tr').find('td').addClass('border-top-none');
343
344		});
345
346		$(document).on("click", ".table-expandable-panel .close-panel", function(e) {
347
348			e.preventDefault();
349
350			// Remove all other white border tops
351			$('.table.table-striped tbody tr .border-top-none').removeClass('border-top-none');
352
353			// Remove others
354			$('.table.table-striped tbody tr td').removeClass('table-row-selected');
355			$('.table.table-striped tbody tr.table-row-mf-link').remove();
356
357		});
358
359		$(document).on("click", ".table-show-more-info", function(e) {
360
361			e.preventDefault();
362
363			var url = $(this).attr("data-expandable-url") + $(this).attr("data-rel");
364
365			// Get expandable view
366			$.ajax({
367				type: 'GET',
368				dataType: 'html',
369				url: url,
370				data: {  },
371				success: function(html) {
372
373					// Styling
374					$('.table-expandable-panel').parent().addClass('table-row-mf-link-selected');
375
376					// Show success message
377					$('.table-expandable-panel').html(html);
378
379				}
380			});
381
382		});
383
384		$(document).mouseup(function (e) {
385
386			var container = $(".table.table-striped.table-with-expandable tbody tr:not(#load-more, .table-row-mf-link), .table-show-more-info, .table-row-mf-link-selected");
387
388			if (!container.is(e.target) // if the target of the click isn't the container...
389				&& container.has(e.target).length === 0) // ... nor a descendant of the container
390			{
391					// Remove all other white border tops
392					$('.table.table-striped tbody tr .border-top-none').removeClass('border-top-none');
393
394					// Remove others
395					$('.table.table-striped tbody tr td').removeClass('table-row-selected');
396					$('.table.table-striped tbody tr.table-row-mf-link').remove();
397			}
398
399		});
400
401	});
402
403	////////////////////////////////
404	// LIGHTEN / DARKEN HEX COLOR
405	////////////////////////////////
406
407	function lightenDarkenColor(col, amt) {
408
409		var usePound = false;
410
411		if (col[0] == "#") {
412			col = col.slice(1);
413			usePound = true;
414		}
415
416		var num = parseInt(col,16);
417
418		var r = (num >> 16) + amt;
419
420		if (r > 255) r = 255;
421		else if  (r < 0) r = 0;
422
423		var b = ((num >> 8) & 0x00FF) + amt;
424
425		if (b > 255) b = 255;
426		else if  (b < 0) b = 0;
427
428		var g = (num & 0x0000FF) + amt;
429
430		if (g > 255) g = 255;
431		else if (g < 0) g = 0;
432
433		return (usePound?"#":"") + (g | (b << 8) | (r << 16)).toString(16);
434
435	}
436
437	// Load country's states
438
439	function load_states(control, url, data, state_selected) {
440
441		var data = "country_id="+$(control).val()+"&"+data+"&state_selected="+state_selected;
442
443		$.ajax({
444			method:"POST",
445			url: url,
446			data: data,
447			dataType:"json",
448			success:function(response){
449				if( ( typeof( response.status ) !== 'undefined' ) && ( response.status == 'success' ) ) {
450					// Load html received and refresh customSelect (if it exists)
451					$("#state").empty().html( response.states).addClass("states_loaded").trigger('render');
452				}
453			}
454		});
455
456	}
457
458	// Refresh status of affiliates/conversions bulk processing
459	function refresh_bulk_processing_status(url, data, bulk_type){
460
461		var interval = setInterval(function(){
462			$.ajax({
463				method:'POST',
464				url:url,
465				dataType:'json',
466				data:data,
467				success:function(response){
468
469					// If it is successful
470					if( ( typeof( response.status ) !== 'undefined' ) && ( response.status == 'COMPLETED' ) ){
471
472						clearInterval(interval);
473
474						if( bulk_type == 'AFFILIATE' ) {
475							$(".affiliates_processing_complete").toggle();
476						}
477
478						if( bulk_type == 'CONVERSION' ) {
479							$(".conversions_processing_complete").toggle();
480						}
481
482						// Refresh the page
483						location.reload();
484
485					}
486
487					// If there are items remaining to approve/deny
488					if( ( typeof( response.num_remaining ) !== 'undefined' ) ){
489
490						$('#num_remaining').show();
491						$('#num_remaining span').html(response.num_remaining);
492
493					}
494
495				}
496			});
497		}, 5000);
498
499	}
500
501	////////////////////////////////
502	// COPY TO CLIPBOARD
503	////////////////////////////////
504	function copyToClipboard(promise) {
505		return new Promise((resolve, reject) => {
506			if (typeof ClipboardItem && navigator.clipboard.write) {
507				// Handle Safari and Chrome.
508				
509				// Safari does not allow the clipboard
510				// api to be used async and will throw an error. To write to the clipboard
511				// for Safari the interaction must be a direct interaction triggered by the user.
512				// More info here https://bugs.webkit.org/show_bug.cgi?id=222262
513
514				const text = new ClipboardItem({
515					"text/plain": promise
516						.then(response => {
517							return response;
518						})
519						.then(text => new Blob([text], { type: 'text/plain' }))
520						.catch((err) => reject(err))
521				});
522
523				navigator.clipboard.write([text])
524					.then(() => {
525						resolve(text);
526					})
527					.catch((err) => {
528						reject(err);
529					});
530			} else {
531				// Handle Firefox
532
533				// Firefox doesn't care if something is written to the clipboard async in a promise
534				promise
535					.then(response => response)
536					.then(text => {
537						navigator.clipboard.writeText(text).then(() => resolve(text)).catch((err) => reject(err));
538					})
539					.catch(err => reject(err))
540			}
541		});
542	}

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.