| [ Index ] |
PHP Cross Reference of zeList |
[Summary view] [Print] [Text view]
1 // Character count 2 3 (function(JQ) { 4 wpWordCount = { 5 6 init : function() { 7 var t = this, last = 0, co = JQ('#content'); 8 9 JQ('#wp-word-count').html( linkWordCountL10n.count.replace( /%d/, '<span id="word-count">0</span>' ) ); 10 t.block = 0; 11 t.wc(co.val()); 12 co.keyup( function(e) { 13 if ( e.keyCode == last ) return true; 14 if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val()); 15 last = e.keyCode; 16 return true; 17 }); 18 }, 19 20 wc : function(tx) { 21 var t = this, w = JQ('#wp-word-count'), tc = 0; 22 23 if ( t.block ) return; 24 t.block = 1; 25 26 setTimeout( function() { 27 if ( tx ) { 28 tc = tx.replace(/(<([^>]+)>)/ig,"").length; 29 //tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( / /gi, ' ' ); 30 //tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' ); 31 //tx.replace( /\S\s+/g, function(){tc++;} ); 32 } 33 34 w.html(''); 35 JQ('body#tinymce').css('border',''); 36 var count_text = linkWordCountL10n.count.replace( /%d/, '<span id="word-count">' + tc + '</span>' ); 37 if(tc < linkWordCountL10n.min_length) { 38 count_text = count_text + ' ' + '<span class="red">' + linkWordCountL10n.need_more.replace( /%d/,linkWordCountL10n.min_length) + '</span>'; 39 JQ('body#tinymce').css('border','red 1px solid;'); 40 } 41 else if(tc > linkWordCountL10n.max_length) { 42 count_text = count_text + ' ' + '<span class="red">' + linkWordCountL10n.need_less.replace( /%d/,linkWordCountL10n.max_length) + '</span>'; 43 JQ('body#tinymce').css('border','red 1px solid;'); 44 } 45 else { 46 JQ('body#tinymce').css('border','green 1px solid;'); 47 } 48 49 w.html(count_text); 50 //w.html(tc.toString()); 51 setTimeout( function() { t.block = 0; }, 2000 ); 52 }, 1 ); 53 } 54 } 55 }(jQuery)); 56 57 jQuery(document).ready( function(){ wpWordCount.init(); } );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat May 30 23:51:06 2009 | Cross-referenced by PHPXref 0.7 |