]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-content/plugins/akismet/akismet.js
WordPress 3.5.1
[autoinstalls/wordpress.git] / wp-content / plugins / akismet / akismet.js
1 jQuery(document).ready(function () {
2         jQuery('.akismet-status').each(function () {
3                 var thisId = jQuery(this).attr('commentid');
4                 jQuery(this).prependTo('#comment-' + thisId + ' .column-comment div:first-child');
5         });
6         jQuery('.akismet-user-comment-count').each(function () {
7                 var thisId = jQuery(this).attr('commentid');
8                 jQuery(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
9         });
10         jQuery('#the-comment-list tr.comment .column-author a[title ^= "http://"]').each(function () {
11                 var thisTitle = jQuery(this).attr('title');
12                     thisCommentId = jQuery(this).parents('tr:first').attr('id').split("-");
13                 
14                 jQuery(this).attr("id", "author_comment_url_"+ thisCommentId[1]);
15                 
16                 if (thisTitle) {
17                         jQuery(this).after(' <a href="#" class="remove_url" commentid="'+ thisCommentId[1] +'" title="Remove this URL">x</a>');
18                 }
19         });
20         jQuery('.remove_url').live('click', function () {
21                 var thisId = jQuery(this).attr('commentid');
22                 var data = {
23                         action: 'comment_author_deurl',
24                         _wpnonce: WPAkismet.comment_author_url_nonce,
25                         id: thisId
26                 };
27                 jQuery.ajax({
28                     url: ajaxurl,
29                     type: 'POST',
30                     data: data,
31                     beforeSend: function () {
32                         // Removes "x" link
33                                 jQuery("a[commentid='"+ thisId +"']").hide();
34                                 // Show temp status
35                         jQuery("#author_comment_url_"+ thisId).html('<span>Removing...</span>');
36                     },
37                     success: function (response) {
38                         if (response) {
39                                         // Show status/undo link
40                                         jQuery("#author_comment_url_"+ thisId).attr('cid', thisId).addClass('akismet_undo_link_removal').html('<span>URL removed (</span>undo<span>)</span>');
41                                 }
42                     }
43                 });
44
45                 return false;
46         });
47         jQuery('.akismet_undo_link_removal').live('click', function () {
48                 var thisId = jQuery(this).attr('cid');
49                 var thisUrl = jQuery(this).attr('href').replace("http://www.", "").replace("http://", "");
50                 var data = {
51                         action: 'comment_author_reurl',
52                         _wpnonce: WPAkismet.comment_author_url_nonce,
53                         id: thisId,
54                         url: thisUrl
55                 };
56                 jQuery.ajax({
57                     url: ajaxurl,
58                     type: 'POST',
59                     data: data,
60                     beforeSend: function () {
61                                 // Show temp status
62                         jQuery("#author_comment_url_"+ thisId).html('<span>Re-adding…</span>');
63                     },
64                     success: function (response) {
65                         if (response) {
66                                         // Add "x" link
67                                         jQuery("a[commentid='"+ thisId +"']").show();
68                                         // Show link
69                                         jQuery("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').html(thisUrl);
70                                 }
71                     }
72                 });
73                 
74                 return false;
75         });
76         jQuery('a[id^="author_comment_url"]').mouseover(function () {
77                 var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://';
78                 // Need to determine size of author column
79                 var thisParentWidth = jQuery(this).parent().width();
80                 // It changes based on if there is a gravatar present
81                 thisParentWidth = (jQuery(this).parent().find('.grav-hijack').length) ? thisParentWidth - 42 + 'px' : thisParentWidth + 'px';
82                 if (jQuery(this).find('.mShot').length == 0 && !jQuery(this).hasClass('akismet_undo_link_removal')) {
83                         var thisId = jQuery(this).attr('id').replace('author_comment_url_', '');
84                         jQuery('.widefat td').css('overflow', 'visible');
85                         jQuery(this).css('position', 'relative');
86                         var thisHref = jQuery.URLEncode(jQuery(this).attr('href'));
87                         jQuery(this).append('<div class="mShot mshot-container" style="left: '+thisParentWidth+'"><div class="mshot-arrow"></div><img src="'+wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450" width="450" class="mshot-image_'+thisId+'" style="margin: 0;" /></div>');
88                         setTimeout(function () {
89                                 jQuery('.mshot-image_'+thisId).attr('src', wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2');
90                         }, 6000);
91                         setTimeout(function () {
92                                 jQuery('.mshot-image_'+thisId).attr('src', wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3');
93                         }, 12000);
94                 } else {
95                         jQuery(this).find('.mShot').css('left', thisParentWidth).show();
96                 }
97         }).mouseout(function () {
98                 jQuery(this).find('.mShot').hide();
99         });
100 });
101 // URL encode plugin
102 jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
103   while(x<c.length){var m=r.exec(c.substr(x));
104     if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
105     }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
106     o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}
107 });
108 // Preload mshot images after everything else has loaded
109 jQuery(window).load(function() {
110         var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://';
111         jQuery('a[id^="author_comment_url"]').each(function () {
112                 jQuery.get(wpcomProtocol+'s0.wordpress.com/mshots/v1/'+jQuery.URLEncode(jQuery(this).attr('href'))+'?w=450');
113         });
114 });