PageSourceSearch

https://www.led-schuhe.click/wp-content/plugins/yet-another-stars-rating/js/yasr-front.js?ver=2.2.1

js led-schuhe.click collected 2026-10-07 05:21:53 UTC 9,858 bytes, 346 lines download raw bytes

1
2/*** Constant used by yasr
3
4yasrCommonData (postid, ajaxurl, loggedUser, visitorStatsEnabled, loaderHtml, tooltipValues')
5
6yasrMultiSetData (setType, nonce)
7
8
9***/
10
11
12/****** Do this actions on document load ******/
13document.addEventListener('DOMContentLoaded', function(event) {
14
15    //At pageload, check if there is some shortcode with class yasr-rater-stars
16    var yasrRaterInDom = document.getElementsByClassName('yasr-rater-stars');
17    //If so, call the function to set the rating
18    if (yasrRaterInDom.length > 0) {
19
20        //load this on everypageload
21        yasrSetRatingOnLoad(yasrRaterInDom);
22
23    }
24
25    //check if shortcode yasr_visitor_votes is used
26    var yasrRaterVVInDom = document.getElementsByClassName('yasr-rater-stars-visitor-votes');
27
28    if (yasrRaterVVInDom.length > 0) {
29        yasrVisitorVotesFront(yasrRaterVVInDom);
30    }
31
32    var yasrMultiSetVisitorInDom = document.getElementsByClassName('yasr-multiset-visitors-rater');
33
34    if (yasrMultiSetVisitorInDom.length > 0) {
35        yasrRaterVisitorsMultiSet(yasrMultiSetVisitorInDom)
36    }
37
38
39    //Check to draw tooltips
40    if (yasrRaterVVInDom) {
41
42        if (yasrCommonData.visitorStatsEnabled === 'yes') {
43
44            var yasrStatsInDom = document.getElementsByClassName('yasr-dashicons-visitor-stats');
45
46            if (yasrStatsInDom) {
47                yasrDrawTipsProgress (yasrStatsInDom);
48            }
49
50        }
51
52    }
53
54    if (typeof yasrMostHighestRanking !== 'undefined') {
55
56        //By default, hide the highest rated chart
57        document.getElementById('yasr-highest-rated-posts').style.display = 'none';
58
59    }
60
61});
62
63
64//This work on top10 ranking chart, show the highest rated and hide most rated
65function yasrShowHighest () {
66
67    document.getElementById('yasr-most-rated-posts').style.display = 'none';
68    document.getElementById('yasr-highest-rated-posts').style.display = '';
69
70}
71
72//Vice versa
73function yasrShowMost () {
74
75    document.getElementById('yasr-highest-rated-posts').style.display = 'none';
76    document.getElementById('yasr-most-rated-posts').style.display = '';
77
78}
79
80
81/****** End Yasr shortcode page  ******/
82
83
84/****** Tooltip function ******/
85
86//used in shortcode page and ajax page
87function yasrDrawTipsProgress (yasrStatsInDom) {
88
89    //htmlcheckid declared false
90    var htmlIdChecked = false;
91
92    for (var i = 0; i < yasrStatsInDom.length; i++) {
93
94        (function (i) {
95
96            var htmlId = '#'+yasrStatsInDom.item(i).id;
97            var postId = yasrStatsInDom.item(i).getAttribute('data-postid');
98
99            var data = {
100                action: 'yasr_stats_visitors_votes',
101                post_id: postId
102            };
103
104            //Convert in a string
105            //var dataToSend = jsObject_to_URLEncoded(data);
106
107            var initialContent = '<span style="color: #0a0a0a">Loading...</span>';
108
109            tippy(htmlId, {
110                content: initialContent,
111                theme: 'yasr',
112                arrow: 'true',
113                arrowType: 'round',
114
115                //When support for IE will be dropped out, this will become onShow(tip)
116                onShow: function onShow(tip) {
117
118                    if (htmlId !== htmlIdChecked) {
119
120                        jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
121                            response = JSON.parse(response);
122                            tip.setContent(response);
123
124                        });
125                    }
126
127                },
128                onHidden: function onHidden() {
129                    htmlIdChecked = htmlId;
130                }
131
132            });
133
134         })(i);
135
136    }
137
138}
139
140
141
142/****** End tooltipfunction ******/
143
144
145/****  ****/
146
147//this is the function that print the overall rating shortcode, get overall rating and starsize
148function yasrSetRaterValue (starSize, htmlId) {
149
150    //convert to be a number
151    starSize = parseInt(starSize);
152
153    raterJs({
154        starSize: starSize,
155        step: 0.1,
156        showToolTip: false,
157        readOnly: true,
158        element: document.getElementById(htmlId),
159    });
160
161}
162
163function yasrSetRatingOnLoad (yasrRatingsInDom) {
164
165    //Check in the object
166    for (var i = 0; i < yasrRatingsInDom.length; i++) {
167
168        var htmlId = yasrRatingsInDom.item(i).id;
169        var starSize = yasrRatingsInDom.item(i).getAttribute('data-rater-starsize');
170
171        yasrSetRaterValue(starSize, htmlId);
172
173    }
174
175}
176
177function yasrVisitorVotesFront (yasrRaterVVInDom) {
178
179    //Check in the object
180    for (var i = 0; i < yasrRaterVVInDom.length; i++) {
181
182        (function(i) {
183
184            var postId = yasrRaterVVInDom.item(i).getAttribute('data-rater-postid');
185            var htmlId = yasrRaterVVInDom.item(i).id;
186            var uniqueId = htmlId.replace('yasr-visitor-votes-rater-', '');
187            var starSize = parseInt(yasrRaterVVInDom.item(i).getAttribute('data-rater-starsize'));
188            var readonly = yasrRaterVVInDom.item(i).getAttribute('data-rater-readonly');
189            var nonce = yasrRaterVVInDom.item(i).getAttribute('data-rater-nonce');
190            var isSingular = yasrRaterVVInDom.item(i).getAttribute('data-issingular');
191
192            //Convert string to boolean
193            readonly = yasrTrueFalseStringConvertion(readonly);
194            isSingular = yasrTrueFalseStringConvertion (isSingular);
195
196            raterJs({
197                starSize: starSize,
198                step: 1,
199                showToolTip: false,
200                readOnly: readonly,
201                element: document.getElementById(htmlId),
202
203                rateCallback: function rateCallback(rating, done) {
204
205                    //show the loader
206                    document.getElementById('yasr-visitor-votes-container-after-stars-' + uniqueId).innerHTML = yasrCommonData.loaderHtml;
207
208                    //Just leave 1 number after the .
209                    rating = rating.toFixed(1);
210                    //Be sure is a number and not a string
211                    rating = parseFloat(rating);
212
213                    //Creating an object with data to send
214                    var data = {
215                        action: 'yasr_send_visitor_rating',
216                        rating: rating,
217                        post_id: postId,
218                        nonce_visitor: nonce,
219                        is_singular : isSingular
220                    };
221
222                    this.setRating(rating);
223                    this.disable();
224
225                    //Send value to the Server
226                    jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
227                        //decode json
228                        response = JSON.parse(response);
229                        document.getElementById('yasr-visitor-votes-container-after-stars-' + uniqueId).innerHTML = response;
230
231                    });
232
233                    done();
234
235                }
236
237            });
238
239        })(i);
240
241    }//End for
242
243}
244
245function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
246
247    //will have field id and vote
248    var ratingObject = "";
249
250    //an array with all the ratings objects
251    var ratingArray = [];
252
253    //Check in the object
254    for (var i = 0; i < yasrMultiSetVisitorInDom.length; i++) {
255
256        (function (i) {
257
258            var htmlId = yasrMultiSetVisitorInDom.item(i).id;
259            var readonly = yasrMultiSetVisitorInDom.item(i).getAttribute('data-rater-readonly');
260
261            readonly = yasrTrueFalseStringConvertion(readonly);
262
263            var elem = document.querySelector("#" + htmlId);
264            raterJs({
265                starSize: 16,
266                step: 1,
267                showToolTip: false,
268                readOnly: readonly,
269                element: elem,
270
271                rateCallback: function rateCallback(rating, done) {
272
273                    var postId = elem.getAttribute('data-rater-postid');
274                    var setId = elem.getAttribute('data-rater-setid');
275                    var setIdField = elem.getAttribute('data-rater-set-field-id');
276
277                    //Just leave 1 number after the .
278                    rating = rating.toFixed(1);
279                    //Be sure is a number and not a string
280                    var vote = parseInt(rating);
281
282                    this.setRating(vote); //set the new rating
283
284                    ratingObject = {
285                        postid: postId,
286                        setid: setId,
287                        field: setIdField,
288                        rating: vote
289                    };
290
291                    //creating rating array
292                    ratingArray.push(ratingObject);
293
294                    done();
295
296                }
297
298            });
299
300        })(i);
301
302    }
303
304    jQuery('.yasr-send-visitor-multiset').on('click', function() {
305
306        var multiSetPostId = this.getAttribute('data-postid');
307        var multiSetId = this.getAttribute('data-setid');
308
309        jQuery('#yasr-send-visitor-multiset-'+multiSetPostId+'-'+multiSetId).hide();
310        jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).show();
311
312        var data = {
313            action: 'yasr_visitor_multiset_field_vote',
314            nonce: yasrMultiSetData.nonceVisitor,
315            post_id: multiSetPostId,
316            rating: ratingArray,
317            set_type: multiSetId
318        };
319
320        //Send value to the Server
321        jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
322            jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).text(response);
323        });
324
325    });
326    
327} //End function
328
329
330function yasrTrueFalseStringConvertion(string) {
331
332    if (typeof string === 'undefined' || string === null || string === '') {
333        string = true;
334    }
335
336    //Convert string to boolean
337    if (string === 'true' || string === '1') {
338        string = true;
339    }
340    if (string === 'false' || string === '0') {
341        string = false;
342    }
343
344    return string;
345
346}

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.