1function cld_setCookie(cname, cvalue, exdays) { 2 var d = new Date(); 3 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 4 var expires = "expires=" + d.toUTCString(); 5 document.cookie = cname + "=" + cvalue + "; " + expires; 6} 7 8function cld_getCookie(cname) { 9 var name = cname + "="; 10 var ca = document.cookie.split(';'); 11 for (var i = 0; i < ca.length; i++) { 12 var c = ca[i]; 13 while (c.charAt(0) == ' ') { 14 c = c.substring(1); 15 } 16 if (c.indexOf(name) == 0) { 17 return c.substring(name.length, c.length); 18 } 19 } 20 return ""; 21} 22 23jQuery(document).ready(function ($) { 24 var ajax_flag = 0; 25 $('body').on('click', '.cld-like-dislike-trigger', function () { 26 if (ajax_flag == 0) { 27 var comment_id = $(this).data('comment-id'); 28 var trigger_type = $(this).data('trigger-type'); 29 var selector = $(this); 30 var cld_cookie = cld_getCookie('cld_' + comment_id); 31 var current_count = selector.closest('.cld-common-wrap').find('.cld-count-wrap').html(); 32 var new_count = parseInt(current_count) + 1; 33 34 if (cld_cookie == '') { 35 $.ajax({ 36 type: 'post', 37 url: cld_js_object.admin_ajax_url, 38 data: { 39 comment_id: comment_id, 40 action: 'cld_comment_ajax_action', 41 type: trigger_type, 42 _wpnonce: cld_js_object.admin_ajax_nonce, 43 }, 44 beforeSend: function (xhr) { 45 ajax_flag = 1; 46 selector.closest('.cld-common-wrap').find('.cld-count-wrap').html(new_count); 47 }, 48 success: function (res) { 49 ajax_flag = 0; 50 res = $.parseJSON(res); 51 if (res.success) { 52 var cookie_name = 'cld_' + comment_id; 53 cld_setCookie(cookie_name, 1, 365); 54 var latest_count = res.latest_count; 55 selector.closest('.cld-common-wrap').find('.cld-count-wrap').html(latest_count); 56 } 57 } 58 59 }); 60 } 61 } 62 }); 63 64 $('.cld-facebook').click(function () { 65 var url = $(this).data('share-url'); 66 var share_text = $(this).data('share-text'); 67 68 FB.ui({ 69 method: 'share', 70 display: 'popup', 71 href: url, 72 quote: share_text 73 }, function (response) { 74 }); 75 }); 76 77 78});
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.