1 jQuery( function ( $ ) {
2 var mshotRemovalTimer = null;
3 var mshotSecondTryTimer = null
4 var mshotThirdTryTimer = null
6 $( 'a.activate-option' ).click( function(){
8 if ( link.hasClass( 'clicked' ) ) {
9 link.removeClass( 'clicked' );
12 link.addClass( 'clicked' );
14 $( '.toggle-have-key' ).slideToggle( 'slow', function() {});
17 $('.akismet-status').each(function () {
18 var thisId = $(this).attr('commentid');
19 $(this).prependTo('#comment-' + thisId + ' .column-comment');
21 $('.akismet-user-comment-count').each(function () {
22 var thisId = $(this).attr('commentid');
23 $(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
25 $('#the-comment-list').find('tr.comment, tr[id ^= "comment-"]').find('.column-author a[title]').each(function () {
26 // Comment author URLs are the only URL with a title attribute in the author column.
27 var thisTitle = $(this).attr('title');
29 var thisCommentId = $(this).parents('tr:first').attr('id').split("-");
31 $(this).attr("id", "author_comment_url_"+ thisCommentId[1]);
35 $( '<a href="#" class="remove_url">x</a>' )
36 .attr( 'commentid', thisCommentId[1] )
37 .attr( 'title', WPAkismet.strings['Remove this URL'] )
41 $('.remove_url').live('click', function () {
42 var thisId = $(this).attr('commentid');
44 action: 'comment_author_deurl',
45 _wpnonce: WPAkismet.comment_author_url_nonce,
52 beforeSend: function () {
54 $("a[commentid='"+ thisId +"']").hide();
56 $("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Removing...'] ) );
58 success: function (response) {
60 // Show status/undo link
61 $("#author_comment_url_"+ thisId)
63 .addClass('akismet_undo_link_removal')
65 $( '<span/>' ).text( WPAkismet.strings['URL removed'] )
70 .text( WPAkismet.strings['(undo)'] )
71 .addClass( 'akismet-span-link' )
79 $('.akismet_undo_link_removal').live('click', function () {
80 var thisId = $(this).attr('cid');
81 var thisUrl = $(this).attr('href');
83 action: 'comment_author_reurl',
84 _wpnonce: WPAkismet.comment_author_url_nonce,
92 beforeSend: function () {
94 $("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Re-adding...'] ) );
96 success: function (response) {
99 $("a[commentid='"+ thisId +"']").show();
100 // Show link. Core strips leading http://, so let's do that too.
101 $("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').text( thisUrl.replace( /^http:\/\/(www\.)?/ig, '' ) );
109 // Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments.
110 $( 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, table.comments td.comment p a' ).mouseover( function () {
111 clearTimeout( mshotRemovalTimer );
113 if ( $( '.akismet-mshot' ).length > 0 ) {
114 if ( $( '.akismet-mshot:first' ).data( 'link' ) == this ) {
115 // The preview is already showing for this link.
119 // A new link is being hovered, so remove the old preview.
120 $( '.akismet-mshot' ).remove();
124 clearTimeout( mshotSecondTryTimer );
125 clearTimeout( mshotThirdTryTimer );
127 var thisHref = $.URLEncode( $( this ).attr( 'href' ) );
129 var mShot = $( '<div class="akismet-mshot mshot-container"><div class="mshot-arrow"></div><img src="//s0.wordpress.com/mshots/v1/' + thisHref + '?w=450" width="450" height="338" class="mshot-image" /></div>' );
130 mShot.data( 'link', this );
132 var offset = $( this ).offset();
135 left : Math.min( $( window ).width() - 475, offset.left + $( this ).width() + 10 ), // Keep it on the screen if the link is near the edge of the window.
136 top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness
139 mshotSecondTryTimer = setTimeout( function () {
140 mShot.find( '.mshot-image' ).attr( 'src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2' );
143 mshotThirdTryTimer = setTimeout( function () {
144 mShot.find( '.mshot-image' ).attr( 'src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3' );
147 $( 'body' ).append( mShot );
148 } ).mouseout( function () {
149 mshotRemovalTimer = setTimeout( function () {
150 clearTimeout( mshotSecondTryTimer );
151 clearTimeout( mshotThirdTryTimer );
153 $( '.akismet-mshot' ).remove();
157 $('.checkforspam:not(.button-disabled)').click( function(e) {
158 $('.checkforspam:not(.button-disabled)').addClass('button-disabled');
159 $('.checkforspam-spinner').addClass( 'spinner' );
160 akismet_check_for_spam(0, 100);
164 function akismet_check_for_spam(offset, limit) {
168 'action': 'akismet_recheck_queue',
173 if (result.processed < limit) {
174 window.location.reload();
177 akismet_check_for_spam(offset + limit, limit);
184 jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
185 while(x<c.length){var m=r.exec(c.substr(x));
186 if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
187 }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
188 o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}