<commit_before>- if @error_404
  - url = "/404?page=#{request.fullpath}&from=#{request.referer}"
- else
  - url = URI.parse(request.fullpath)
  - url.query ||= "ga=1"
  - if @ga_user
    - url.query += "&#{@ga_user.to_query}"

:javascript
  var debug_on = /debug/i.test($(location).attr('href').toLowerCase());
  var ga_url = "";
  if(typeof(delayGAEvents) == "undefined"){
    delayGAEvents = false;
  }
  function class_type_or_click(element){
    var this_is_sparta ="click:";
    var story_id = "";
    var story = $(element).parents(".item.active, .story");
    if(story.length > 0){
      story_id = "story_" + $(story[0]).get(0).id.split("_")[1];
    }
    var val = $(element).attr("value");
    var tag_name = $(element).get(0).tagName;
    var text_val = $(element).text();
    var alt = $(element).attr("alt");
    var data = [val, text_val, tag_name, alt, story_id];

    data = _.select(data, function(e){ 
      return !_.isNull(e) && !_.isUndefined(e);
    });
    this_is_sparta += _.map(data, function(e){return e.replace(/\n*/, "");}).join(":");
    
    return this_is_sparta.replace(/\s+/g,'_');
  }

  function build_ga_string(element){
    var build_ga;
    var recursion = false;

    build_ga = class_type_or_click(element);

    var parent_list = $(element).parents();

    if(recursion){
      parent_list.each(function(index){
        build_ga += '-' + class_type_or_click(this);
      });
    }

   return build_ga;
  }

  function submit_ga_string(element, built_ga){
    if(!_.isNull(element)){
      built_ga = build_ga_string(element);
    } 
    uri_encoded_ga = encodeURI(built_ga);
    var ts = new Date().getTime();
    post_to_ga =  "#{ga_url}&ts=" + ts +"&additional=["+uri_encoded_ga;

    post_to_ga += "]";
    

    try{
      if('#{Rails.env.to_s}' == "production"){
        if(debug_on){
          log(post_to_ga);
        }
      
        _gaq.push(['_setAccount', '#{AppConfig["google_analytics_stream_id"]}']);
        _gaq.push(['_trackPageview', post_to_ga]);
      }else{
        log(post_to_ga); 
      }
    }
    catch(err){
      $('#ga_errors').append("<p>" + err + "</p>");
    }
  }

  function generate_ga_from_element(element){
    //currently unused for GA. Kept for obvious reasons
     var clazz = $(element).attr("class");<commit_msg>pull title tag, fix exception<commit_after>- if @error_404
  - url = "/404?page=#{request.fullpath}&from=#{request.referer}"
- else
  - url = URI.parse(request.fullpath)
  - url.query ||= "ga=1"
  - if @ga_user
    - url.query += "&#{@ga_user.to_query}"

:javascript
  var debug_on = /debug/i.test($(location).attr('href').toLowerCase());
  var ga_url = "";
  if(typeof(delayGAEvents) == "undefined"){
    delayGAEvents = false;
  }
  function class_type_or_click(element){
    var this_is_sparta ="click:";
    var val = $(element).attr("value");
    var tag_name = $(element).get(0).tagName;
    var text_val = $(element).text();
    var alt = $(element).attr("alt");
    var title = $(element).attr("title");
    var data = [val, text_val, tag_name, alt, title];

    data = _.select(data, function(e){ 
      return !_.isNull(e) && !_.isUndefined(e);
    });
    this_is_sparta += _.map(data, function(e){return e.replace(/\n*/, "");}).join(":");
    
    return this_is_sparta.replace(/\s+/g,'_');
  }

  function build_ga_string(element){
    var build_ga;
    var recursion = false;

    build_ga = class_type_or_click(element);

    var parent_list = $(element).parents();

    if(recursion){
      parent_list.each(function(index){
        build_ga += '-' + class_type_or_click(this);
      });
    }

   return build_ga;
  }

  function submit_ga_string(element, built_ga){
    if(!_.isNull(element)){
      built_ga = build_ga_string(element);
    } 
    uri_encoded_ga = encodeURI(built_ga);
    var ts = new Date().getTime();
    post_to_ga =  ga_url + "&ts=" + ts +"&additional=["+uri_encoded_ga;

    post_to_ga += "]";
    

    try{
      if('#{Rails.env.to_s}' == "production"){
        if(debug_on){
          log(post_to_ga);
        }
      
        _gaq.push(['_setAccount', '#{AppConfig["google_analytics_stream_id"]}']);
        _gaq.push(['_trackPageview', post_to_ga]);
      }else{
        log(post_to_ga); 
      }
    }
    catch(err){
      $('#ga_errors').append("<p>" + err + "</p>");
    }
  }

  function generate_ga_from_element(element){
    //currently unused for GA. Kept for obvious reasons
     var clazz = $(element).attr("class");
{'fraction_non_alphanumeric': 0.18617140299843365, 'fraction_numerical': 0.004475274110539271, 'mean_word_length': 3.0489130434782608, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7057259', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1592, 'n_words': 266}