1jQuery(document).ready(function($){ 2 var countdown; 3 function cpln_close_notice(){ 4 $('.cpln-leavenotice').removeClass('cpln-active'); 5 } 6 function cpln_set_displayed_url(url){ 7 $('.cpln-redirect-link').html('<a target="_blank" class="cpln-redirect-url" href="'+url+'">'+url+'</a>'); 8 } 9 function cpln_open_notice(){ 10 $('.cpln-leavenotice').addClass('cpln-active'); 11 } 12 function cpln_auto_redirect(el, url){ 13 //get start time 14 var start = parseInt(el.dataset.startTime); 15 var timeLeft = start; 16 el.innerHTML = start; //when countdown was previously closed... this resets the UI timer 17 18 //set countdown, redirect, close window, and reset html 19 countdown = setInterval(function(){ 20 timeLeft--; 21 el.innerHTML = timeLeft; 22 if(timeLeft < 1){ 23 window.open(url, '_blank'); 24 clearInterval(countdown); 25 cpln_close_notice(); 26 el.innerHTML = start; 27 } 28 }, 1000); 29 } 30 function cpln_stop_redirect(){ 31 if(countdown){ 32 clearInterval(countdown); 33 } 34 } 35 36 //get exclusion URLs, convert to regex, convert to array 37 var cplnExclusions = []; 38 $('li.cpln-exclude').each(function(){ 39 var cplnExclude = $(this).html(); 40 41 //convert common URL features to regex-ready strings 42 cplnExclude = cplnExclude.replace(/\//g,'\\/'); 43 //cplnExclude = cplnExclude.replace(/\:/g,'\\:'); 44 cplnExclude = cplnExclude.replace(/\-/g,'\\-'); 45 46 //tag on the exclusions to the array 47 cplnExclusions.push( cplnExclude ); 48 49 }); 50 51 var cplnExList = '!obj.href.match(/^mailto\:/) && !obj.href.match(/^tel\:/) && !obj.href.match(/^javascript/) && (obj.hostname !== location.hostname)'; 52 //checks to see if any exclusions have been entered, if so, add them to the exclusion list 53 if(cplnExclusions.length > 0 && cplnExclusions[0] !== '') { 54 for(var i = 0; i < cplnExclusions.length; i++){ 55 cplnExList = cplnExList.concat(' && !obj.href.match(/' + cplnExclusions[i] + '/)'); 56 } 57 } 58 //console.log(cplnExList); 59 // Creating custom :external selector 60 $.expr[':'].external = function(obj){ //all links except mailto, tel, and links with hostname location 61 return eval(cplnExList); 62 }; 63 64 // Add 'external' CSS class to all external links 65 $('a[href]:external').addClass('external'); 66 $('.no-notice').removeClass('external'); //add class 'no-popup' on any link you want to exclude from external warning 67 $('.no-notice a').removeClass('external'); //allows applying class to menu navigation 68 $('a.external').click(function(e){ 69 e.preventDefault(); 70 //if the element clicked on is NOT the link (i.e. a button with an icon), travel up until you find the element with the href 71 var url = (e.target.hasAttribute('href')) ? e.target.getAttribute('href') : $(this).closest('[href]').attr('href'); 72 cpln_set_displayed_url(url); 73 cpln_open_notice(); 74 if(document.querySelector('.cpln-redirect-box__time')){ 75 cpln_auto_redirect(document.querySelector('.cpln-redirect-box__time'), url); 76 } 77 }); 78 79 // CLOSE POP UP WHEN OPENING THE NEW PAGE 80 $(document.body).on('click', '.cpln-redirect-url', function(){ 81 cpln_close_notice(); 82 }); 83 84 // CANCEL BUTTON AND ESC TO CLOSE POPUP 85 $('.cpln-cancel').click(function(e){ 86 cpln_close_notice(); 87 e.preventDefault(); 88 cpln_stop_redirect(); 89 }); 90 $(document).keyup(function(e){ 91 if(e.keyCode === 27) { 92 cpln_close_notice(); 93 cpln_stop_redirect(); 94 } 95 }); 96});
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.