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')
26 .find('tr.comment, tr[id ^= "comment-"]')
27 .find('.column-author a[href^="http"]:first') // Ignore mailto: links, which would be the comment author's email.
29 var linkHref = $(this).attr( 'href' );
31 // Ignore any links to the current domain, which are diagnostic tools, like the IP address link
32 // or any other links another plugin might add.
33 var currentHostParts = document.location.href.split( '/' );
34 var currentHost = currentHostParts[0] + '//' + currentHostParts[2] + '/';
36 if ( linkHref.indexOf( currentHost ) != 0 ) {
37 var thisCommentId = $(this).parents('tr:first').attr('id').split("-");
40 .attr("id", "author_comment_url_"+ thisCommentId[1])
42 $( '<a href="#" class="remove_url">x</a>' )
43 .attr( 'commentid', thisCommentId[1] )
44 .attr( 'title', WPAkismet.strings['Remove this URL'] )
48 $('.remove_url').live('click', function () {
49 var thisId = $(this).attr('commentid');
51 action: 'comment_author_deurl',
52 _wpnonce: WPAkismet.comment_author_url_nonce,
59 beforeSend: function () {
61 $("a[commentid='"+ thisId +"']").hide();
63 $("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Removing...'] ) );
65 success: function (response) {
67 // Show status/undo link
68 $("#author_comment_url_"+ thisId)
70 .addClass('akismet_undo_link_removal')
72 $( '<span/>' ).text( WPAkismet.strings['URL removed'] )
77 .text( WPAkismet.strings['(undo)'] )
78 .addClass( 'akismet-span-link' )
86 $('.akismet_undo_link_removal').live('click', function () {
87 var thisId = $(this).attr('cid');
88 var thisUrl = $(this).attr('href');
90 action: 'comment_author_reurl',
91 _wpnonce: WPAkismet.comment_author_url_nonce,
99 beforeSend: function () {
101 $("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Re-adding...'] ) );
103 success: function (response) {
106 $("a[commentid='"+ thisId +"']").show();
107 // Show link. Core strips leading http://, so let's do that too.
108 $("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').text( thisUrl.replace( /^http:\/\/(www\.)?/ig, '' ) );
116 // Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments.
117 $( 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, table.comments td.comment p a' ).mouseover( function () {
118 clearTimeout( mshotRemovalTimer );
120 if ( $( '.akismet-mshot' ).length > 0 ) {
121 if ( $( '.akismet-mshot:first' ).data( 'link' ) == this ) {
122 // The preview is already showing for this link.
126 // A new link is being hovered, so remove the old preview.
127 $( '.akismet-mshot' ).remove();
131 clearTimeout( mshotSecondTryTimer );
132 clearTimeout( mshotThirdTryTimer );
134 var thisHref = $.URLEncode( $( this ).attr( 'href' ) );
136 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>' );
137 mShot.data( 'link', this );
139 var offset = $( this ).offset();
142 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.
143 top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness
146 mshotSecondTryTimer = setTimeout( function () {
147 mShot.find( '.mshot-image' ).attr( 'src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2' );
150 mshotThirdTryTimer = setTimeout( function () {
151 mShot.find( '.mshot-image' ).attr( 'src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3' );
154 $( 'body' ).append( mShot );
155 } ).mouseout( function () {
156 mshotRemovalTimer = setTimeout( function () {
157 clearTimeout( mshotSecondTryTimer );
158 clearTimeout( mshotThirdTryTimer );
160 $( '.akismet-mshot' ).remove();
164 $('.checkforspam:not(.button-disabled)').click( function(e) {
165 $('.checkforspam:not(.button-disabled)').addClass('button-disabled');
166 $('.checkforspam-spinner').addClass( 'spinner' );
167 akismet_check_for_spam(0, 100);
171 function akismet_check_for_spam(offset, limit) {
175 'action': 'akismet_recheck_queue',
180 if (result.processed < limit) {
181 window.location.reload();
184 akismet_check_for_spam(offset + limit, limit);
191 jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
192 while(x<c.length){var m=r.exec(c.substr(x));
193 if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
194 }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
195 o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}