PageSourceSearch

https://www.lvretc.com/javascripts/jquery-star-rating.js?1786078244

js lvretc.com collected 2026-10-06 07:27:48 UTC 2,157 bytes, 74 lines download raw bytes

1(function( $ ) {
2  $.fn.setRatingManual = function(options) {
3    var obj = this;
4    var settings = $.extend({
5      max : 5,
6      half : true,
7      fieldName : 'rating',
8      fieldId : 'rating'
9    }, options );
10    this.settings = settings;
11
12    // add click on stars
13    for(var i = 1 ; i <= settings.max ; i++) {
14      var star = $(this).find('input').eq(i).data('rating', i).click(
15        function(){
16          $('#'+obj.settings.fieldId).val($(this).data('rating'));
17        }
18      ) 
19    }    
20    $(this).append('<input type="hidden" name="'+settings.fieldName+'" id="'+settings.fieldId+'" />');
21
22    // Check initial rating star
23    $(this).find('input:checked').prop('checked', false);
24    $(this).find('input#star' + $(this).data().rating).prop('checked', true);
25  }
26
27  $.fn.addRatingStatic = function(numRating) {
28    var obj = this;
29    var settings = $.extend({
30      max : 5,
31      half : true,
32      icon : 'starOutline',
33      icon_half : 'starHalf'
34    });
35    this.settings = settings;
36
37    // create the stars
38    for(var i = 1 ; i <= settings.max ; i++) {
39      var star = $('<i/>').addClass(this.settings.icon).addClass('icnColor').data('rating', i).appendTo(this);
40    }
41    this.showRating(numRating,true);
42  };
43
44  $.fn.setRating = function(numRating) {
45    var obj = this;
46    $('#'+obj.settings.fieldId).val(numRating);
47    obj.showRating(numRating, true);
48  };
49
50  $.fn.showRating = function(numRating, force) {
51    var obj = this;
52    if($('#'+obj.settings.fieldId).val() == '' || force)
53    {
54      var half = false;
55      if(numRating % 1 !== 0 ){
56        numRating = Math.floor(numRating) + 1;
57        half = true;
58      }
59      $(obj).find('i').each(function(){
60        var icon = obj.settings.icon;
61        if($(this).data('rating') <= numRating) {
62          if(half && (numRating == $(this).data('rating'))){
63            $(this).addClass(obj.settings.icon_half).removeClass(obj.settings.icon);
64            icon = obj.settings.icon_half;
65          }else{
66            icon = obj.settings.icon;
67            $(this).addClass('star').removeClass(obj.settings.icon);
68          }
69        }
70      });
71    }
72  };
73
74}( 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.