Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 7th, 2012  |  syntax: None  |  size: 0.40 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. if (typeof(String.prototype.trim) === "undefined") {
  2.     String.prototype.trim = function() {
  3.         return String(this).replace(/^\s+|\s+$/g, '');
  4.     };
  5. };
  6.  
  7. function number_with_commas(x) {
  8.     return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  9. };
  10.  
  11. function count_words(words) {
  12.         var ct = (words == "") ? 0 : words.split(/[\s\.\?]+/).length;
  13.         $("#word_count span").html(number_with_commas(ct));
  14. };