Ticket #8759: character_count.2.diff
File character_count.2.diff, 4.0 KB (added by , 14 years ago) |
---|
-
wp-includes/script-loader.php
374 374 375 375 $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), '20101007' ); 376 376 $scripts->add_data( 'admin-widgets', 'group', 1 ); 377 378 if ( defined( 'WPLANG' ) && preg_match( '/^(bo|dz|ii|ja|km|my|th|zh)/', WPLANG ) ) { 379 $counting_string = __('Character count: %d'); 380 $counting_method = 'character'; 381 } else { 382 $counting_string = __('Word count: %d'); 383 $counting_method = 'word'; 384 } 377 385 378 386 $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20090422' ); 379 387 $scripts->add_data( 'word-count', 'group', 1 ); 380 388 $scripts->localize( 'word-count', 'wordCountL10n', array( 381 'count' => __('Word count: %d'), 389 'count' => $counting_string, 390 'method' => $counting_method, 382 391 'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};' 383 392 )); 384 393 -
wp-admin/js/word-count.dev.js
24 24 25 25 setTimeout( function() { 26 26 if ( tx ) { 27 tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( / | /gi, ' ' ); 28 tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' ); 29 tx.replace( /\S\s+/g, function(){tc++;} ); 27 if (wordCountL10n.method == 'character') { 28 tx = tx.replace(/<.[^<>]*?>/g, ''); 29 tx = tx.replace(/&(nbsp|#160|#x00a0);/gi, ''); 30 tx = tx.replace(/[ \s]/g, ''); 31 tx = tx.replace(/&(#[\d]{2,5}|#x[a-fA-F\d]{1,4}|[a-zA-Z]{2,8}[1-4]{0,2});/g, ' '); 32 tc = tx.length; 33 } else { 34 tx = tx.replace(/<.[^<>]*?>/g, " ").replace(/ | /gi, " "); 35 tx = tx.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, ""); 36 tx.replace(/\S\s+/g, function () { 37 tc++; 38 }); 39 } 30 40 } 31 41 w.html(tc.toString()); 32 42 -
wp-admin/js/word-count.js
1 (function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'<span id="word-count">0</span>'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a("#word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if (d){d=d.replace(/<.[^<>]*?>/g," ").replace(/ | /gi," ");d=d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");d.replace(/\S\s+/g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery));2 No newline at end of file 1 (function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'<span id="word-count">0</span>'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a("#word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if (d) {if ( wordCountL10n.method == 'character' ) {d = d.replace( /<.[^<>]*?>/g, '' );d = d.replace( /&(nbsp|#160|#x00a0);/gi, '' );d = d.replace( /[ \s]/g, '' );d = d.replace( /&(#[\d]{2,5}|#x[a-fA-F\d]{1,4}|[a-zA-Z]{2,8}[1-4]{0,2});/g, ' ' );b = d.length;} else {d = d.replace(/<.[^<>]*?>/g, " ").replace(/ | /gi, " ");d = d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, "");d.replace(/\S\s+/g, function () {b++;});}}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery)); 2 No newline at end of file