[ Index ]

WordPress Cross Reference

title

Body

[close]

/wp-admin/js/ -> word-count.js (source)

   1  /* global wordCountL10n */
   2  var wpWordCount;
   3  (function($,undefined) {
   4      wpWordCount = {
   5  
   6          settings : {
   7              strip : /<[a-zA-Z\/][^<>]*>/g, // strip HTML tags
   8              clean : /[0-9.(),;:!?%#$¿'"_+=\\/-]+/g, // regexp to remove punctuation, etc.
   9              w : /\S\s+/g, // word-counting regexp
  10              c : /\S/g // char-counting regexp for asian languages
  11          },
  12  
  13          block : 0,
  14  
  15          wc : function(tx, type) {
  16              var t = this, w = $('.word-count'), tc = 0;
  17  
  18              if ( type === undefined )
  19                  type = wordCountL10n.type;
  20              if ( type !== 'w' && type !== 'c' )
  21                  type = 'w';
  22  
  23              if ( t.block )
  24                  return;
  25  
  26              t.block = 1;
  27  
  28              setTimeout( function() {
  29                  if ( tx ) {
  30                      tx = tx.replace( t.settings.strip, ' ' ).replace( /&nbsp;|&#160;/gi, ' ' );
  31                      tx = tx.replace( t.settings.clean, '' );
  32                      tx.replace( t.settings[type], function(){tc++;} );
  33                  }
  34                  w.html(tc.toString());
  35  
  36                  setTimeout( function() { t.block = 0; }, 2000 );
  37              }, 1 );
  38          }
  39      };
  40  
  41      $(document).bind( 'wpcountwords', function(e, txt) {
  42          wpWordCount.wc(txt);
  43      });
  44  }(jQuery));


Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu