1 jQuery(document).ready(function () {
2 jQuery( '.switch-have-key' ).click( function() {
3 var no_key = jQuery( this ).parents().find('div.no-key');
4 var have_key = jQuery( this ).parents().find('div.have-key');
6 no_key.addClass( 'hidden' );
7 have_key.removeClass( 'hidden' );
11 jQuery( 'p.need-key a' ).click( function(){
12 document.akismet_activate.submit();
14 jQuery('.akismet-status').each(function () {
15 var thisId = jQuery(this).attr('commentid');
16 jQuery(this).prependTo('#comment-' + thisId + ' .column-comment div:first-child');
18 jQuery('.akismet-user-comment-count').each(function () {
19 var thisId = jQuery(this).attr('commentid');
20 jQuery(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
22 jQuery('#the-comment-list tr.comment .column-author a[title ^= "http://"]').each(function () {
23 var thisTitle = jQuery(this).attr('title');
24 thisCommentId = jQuery(this).parents('tr:first').attr('id').split("-");
26 jQuery(this).attr("id", "author_comment_url_"+ thisCommentId[1]);
29 jQuery(this).after(' <a href="#" class="remove_url" commentid="'+ thisCommentId[1] +'" title="Remove this URL">x</a>');
32 jQuery('.remove_url').live('click', function () {
33 var thisId = jQuery(this).attr('commentid');
35 action: 'comment_author_deurl',
36 _wpnonce: WPAkismet.comment_author_url_nonce,
43 beforeSend: function () {
45 jQuery("a[commentid='"+ thisId +"']").hide();
47 jQuery("#author_comment_url_"+ thisId).html('<span>Removing...</span>');
49 success: function (response) {
51 // Show status/undo link
52 jQuery("#author_comment_url_"+ thisId).attr('cid', thisId).addClass('akismet_undo_link_removal').html('<span>URL removed (</span>undo<span>)</span>');
59 jQuery('.akismet_undo_link_removal').live('click', function () {
60 var thisId = jQuery(this).attr('cid');
61 var thisUrl = jQuery(this).attr('href').replace("http://www.", "").replace("http://", "");
63 action: 'comment_author_reurl',
64 _wpnonce: WPAkismet.comment_author_url_nonce,
72 beforeSend: function () {
74 jQuery("#author_comment_url_"+ thisId).html('<span>Re-adding…</span>');
76 success: function (response) {
79 jQuery("a[commentid='"+ thisId +"']").show();
81 jQuery("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').html(thisUrl);
88 jQuery('a[id^="author_comment_url"]').mouseover(function () {
89 var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://';
90 // Need to determine size of author column
91 var thisParentWidth = jQuery(this).parent().width();
92 // It changes based on if there is a gravatar present
93 thisParentWidth = (jQuery(this).parent().find('.grav-hijack').length) ? thisParentWidth - 42 + 'px' : thisParentWidth + 'px';
94 if (jQuery(this).find('.mShot').length == 0 && !jQuery(this).hasClass('akismet_undo_link_removal')) {
95 var thisId = jQuery(this).attr('id').replace('author_comment_url_', '');
96 jQuery('.widefat td').css('overflow', 'visible');
97 jQuery(this).css('position', 'relative');
98 var thisHref = jQuery.URLEncode(jQuery(this).attr('href'));
99 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>');
100 setTimeout(function () {
101 jQuery('.mshot-image_'+thisId).attr('src', wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2');
103 setTimeout(function () {
104 jQuery('.mshot-image_'+thisId).attr('src', wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3');
107 jQuery(this).find('.mShot').css('left', thisParentWidth).show();
109 }).mouseout(function () {
110 jQuery(this).find('.mShot').hide();
114 jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
115 while(x<c.length){var m=r.exec(c.substr(x));
116 if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
117 }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
118 o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}
120 // Preload mshot images after everything else has loaded
121 jQuery(window).load(function() {
122 var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://';
123 jQuery('a[id^="author_comment_url"]').each(function () {
124 jQuery.get(wpcomProtocol+'s0.wordpress.com/mshots/v1/'+jQuery.URLEncode(jQuery(this).attr('href'))+'?w=450');