Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 12th, 2013  |  syntax: JavaScript  |  size: 0.86 KB  |  views: 5  |  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. <html>
  2. <head>
  3.   <title>Test Javascript Youtube</title>
  4.   <script>
  5.     function Format(str) {
  6.         var sRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');
  7.         var thousandSeparator = ".";
  8.         sValue = str;
  9.                
  10.         while(sRegExp.test(sValue)) {
  11.             sValue = sValue.replace(sRegExp, '$1' + thousandSeparator + '$2');
  12.         }
  13.     return sValue;
  14.     }
  15.   </script>
  16. </head>
  17. <body>
  18.   <p class="um"><em>150560996</em></p>
  19. <!--  <p class="um"><em>1148597</em></p>
  20.   <p class="um"><em>600000000</em></p> -->
  21. <script>
  22.   function main(arg){
  23.       var viewCount = new Array();
  24.  
  25.       for(var i=0; i<arguments.length; i++){
  26.           var viewCount = Format(document.getElementsByClassName(arguments[i])[i].textContent);
  27.           (function(){document.getElementsByClassName(arguments[i])[i].innerHTML = viewCount[i]})();          
  28.       }
  29.   }
  30.  
  31. main("um");
  32. </script>
  33. </body>
  34. </html>
clone this paste RAW Paste Data