]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-content/plugins/akismet/akismet.js
WordPress 3.8.2
[autoinstalls/wordpress.git] / wp-content / plugins / akismet / akismet.js
1 jQuery( function ( $ ) {
2         $( '.switch-have-key' ).click( function() {
3                 var no_key = $( this ).parents().find('div.no-key');            
4                 var have_key = $( this ).parents().find('div.have-key');
5                 
6                 no_key.addClass( 'hidden' );
7                 have_key.removeClass( 'hidden' );               
8                 
9                 return false;
10         });
11         $( 'p.need-key a' ).click( function(){
12                 document.akismet_activate.submit();
13         });
14         $('.akismet-status').each(function () {
15                 var thisId = $(this).attr('commentid');
16                 $(this).prependTo('#comment-' + thisId + ' .column-comment div:first-child');
17         });
18         $('.akismet-user-comment-count').each(function () {
19                 var thisId = $(this).attr('commentid');
20                 $(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
21         });
22         $('#the-comment-list').find('tr.comment, tr[id ^= "comment-"]').find('.column-author a[title ^= "http://"]').each(function () {
23                 var thisTitle = $(this).attr('title');
24                     thisCommentId = $(this).parents('tr:first').attr('id').split("-");
25                 
26                 $(this).attr("id", "author_comment_url_"+ thisCommentId[1]);
27                 
28                 if (thisTitle) {
29                         $(this).after(
30                                 $( '<a href="#" class="remove_url">x</a>' )
31                                         .attr( 'commentid', thisCommentId[1] )
32                                         .attr( 'title', WPAkismet.strings['Remove this URL'] )
33                         );
34                 }
35         });
36         $('.remove_url').live('click', function () {
37                 var thisId = $(this).attr('commentid');
38                 var data = {
39                         action: 'comment_author_deurl',
40                         _wpnonce: WPAkismet.comment_author_url_nonce,
41                         id: thisId
42                 };
43                 $.ajax({
44                     url: ajaxurl,
45                     type: 'POST',
46                     data: data,
47                     beforeSend: function () {
48                         // Removes "x" link
49                                 $("a[commentid='"+ thisId +"']").hide();
50                                 // Show temp status
51                         $("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Removing...'] ) );
52                     },
53                     success: function (response) {
54                         if (response) {
55                                         // Show status/undo link
56                                         $("#author_comment_url_"+ thisId)
57                                                 .attr('cid', thisId)
58                                                 .addClass('akismet_undo_link_removal')
59                                                 .html(
60                                                         $( '<span/>' ).text( WPAkismet.strings['URL removed'] )
61                                                 )
62                                                 .append( ' ' )
63                                                 .append(
64                                                         $( '<span/>' )
65                                                                 .text( WPAkismet.strings['(undo)'] )
66                                                                 .addClass( 'akismet-span-link' )
67                                                 );
68                                 }
69                     }
70                 });
71
72                 return false;
73         });
74         $('.akismet_undo_link_removal').live('click', function () {
75                 var thisId = $(this).attr('cid');
76                 var thisUrl = $(this).attr('href').replace("http://www.", "").replace("http://", "");
77                 var data = {
78                         action: 'comment_author_reurl',
79                         _wpnonce: WPAkismet.comment_author_url_nonce,
80                         id: thisId,
81                         url: thisUrl
82                 };
83                 $.ajax({
84                     url: ajaxurl,
85                     type: 'POST',
86                     data: data,
87                     beforeSend: function () {
88                                 // Show temp status
89                         $("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Re-adding...'] ) );
90                     },
91                     success: function (response) {
92                         if (response) {
93                                         // Add "x" link
94                                         $("a[commentid='"+ thisId +"']").show();
95                                         // Show link
96                                         $("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').html(thisUrl);
97                                 }
98                     }
99                 });
100                 
101                 return false;
102         });
103         $('a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type').mouseover(function () {
104                 var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://';
105                 // Need to determine size of author column
106                 var thisParentWidth = $(this).parent().width();
107                 // It changes based on if there is a gravatar present
108                 thisParentWidth = ($(this).parent().find('.grav-hijack').length) ? thisParentWidth - 42 + 'px' : thisParentWidth + 'px';
109                 if ($(this).find('.mShot').length == 0 && !$(this).hasClass('akismet_undo_link_removal')) {
110                         var self = $( this );
111                         $('.widefat td').css('overflow', 'visible');
112                         $(this).css('position', 'relative');
113                         var thisHref = $.URLEncode( $(this).attr('href') );
114                         $(this).append('<div class="mShot mshot-container" style="left: '+thisParentWidth+'"><div class="mshot-arrow"></div><img src="//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450" width="450" class="mshot-image" style="margin: 0;" /></div>');
115                         setTimeout(function () {
116                                 self.find( '.mshot-image' ).attr('src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2');
117                         }, 6000);
118                         setTimeout(function () {
119                                 self.find( '.mshot-image' ).attr('src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3');
120                         }, 12000);
121                 } else {
122                         $(this).find('.mShot').css('left', thisParentWidth).show();
123                 }
124         }).mouseout(function () {
125                 $(this).find('.mShot').hide();
126         });
127         $('.checkforspam:not(.button-disabled)').click( function(e) { 
128             $('.checkforspam:not(.button-disabled)').addClass('button-disabled'); 
129                 $('.checkforspam-spinner').show(); 
130                 akismet_check_for_spam(0, 100); 
131                 e.preventDefault(); 
132         });
133         
134         function akismet_check_for_spam(offset, limit) { 
135                 $.post( 
136                         ajaxurl, 
137                         { 
138                                 'action': 'akismet_recheck_queue', 
139                                 'offset': offset, 
140                                 'limit': limit 
141                         }, 
142                         function(result) { 
143                                 if (result.processed < limit) { 
144                                         window.location.reload(); 
145                                 } 
146                                 else { 
147                                         akismet_check_for_spam(offset + limit, limit); 
148                                 } 
149                         } 
150                 ); 
151         }
152 });
153 // URL encode plugin
154 jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
155   while(x<c.length){var m=r.exec(c.substr(x));
156     if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
157     }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
158     o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}
159 });