PageSourceSearch

https://kostum66.ru/design/kostum66_1/js/project.js

js kostum66.ru collected 2026-09-28 14:00:14 UTC 3,473 bytes, 80 lines download raw bytes

1// Звёздный рейтинг товаров
2$.fn.rater = function (options) {
3    var opts = $.extend({}, $.fn.rater.defaults, options);
4    return this.each(function () {
5        var $this = $(this);
6        var $on = $this.find('.rater-starsOn');
7        var $off = $this.find('.rater-starsOff');
8        opts.size = $on.height();
9        if (opts.rating == undefined) opts.rating = $on.width() / opts.size;
10        if (opts.id == undefined) opts.id = $this.attr('id');
11
12        $off.mousemove(function (e) {
13            var left = e.clientX - $off.offset().left;
14            var width = $off.width() - ($off.width() - left);
15            width = Math.ceil(width / (opts.size / opts.step)) * opts.size / opts.step;
16            $on.width(width);
17        }).hover(function (e) { $on.addClass('rater-starsHover'); }, function (e) {
18            $on.removeClass('rater-starsHover'); $on.width(opts.rating * opts.size);
19        }).click(function (e) {
20            var r = Math.round($on.width() / $off.width() * (opts.units * opts.step)) / opts.step;
21            $off.unbind('click').unbind('mousemove').unbind('mouseenter').unbind('mouseleave');
22            $off.css('cursor', 'default'); $on.css('cursor', 'default');
23            $.fn.rater.rate($this, opts, r);
24        }).css('cursor', 'pointer'); $on.css('cursor', 'pointer');
25    });
26};
27
28$.fn.rater.defaults = {
29    postHref: location.href,
30    units: 5,
31    step: 1
32};
33
34$.fn.rater.rate = function ($this, opts, rating) {
35    var $on = $this.find('.rater-starsOn');
36    var $off = $this.find('.rater-starsOff');
37    $off.fadeTo(600, 0.4, function () {
38        $.ajax({
39            url: opts.postHref,
40            type: "POST",
41            data: 'id=' + opts.id + '&rating=' + rating,
42            complete: function (req) {
43                if (req.status == 200) { //success
44                    opts.rating = parseFloat(req.responseText);
45
46                    if (opts.rating > 0) {
47                        opts.rating = parseFloat(req.responseText);
48                        $off.fadeTo(200, 0.1, function () {
49                            $on.removeClass('rater-starsHover').width(opts.rating * opts.size);
50                            var $count = $this.find('.rater-rateCount');
51                            $count.text(parseInt($count.text()) + 1);
52                            $this.find('.rater-rating').text(opts.rating.toFixed(1));
53                            $off.fadeTo(200, 1);
54                        });
55                        //alert('Спасибо! Ваш голос учтен.');
56                    }
57                    else
58					if (opts.rating == -1) {
59						$off.fadeTo(200, 0.6, function () {
60                            $this.find('.test-text').text('Вы уже голосовали!');
61                        });
62						//alert('Вы уже голосовали за данный товар!');
63					}
64                    else {
65						$off.fadeTo(200, 0.6, function () {
66                            $this.find('.test-text').text('Вы уже голосовали!');
67                        });
68						//alert('Вы уже голосовали за данный товар!');
69					}
70                } else { //failure
71                    alert(req.responseText);
72                    $on.removeClass('rater-starsHover').width(opts.rating * opts.size);
73                    $this.rater(opts);
74                    $off.fadeTo(2200, 1);
75                }
76            }
77        });
78    });
79};
80// end

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.