Advertisement
orksnork

Untitled

Jun 9th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   String.prototype.toTitleCase = function(n) {
  2.      var s = this;
  3.      if (1 !== n) s = s.toLowerCase();
  4.      return s.replace(/\b[a-z]/g,function(f){return f.toUpperCase()});
  5.   }
  6.  
  7.  
  8.  var tags = {
  9.     1: "the-reality",
  10.     2: "your-life",
  11.     3: "your-voice",
  12.     4: "amped-up"
  13.   };
  14.  
  15.   for (i = 1; i < 5; i++) {
  16.     if ($pathname === "/tagged/" + tags[i]) {
  17.       $(".navbar-nav li a.tag" + i).addClass("active");
  18.  
  19.    
  20.       var stringArray = tags[i];  
  21.       stringArray = stringArray.replace(/-/g, " ");
  22.       stringArray = stringArray.toTitleCase();
  23.  
  24.  //At this point, stringArray is going to be only one string, like "The Reality" or "Your Life"
  25.  
  26. // stringArray[i] is undefined, as stringArray isn't an array of thing.  also, the [i] listed below would be the same for all because this functionality is within your for loop.  If you removed the [i] from each, it would just say "The Reality" on each of them, then it would update them with "Your Life" so and so forth, and the last time through they'd all say "Amped Up"
  27.  
  28.       $('.nav .home').attr('onclick', 'ga(\'send\',\'event\',\'Content Header\',\'Click\',\'' + stringArray[i] + ' Blog Content Header - HOME\');');
  29.  
  30.       $('.nav .reasons').attr('onclick', 'ga(\'send\',\'event\',\'Content Header\',\'Click\',\'' + stringArray[i] + ' Blog Content Header - REASONS\');');
  31.  
  32.       $('.nav .tag1').attr('onclick', 'ga(\'send\',\'event\',\'Content Header\',\'Click\',\'' + stringArray[i] + ' Blog Content Header - THE REALITY\');');
  33.  
  34.       $('.nav .tag2').attr('onclick', 'ga(\'send\',\'event\',\'Content Header\',\'Click\',\'' + stringArray[i] + '  Blog Content Header - YOUR LIFE\');');
  35.  
  36.       $('.nav .tag3').attr('onclick', 'ga(\'send\',\'event\',\'Content Header\',\'Click\',\'' + stringArray[i] + '  Blog Content Header - YOUR VOICE\');');
  37.  
  38.       $('.nav .tag4').attr('onclick', 'ga(\'send\',\'event\',\'Content Header\',\'Click\',\'' + stringArray[i] + '  Blog Content Header - AMPED UP\');');
  39.  
  40.       $('.nav .home').attr('onclick', 'ga(\'send\',\'event\',\'Content Header\',\'Click\',\'' + stringArray[i] + ' Blog Content Header - HOME\');');
  41.     }
  42.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement