1function createCookie(name, value, minutes) { 2 if (minutes) { 3 var date = new Date(); 4 date.setTime(date.getTime() + minutes * 60 * 1000); 5 var expires = "; expires=" + date.toGMTString(); 6 } else { 7 var expires = ""; 8 } 9 document.cookie = name + "=" + value + expires + "; path=/"; 10} 11 12function getCookie(c_name) { 13 var c_value = document.cookie, 14 c_start = c_value.indexOf(" " + c_name + "="); 15 if (c_start == -1) c_start = c_value.indexOf(c_name + "="); 16 if (c_start == -1) { 17 c_value = null; 18 } else { 19 c_start = c_value.indexOf("=", c_start) + 1; 20 var c_end = c_value.indexOf(";", c_start); 21 if (c_end == -1) { 22 c_end = c_value.length; 23 } 24 c_value = unescape(c_value.substring(c_start, c_end)); 25 } 26 return c_value; 27} 28 29(function ($) { 30 "use strict"; 31 // YouTube has disabled live chat on mobile devices, so hide it if the user agent reports a mobile device 32 $(document).ready(function () { 33 /* YouTube has completely disabled chat for now, so save this for later 34 if ( 35 /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test( 36 navigator.userAgent 37 ) 38 ) { 39 $(".wp-block-embed-youtube-chat").hide(); 40 } 41 */ 42 43 // Only run if notifications are enabled. 44 if (wpls.notification_enable) { 45 wpls_check(); 46 } 47 function wpls_check() { 48 // REST API - Notification - Step #4 - Call our REST API and show/hide the notification based on the response 49 $.ajax({ 50 method: "GET", 51 url: wpls.restURL + "wplivestream/v1/notification", 52 data: { 53 post: wpls.postID, //pass the post ID to our notification endpoint 54 }, 55 beforeSend: function (xhr) { 56 // Here we set a header 'X-WP-Nonce' with the nonce as opposed to the nonce in the data object with admin-ajax 57 xhr.setRequestHeader("X-WP-Nonce", wpls.restNonce); 58 }, 59 success: function (response) { 60 //console.log("here it is:" + response + "end"); 61 var wpls_cookie_dismiss = getCookie("wpls-notification"); 62 63 if ( 64 response !== "" && 65 jQuery("figure.wpls").length === 0 &&
66 !wpls_cookie_dismiss 67 ) { 68 if (jQuery("#wpls-notification").length === 0) { 69 // code to run if it isn't there 70 jQuery("#wpls-notification-wrapper").html(response); 71 } else { 72 // code to run if it is there 73 jQuery("#wpls-notification").show(); 74 } 75 } else { 76 // hide the notification 77 jQuery("#wpls-notification").hide(); 78 } 79 }, 80 fail: function (response) { 81 console.log(response); 82 }, 83 }).then(function () { 84 // Get user defined frequency interval 85 var optionFrequency = wpls.frequency; 86 if ( 87 typeof optionFrequency === "undefined" || 88 optionFrequency === null || 89 optionFrequency === "" 90 ) { 91 var frequency = 60000; // default to 1 minute (60000 ms) 92 } else { 93 var frequency = parseInt(optionFrequency) * 1000; // format user input as milliseconds 94 } 95 // on completion, restart 96 setTimeout(wpls_check, frequency); // function refers to itself 97 }); 98 } 99 100 // Don't show live notification for 10 minutes if the user has clicked the X on the notification 101 $("#wpls-notification-wrapper").on( 102 "click", 103 "#wpls-hide-notification", 104 function () { 105 createCookie("wpls-notification", "dismissed", 10); 106 } 107 ); 108 }); 109})(jQuery);
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.