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

Untitled

By: a guest on Aug 3rd, 2012  |  syntax: None  |  size: 0.44 KB  |  hits: 10  |  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. function ellipsis(numOfWords, text, wordCount ) {
  2. wordCount = text.trim().replace(/\s+/g, ' ').split(' ').length;
  3.         if(numOfWords <= 0 || numOfWords === wordCount){
  4.                 return text;
  5.         } else {
  6.                 text = text.trim().split(' ');
  7.                 text.splice(numOfWords, wordCount, '...');
  8.                 return text.join(' ');
  9.         }
  10. }
  11.  
  12. //129 bytes, bitches.
  13. function e(n,t,w){w=t.trim().replace(/\s+/g," ").split(' ').length;t=t.trim().split(' ');t.splice(n,w,"...");return t.join(' ');}