CoreFiles by mySites.guru
word-count.dev.js39 lines, 964 bytes, from wordpress-2.8.zip
Raw History Compare with 2.7.1
md5
2e2c9c93a59d78c9004c4359a2a05161
sha1
8fa57b1307460a17f64e351729a1228c58d43658
sha256
59c0a1c3d28dd1774c578593ba7964732790d5ac20a88f9ef65e33072e6da143
// Word count
(function($) {
	wpWordCount = {

		init : function() {
			var t = this, last = 0, co = $('#content');

			$('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '<span id="word-count">0</span>' ) );
			t.block = 0;
			t.wc(co.val());
			co.keyup( function(e) {
				if ( e.keyCode == last ) return true;
				if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val());
				last = e.keyCode;
				return true;
			});
		},

		wc : function(tx) {
			var t = this, w = $('#word-count'), tc = 0;

			if ( t.block ) return;
			t.block = 1;

			setTimeout( function() {
				if ( tx ) {
					tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( /&nbsp;|&#160;/gi, ' ' );
					tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' );
					tx.replace( /\S\s+/g, function(){tc++;} );
				}
				w.html(tc.toString());

				setTimeout( function() { t.block = 0; }, 2000 );
			}, 1 );
		}
	}

	$(document).ready( function(){ wpWordCount.init(); } );
}(jQuery));

The same content is in 47 releases, WordPress 2.8-beta1 to 3.1.4. See them all, or every version of this file.