1 2// JS code that runs on every page. 3// Should be wrapped in a document ready like below. 4 5jQuery(document).ready(function($) { 6 7 /** SCID Tracking **/ 8 // Set the cookie if the parameter exists 9 // Parse the URL 10 function getParameterByName(name) { 11 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); 12 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 13 results = regex.exec(location.search); 14 return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 15 } 16 // Give the URL parameters variable names 17 var scid_cookie = getParameterByName('scid'); 18 var cid_cookie = getParameterByName('cid'); 19 20 var cookieDate = new Date(); 21 cookieDate.setTime(cookieDate.getTime()+(240*60*60*1000)); // save for 10 days 22 23 // Set the cookies 24 if (scid_cookie != null && scid_cookie != '' ){ 25 document.cookie = "scid="+scid_cookie+"; expires="+cookieDate.toGMTString()+";path=/"; 26 } 27 if (cid_cookie != null && cid_cookie != '' ){ 28 document.cookie = "cid="+cid_cookie+"; expires="+cookieDate.toGMTString()+";path=/"; 29 } 30 31 // Get the SCID Value 32 function getCookie(name) { 33 var cookieArr = document.cookie.split(";"); 34 for(var i = 0; i < cookieArr.length; i++) { 35 var cookiePair = cookieArr[i].split("="); 36 if(name == cookiePair[0].trim()) { 37 return decodeURIComponent(cookiePair[1]); 38 } 39 } 40 return null; 41 } 42 43 44 if (document.cookie.indexOf('scid') >= 0 ){ 45 var scid_value = getCookie('scid'); 46 47 if (scid_value != null) { 48 49 setTimeout(function() { 50 // change booking url here 51 $('a[href*="marriott.com/"]').each(function() { 52 var link_href = $(this).attr('href'); 53 console.log(link_href); 54 if (link_href.indexOf("?") >= 0) { 55 $(this).attr('href', link_href + '&scid=' + scid_value ); 56 } else { 57 $(this).attr('href', link_href + '?scid=' + scid_value ); 58 } 59 }) 60 61 // change form id here 62 $('.bookingForm').each(function() { 63 $(this).prepend('<input type="hidden" name="scid" id="scid" value="'+scid_value+'" />'); 64 }) 65 }, 1000); 66 67 } 68 69 } 70 71 if (document.cookie.indexOf('cid') >= 0 ){ 72 var cid_value = getCookie('cid'); 73 74 if (cid_value != null) { 75 76 setTimeout(function() { 77 // change booking url here 78 $('a[href*="marriott.com/"]').each(function() { 79 var link_href = $(this).attr('href'); 80 if (link_href.indexOf("?") >= 0) { 81 $(this).attr('href', link_href + '&cid=' + cid_value ); 82 } else { 83 $(this).attr('href', link_href + '?cid=' + cid_value ); 84 } 85 }) 86 87 // change form id here 88 $('.bookingForm').each(function() { 89 $(this).prepend('<input type="hidden" name="cid" id="cid" value="'+cid_value+'" />'); 90 }) 91 }, 1000); 92 93 } 94 95 } 96 /* END SCID */ 97 98});
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.