1jQuery.fn.extend({ 2 rating: function(options){ 3 if(typeof(options)=='undefined') options={}; 4 var ratings=[]; 5 objs=this; 6 if(objs.length){ 7 for(var i=0;i<objs.length;i++){ 8 ratings.push(new simpleRating(options,objs[i])); 9 } 10 } 11 }, 12}); 13 14class simpleRating { 15 constructor(options,obj) { 16 this.obj=obj; 17 this.options=options; 18 this.rating=0; 19 this.init(); 20 } 21 22 init(){ 23 var html='<div class="simple-rating star-rating">'; 24 for(var i=0;i<5;i++){html+='<i class="icon-star" data-rating="'+(i+1)+'"></i>';} 25 html+='</div>'; 26 27 $(this.obj) 28 .attr('type','hidden') 29 .after(html); 30 31 if ($(this.obj).attr('value')) { 32 this.rating = $(this.obj).attr('value'); 33 this.setstars($(this.obj).attr('value')); 34 } 35 36 $(this.obj).next().children().click({classObj:this},function(e){ 37 e.data.classObj.rate(this); 38 }); 39 40 $(this.obj).next().children().mouseenter({classObj:this},function(e){ 41 e.data.classObj.setstars($(this).data('rating')); 42 }); 43 44 $(this.obj).next().children().mouseleave({classObj:this},function(e){ 45 e.data.classObj.setstars(e.data.classObj.rating); 46 }); 47 } 48 49 rate(obj){ 50 var rating=$(obj).data('rating'); 51 $(obj).parent().prev().val(rating); 52 this.rating=rating; 53 this.refresh(); 54 } 55 56 refresh(){ 57 this.setstars(this.rating); 58 } 59 60 setstars(rating){ 61 var stars=$(this.obj).next().children(); 62 for(var i=0;i<5;i++){ 63 var starObj=$(this.obj).next().children()[i]; 64 if(i<rating){ 65 $(starObj).removeClass('o'); 66 }else{ 67 $(starObj).addClass('o'); 68 } 69 } 70 } 71}
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.