1function thumbs_rating_vote(obj, ID, type, likeLabel) 2{ 3 // For the LocalStorage 4 5 var itemName = "thumbsrating" + ID; 6 7 var container = '#thumbs-rating-' + ID; 8 9 // Check if the LocalStorage value exist. If do nothing. 10 localStorage.setItem(itemName, true); 11 12 var currentSelection = jQuery(obj); 13 var selection; 14 var alternate; 15 16 if(type == 1){ 17 var oldTypeItemName = "thumbsrating" + ID + "-2"; 18 var newTypeItemName = "thumbsrating" + ID + "-1"; 19 } else if (type == 2){ 20 var oldTypeItemName = "thumbsrating" + ID + "-1"; 21 var newTypeItemName = "thumbsrating" + ID + "-2"; 22 } 23 24 if(currentSelection.parent().hasClass("lb-voted")){ 25 selection = 0; 26 localStorage.removeItem(oldTypeItemName, false); 27 localStorage.setItem(newTypeItemName, false); 28 } else{ 29 selection = 1; 30 localStorage.removeItem(oldTypeItemName, false); 31 localStorage.setItem(newTypeItemName, true); 32 } 33 34 35 if(currentSelection.parent().hasClass("thumbs-rating-up")){ 36 if(currentSelection.parent().parent().find('.thumbs-rating-down.lb-voted').length > 0){ 37 alternate = 1; 38 } 39 40 } else if(currentSelection.parent().hasClass("thumbs-rating-down")){ 41 if(currentSelection.parent().parent().find('.thumbs-rating-up.lb-voted').length > 0){ 42 alternate = 1; 43 } 44 } 45 46 var data = { 47 action: 'thumbs_rating_add_vote', 48 postid: ID, 49 type: type, 50 selection: selection, 51 alternate : alternate, 52 likelabel : likeLabel, 53 nonce: thumbs_rating_ajax.nonce 54 }; 55 56 jQuery.post(thumbs_rating_ajax.ajax_url, data, function(response) { 57 58 var object = jQuery(container); 59 60 jQuery(container).html(''); 61 62 jQuery(container).append(response); 63 64 // Remove the class and ID so we don't have 2 DIVs with the same ID 65 66 //jQuery(object).removeClass('thumbs-rating-container'); 67 //jQuery(object).attr('id', ''); 68 69 // Add the class to the clicked element 70 71 var new_container = '#thumbs-rating-' + ID; 72 73 // Check the type 74 75 if( type == 1){ 76 thumbs_rating_class = ".thumbs-rating-up"; 77 } 78 else{ 79 thumbs_rating_class = ".thumbs-rating-down"; 80 } 81 82 if (selection == 1){ 83 jQuery(new_container + ' ' + thumbs_rating_class ).addClass('thumbs-rating-voted lb-voted'); 84 } 85 86 }); 87} 88 89
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.