1(function ($) { 2 $.fn.jsRapStar = function (options) { 3 4 return this.each(function () { 5 let value = $(this).attr('value'); 6 let color = $(this).attr('color'); 7 value = value === undefined ? 0 : parseFloat(value); 8 color = color === undefined ? 'yellow' : color; 9 this.opt = $.extend({ 10 star: '★', 11 colorFront: color, 12 colorBack: 'white', 13 enabled: true, 14 step: true, 15 starHeight: 32, 16 length: 6, 17 value: value, 18 onClick: null, 19 onMousemove: null 20 }, options); 21 let starH = Array(this.opt.length + 1).join('<span>' + this.opt.star + '</span>'); 22 $(this).empty().addClass('rapStar').css({ color: this.opt.colorBack, 'font-size': this.opt.starHeight + 'px' }).html(starH); 23 let widthSingle = $(this).width() / this.opt.length; 24 let widthValue = this.opt.value * widthSingle; 25 let widthCurrent = widthValue; 26 this.StarF = $('<div>').addClass('rapStarFront').css({ color: this.opt.colorFront }).html(starH).width(widthValue).appendTo(this); 27 if (this.opt.enabled) { 28 $(this).bind({ 29 mousemove: function (e) { 30 widthSingle = $(this).width() / this.opt.length; 31 widthCurrent = e.clientX - this.getBoundingClientRect().left; 32 if (this.opt.step) 33 widthCurrent = Math.floor(widthCurrent / widthSingle + 1) * widthSingle; 34 this.StarF.width(widthCurrent); 35 if (this.opt.onMousemove) 36 this.opt.onMousemove.call(this, widthCurrent / widthSingle); 37 }, 38 mouseleave: function (e) { 39 this.StarF.animate({ width: widthValue }); 40 }, 41 click: function (e) { 42 widthValue = widthCurrent; 43 this.opt.value = widthValue / widthSingle; 44 if (this.opt.onClick) 45 this.opt.onClick.call(this, this.opt.value); 46 } 47 }); 48 } else 49 $(this).addClass('rapStarDisable'); 50 }) 51 } 52})(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.