PageSourceSearch

https://seekinglavenderlane.com/wp-content/plugins/commentluv/js/commentluv.js?ver=4

js seekinglavenderlane.com collected 2026-10-03 22:11:38 UTC 13,836 bytes, 360 lines download raw bytes

1// commentluv 2.94.8
2jQuery(document).ready(function () {
3    // get the form object and fields
4    var formObj = jQuery('#cl_post_title').parents('form');
5    var urlObj = cl_settings['urlObj'] = jQuery("input[name='" + cl_settings['url'] + "']", formObj);
6    var comObj = cl_settings['comObj'] = jQuery("textarea[name='" + cl_settings['comment'] + "']", formObj);
7    var autObj = jQuery("input[name='" + cl_settings['name'] + "']", formObj);
8    var emaObj = jQuery("input[name='" + cl_settings['email'] + "']", formObj);
9    // setup localized object with temporary vars
10    cl_settings['url_value'] = urlObj.val();
11    cl_settings['fired'] = 'no';
12
13    // set event listener for textarea focus
14    comObj.focus(cl_dostuff);
15
16    // set event listener for url blur
17    urlObj.blur(cl_dostuff);
18
19    // set the event listener for the click of the checkbox
20    jQuery('#doluv').click(function () {
21        jQuery('#lastposts').hide();
22        if (jQuery(this).is(":checked")) {
23            // was unchecked, now is checked
24            jQuery('#mylastpost').fadeTo("fast", 1);
25            cl_settings['fired'] = 'no';
26            cl_dostuff();
27        } else {
28            // was checked, user unchecked it so empty hidden fields in form
29            jQuery('input[name="cl_post_title"]').val("");
30            jQuery('input[name="cl_post_url"]').val("");
31            jQuery('#mylastpost').fadeTo("slow", 0.3);
32            jQuery('#lastposts').empty();
33        }
34    });
35    // click event for last blog post link
36    jQuery('.cluv a').click(function () {
37        var data = jQuery(this).attr('class').split(' ');
38        // store click count
39        cl_try_ajax({
40            type: 'POST',
41            data: {
42                'action': 'cl_ajax',
43                'cid': data[1],
44                '_ajax_nonce': data[0],
45                'cl_prem': jQuery(this).hasClass('p'),
46                'url': jQuery(this).attr('href'),
47                'do': 'click'
48            }
49        });
50        jQuery(this).attr('target', '_blank');
51        return true;
52    });
53    // hover event on heart
54    if (cl_settings['infopanel'] == "on") {
55        jQuery('.heart_tip_box').mouseenter(heart_big);
56    }
57    // hide/show showmore
58    jQuery(document.body).click(function () {
59        if (cl_settings['lastposts'] == 'showing') {
60            jQuery('#lastposts').slideUp('', function () {
61                cl_settings['lastposts'] = 'not'
62            });
63        }
64    });
65    jQuery('#showmorespan img').click(function () {
66        if (cl_settings['lastposts'] == 'not') {
67            jQuery('#lastposts').slideDown('', function () {
68                cl_settings['lastposts'] = 'showing'
69            });
70        }
71    });
72    // clear hidden inputs on load
73    jQuery('#cl_post_title,#cl_post_url,#cl_prem').val('');
74    // set click on anywhere closes info box 
75    jQuery(document).click(heart_small);
76    // add info panel to page
77    jQuery("body").append('<span id="heart_tip_big" style="display: none;position:absolute; z-index: 1001; background-color: ' + cl_settings['infoback'] + '; color: ' + cl_settings['infotext'] + '; width: 62px;"></span>');
78
79    // hover over to see raw file wrapper open
80    jQuery('#commentluv').on('mouseover', '.rawfilewrap', function () {
81        jQuery('.rawfile').show();
82    });
83
84    jQuery('#commentluv').on('mouseout', '.rawfilewrap', function () {
85        jQuery('.rawfile').hide();
86    });
87});
88
89/**
90 * checks everything is in place for doing stuff
91 * returns string 'ok' if, um, ok
92 */
93function cl_docheck() {
94    // checkbox check
95    if (!jQuery('#doluv').is(':checked')) {
96        return 'not checked';
97    }
98    var url = cl_settings['urlObj'];
99    var msg = jQuery('#cl_messages');
100    msg.hide();
101    url.removeClass('cl_error');
102    // logged in user?
103    var nourlmessage = cl_settings['no_url_message'];
104    if (cl_settings['logged_in'] == '1') {
105        nourlmessage = cl_settings['no_url_logged_in_message'];
106    } else {
107        // check if fb connect is active
108        if (!cl_settings['urlObj'].is(':visible') && typeof FB != 'undefined') {
109            var invisurl = cl_settings['urlObj'].remove();
110            var invismsg = msg.remove();
111            cl_settings['comObj'].after('<br><span id="invisurl">').after(invismsg);
112            jQuery('#invisurl').append('URL ').after(invisurl).append('</span>');
113        }
114
115    }
116    // check that there is a value in the url field
117    if (url.val().length > 1) {
118        var urlLower = url.val().toLowerCase();
119
120        // is value just http:// ?
121        if (urlLower == 'http://' || urlLower == 'https://') {
122            url.addClass('cl_error');
123            cl_message(nourlmessage);
124            return;
125        }
126        // is the http:// missing?
127        if (urlLower.substring(0, 7) != 'http://' && urlLower.substring(0, 8) != 'https://') {
128            url.addClass('cl_error');
129            cl_message(cl_settings['no_http_message']);
130            return;
131        }
132    } else {
133        // there is no value
134        url.addClass('cl_error');
135        cl_message(nourlmessage);
136        return;
137    }
138    // if we are here, all is cool mon
139    return 'ok';
140}
141
142/**
143 * tries various methods to get request through to admin-ajax url
144 */
145function cl_try_ajax(args) {
146    args.origError = args.origError || args.error || function () {
147    };
148
149    args.lastError = args.lastError || undefined;
150    args.url = args.url || cl_settings['api_url'];
151    if (window.location.protocol === 'https:' && args.url.indexOf('http:') === 0) {
152        // we were trying to ajax http://, but our current window is https://, so backend would likely also be https://
153        // an https to http ajax request is impossible based on CORS spec
154        args.url = args.url.replace(/^http:/, 'https:');
155    }
156
157    if (args.lastError !== undefined && args.url === args.lastUrl) {
158        return args.origError(args.lastError.x, args.lastError.e);
159    }
160
161    args.error = function (x, e) {
162        args.lastError = {x: x, e: e};
163        args.lastUrl = args.url;
164        args.url = cl_settings['api_url_alt'] || cl_settings['api_url'];
165
166        // try again
167        cl_try_ajax(args);
168    };
169
170    return jQuery.ajax(args);
171};
172
173/**
174 * tries to fetch last blog posts for a url
175 */
176function cl_dostuff() {
177    if (cl_docheck() != 'ok') {
178        return;
179    }
180
181    var msg = jQuery('#cl_messages');
182
183    var url = cl_settings['urlObj'];
184    if (cl_settings['fired'] == 'yes') {
185        // already fired, fire again if current url is different to last fired
186        if (url.val() == cl_settings['url_value']) {
187            msg.show();
188            return;
189        }
190        jQuery('#lastposts,#mylastpost').empty();
191    }
192
193    // fire the request to admin
194    msg.append('<img src="' + cl_settings['images'] + 'loader.gif' + '"/>').show();
195
196    cl_try_ajax({
197        type: 'post',
198        dataType: 'json',
199        data: {'url': url.val(), 'action': 'cl_ajax', 'do': 'fetch', '_ajax_nonce': cl_settings._fetch},
200        success: function (data) {
201            if (data.error == '') {
202                // no error, fill up lastposts div with items returned
203                msg.empty().hide();
204                jQuery.each(data.items, function (j, item) {
205                    var title = item.title;
206                    var link = item.link;
207                    var count = '';
208                    jQuery('#lastposts').append('<span id="' + item.link + '" class="choosepost ' + item.type + '">' + title + '</span>');
209                });
210                // setup first link and hidden fields
211                jQuery('#mylastpost').html('<a target="_blank" title="Click to visit this page (new window)" href="' + data.items[0].link + '"> ' + data.items[0]['title'] + '</a>').fadeIn(1000);
212                jQuery('#cl_post_title').val(data.items[0].title);
213                jQuery('#cl_post_url').val(data.items[0].link);
214                jQuery('#cl_prem').val(data.items[0].p);
215                // setup look and show dropdown
216                jQuery('span.message').css({'backgroundColor': '#efefef', 'color': 'black'});
217                jQuery('#showmorespan img').show();
218                if (cl_settings['comObj'].width() > jQuery('#commentluv').width()) {
219                    var dropdownwidth = jQuery('#commentluv').width();
220                } else {
221                    var dropdownwidth = jQuery(cl_settings['comObj']).width();
222                }
223                jQuery('#lastposts').css('width', dropdownwidth).slideDown('', function () {
224                    cl_settings['lastposts'] = 'showing'
225                });
226                // bind click action
227                jQuery('.choosepost:not(.message)').click(function () {
228                    jQuery('#cl_post_title').val(jQuery(this).text());
229                    jQuery('#cl_post_url').val(jQuery(this).attr('id'));
230                    jQuery('#mylastpost').html('<a href="' + jQuery(this).attr('id') + '"> ' + jQuery(this).text() + '</a>').fadeIn(1000);
231                });
232            } else {
233                if (typeof(data.rawfile) == 'undefined') {
234                    data.rawfile = 'no raw data sent back';
235                }
236                cl_message(data.error, data.rawfile);
237            }
238        },
239        error: function (x, e) {
240            msg.find('img').remove();
241
242            if (x.status == 0) {
243                if (cl_settings['api_url'].indexOf('https') == 0) {
244                    cl_message('This blog has set the api url to use https, the commentluv technical settings need to be changed for the API url to use http');
245                } else {
246                    cl_message('It appears that you are offline or another error occured contacting the API url, have you set it to use www or missed the www off the api url?? check the technical settings and add or remove www from the api url.');
247                }
248
249            } else if (x.status == 404) {
250                cl_message('API URL not found.');
251            } else if (x.status == 500) {
252                cl_message('Internal Server Error.' + x.responseText);
253            } else if (e == 'parsererror') {
254                cl_message('Error.\nParsing JSON Request failed.' + x.responseText);
255            } else if (e == 'timeout') {
256                cl_message('Request Time out.');
257            } else {
258                cl_message('Unknown Error. ' + x.statusText + ' ' + x.responseText);
259            }
260        }
261    });
262
263    // save what url used and that we checked already
264    cl_settings['fired'] = 'yes';
265    cl_settings['url_value'] = url.val();
266
267}
268
269/**
270 * adds a message to tell the user something in the cl_message div and then slides it down
271 * @param string message - the message to show
272 */
273function cl_message(message, rawfile) {
274    jQuery('#cl_messages').empty().hide().html(message).slideDown();
275    if (typeof(rawfile) != 'undefined') {
276        jQuery('#cl_messages').append('<div class="rawfilewrap"><p>Hover your mouse here to see the data that CommentLuv got back from your site..<br />If you see a warning or other error message then that might help you locate the problem (maybe another plugin is spitting out an error?)</p><div class="rawfile"><pre>' + rawfile + '</pre></div></div>');
277    }
278}
279
280function heart_big(e) {
281    // get url and data from link
282    linkspan = jQuery(this).parents(".cluv");
283    var link = jQuery(linkspan).find("a:first").attr("href");
284    var linkdata = jQuery('img', this).attr('class').split(' ');
285
286    // prepare call to admin
287    var data = {
288        'action': 'cl_ajax',
289        'cid': linkdata[2],
290        'cl_prem': linkdata[1],
291        'link': link,
292        'do': 'info',
293        '_ajax_nonce': cl_settings._info
294    };
295    cl_prem = linkdata[1];
296    // set up position
297    var position = jQuery(this).offset();
298    var windowwidth = jQuery(window).width();
299    windowheight = jQuery(window).height();
300    var xpos = position.left;
301    ypos = position.top;
302    if (xpos + 350 > windowwidth) {
303        xpos = windowwidth - 370;
304        if (xpos < 0) xpos = 0;
305    }
306
307    // setup panel and show with loading background image
308    jQuery('#heart_tip_big').empty().css({'left': xpos + "px", 'top': ypos + "px"});
309    jQuery('#heart_tip_big').css("width", "350px");
310    jQuery('#heart_tip_big').addClass("finalbig").show().addClass('cl_ajax');
311    // has this been shown before on this page?
312    if (typeof cl_settings[linkdata[2]] != 'undefined') {
313        fill_panel(cl_settings[linkdata[2]]);
314        return;
315    }
316    // execute call to admin
317    cl_try_ajax({
318        type: 'post',
319        data: data,
320        dataType: 'json',
321        success: function (data) {
322            if (typeof(data) == 'object' && jQuery('#heart_tip_big').is(':visible')) {
323                // acceptable response, populate panel
324                cl_settings[linkdata[2]] = data.panel;
325                fill_panel(data.panel);
326            } else {
327                jQuery('#heart_tip_big').removeClass('cl_ajax').html(cl_settings['no_info_message']);
328            }
329            jQuery('#heart_tip_big').mouseleave(heart_small);
330        }
331    });
332}
333
334function fill_panel(html) {
335    jQuery('#heart_tip_big').removeClass('cl_ajax').html(html).show();
336    if (cl_prem == 'p') {
337        jQuery('#heart_tip_big p.cl_title').css('backgroundColor', cl_settings['infoback']);
338    }
339    // move panel if it extends below window
340    var ely = ypos - jQuery(document).scrollTop();
341    var poph = jQuery('#heart_tip_big').height() + 20;
342    if (ely + poph > windowheight) {
343        var invis = poph - (windowheight - ely);
344        ypos -= invis;
345        if (ypos < 0) ypos = 0;
346        jQuery('#heart_tip_big').css('top', ypos);
347    }
348    return;
349}
350
351function heart_small() {
352    if (!jQuery('body').find('.cl_ajax').is(':visible')) {
353        jQuery("body").find("#heart_tip_big").empty().hide();
354    }
355
356}
357
358function do_nowt() {
359    return;
360}

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.