Ticket #8759: 8759.4.diff
File 8759.4.diff, 1.7 KB (added by , 12 years ago) |
---|
-
wp-admin/js/word-count.dev.js
1 (function($ ,undefined) {1 (function($) { 2 2 wpWordCount = { 3 3 4 4 settings : { 5 5 strip : /<[a-zA-Z\/][^<>]*>/g, // strip HTML tags 6 6 clean : /[0-9.(),;:!?%#$¿'"_+=\\/-]+/g, // regexp to remove punctuation, etc. 7 w : /\S\s+/g, // word-counting regexp 8 c : /\S/g // char-counting regexp for asian languages 7 count : /\S\s+/g // counting regexp 9 8 }, 10 9 10 settingsEastAsia : { 11 count : /[\u3100-\u312F\u31A0-\u31BF\u4E00-\u9FCF\u3400-\u4DBF\uF900-\uFAFF\u2F00-\u2FDF\u2E80-\u2EFF\u31C0-\u31EF\u2FF0-\u2FFF\u1100-\u11FF\uA960-\uA97F\uD780-\uD7FF\u3130-\u318F\uFFA0-\uFFDC\uAC00-\uD7AF\u3040-\u309F\u30A0-\u30FF\u31F0-\u31FF\uFF65-\uFF9F\u3190-\u319F\uA4D0-\uA4FF\uA000-\uA48F\uA490-\uA4CF]/g 12 }, 13 11 14 block : 0, 12 15 13 wc : function(tx , type) {16 wc : function(tx) { 14 17 var t = this, w = $('.word-count'), tc = 0; 15 18 16 if ( type === undefined )17 type = wordCountL10n.type;18 if ( type !== 'w' && type !== 'c' )19 type = 'w';20 21 19 if ( t.block ) 22 20 return; 23 21 … … 25 23 26 24 setTimeout( function() { 27 25 if ( tx ) { 26 // remove generally useless stuff first 28 27 tx = tx.replace( t.settings.strip, ' ' ).replace( / | /gi, ' ' ); 28 29 // count east asia chars 30 tx = tx.replace( t.settingsEastAsia.count, function(){ tc++; return ''; } ); 31 32 // count remaining western characters 29 33 tx = tx.replace( t.settings.clean, '' ); 30 tx.replace( t.settings [type], function(){tc++;} );34 tx.replace( t.settings.count, function(){ tc++; return ''; } ); 31 35 } 32 36 w.html(tc.toString()); 33 37