Guest User

Untitled

a guest
Aug 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. var PT = PT || {
  2. route: {
  3. setCookie: function(cookie_name,value) {
  4. var c_value=escape(value);
  5. document.cookie=cookie_name + "=" + c_value;
  6. },
  7. getCookie: function(cookie_name) {
  8. var i,x,y,ARRcookies=document.cookie.split(";");
  9. for (i=0;i<ARRcookies.length;i++) {
  10. x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  11. y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  12. x=x.replace(/^\s+|\s+$/g,"");
  13. if (x==cookie_name) {
  14. return unescape(y);
  15. }
  16. }
  17. },
  18. count: function() {
  19.  
  20. var new_cookie = PT.route.getCookie("_ptroute");
  21. var s = new_cookie.split("||||");
  22. if (s.length == 5) {
  23. _ptq.push(["view", "1"]);
  24. return false;
  25. }
  26. if ($.inArray(window.location.pathname,s) === -1) {
  27. console.log("not visited");
  28. PT.route.setCookie("_ptroute",new_cookie+"||||"+window.location.pathname);
  29. }
  30. }
  31. }
  32. };
  33.  
  34. $(document).ready(function() {
  35. PT.route.count();
  36. });
Add Comment
Please, Sign In to add comment