tmc_angel

Random count

Jul 3rd, 2013
46
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
  2. <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
  3. <script>
  4.     function setCookie(c_name,value,exdays)
  5.     {
  6.         var exdate = new Date();
  7.         exdate.setDate(exdate.getDate() + exdays);
  8.         var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
  9.         document.cookie = c_name + "=" + c_value;
  10.     }
  11.  
  12.     function getCookie(c_name)
  13.     {
  14.         var i, x, y, ARRcookies = document.cookie.split(";");
  15.  
  16.         for (i = 0; i < ARRcookies.length; i++)
  17.         {
  18.             x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
  19.             y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
  20.             x = x.replace(/^\s+|\s+$/g, "");
  21.  
  22.             if (x == c_name)
  23.             {
  24.                 return unescape(y);
  25.             }
  26.         }
  27.     }
  28.  
  29.     function checkCookie(cookie)
  30.     {
  31.         var peoples_count = getCookie(cookie);
  32.  
  33.         if (peoples_count != null && peoples_count != "")
  34.         {
  35.             $('#peoples_count').html(peoples_count)
  36.         }
  37.         else
  38.         {
  39.             peoples_count = Math.floor(Math.random()*515 + 470)
  40.             setCookie("peoples_count", peoples_count, 2);
  41. $('#peoples_count').html(peoples_count)
  42.         }
  43.     }
  44.  
  45. $().ready(function()
  46. {
  47. checkCookie('peoples_count')
  48. })
  49. </script>
RAW Paste Data