<commit_before>#= require _json2
#= require _history
#= require _history.html4
#= require _history.adapter.jquery.js

String.prototype.ends_with = (suffix) ->
  this.indexOf(suffix, this.length - suffix.length) != -1

class Wiselinks
  constructor: (@$target = $('body'), @options = {}) ->
    # Check that JQuery is available
    throw "Load jQuery to use Wiselinks" unless window.jQuery?

    self = this

    @options = jQuery.extend(self._defaults(), @options);

    if self.enabled()
      @assets_digest = $("meta[name='assets-digest']").attr("content")

      if History.emulated.pushState && @options.html4 == true
        if window.location.href.indexOf('#!') == -1 && @options.html4_root_path != null && window.location.pathname != @options.html4_root_path
          window.location.href = "#{window.location.protocol}//#{window.location.host}#{@options.html4_root_path}#!#{window.location.pathname}"
        
        if window.location.hash.indexOf('#!') != -1                 
          self._call(window.location.hash.substring(2))    

      History.Adapter.bind(
        window,
        "statechange"
        (event, data) ->    
          state = History.getState()         
          self._call(state.url, state.data.target, state.data.render)        
      )
      
      $(document).on(
        "submit", "form[data-push], form[data-replace]"
        (event) ->        
          self._process_form($(this))
          
          event.preventDefault()
          return false
      )
    
      $(document).on(
        "click", "a[data-push], a[data-replace]"
        (event) ->      
          if self._cross_origin_link(event.target) || self._non_standard_click(event)
            return true;        
          self._process_link($(this))

          event.preventDefault()
          return false
      )           
  
  enabled: ->
    !History.emulated.pushState || @options.html4 == true 

  load: (url, target, render = 'template') ->    
    History.pushState({ timestamp: (new Date().getTime()), render: render, target: target }, document.title, url )<commit_msg>Replaced target with currentTarget on link processing<commit_after>#= require _json2
#= require _history
#= require _history.html4
#= require _history.adapter.jquery.js

String.prototype.ends_with = (suffix) ->
  this.indexOf(suffix, this.length - suffix.length) != -1

class Wiselinks
  constructor: (@$target = $('body'), @options = {}) ->
    # Check that JQuery is available
    throw "Load jQuery to use Wiselinks" unless window.jQuery?

    self = this

    @options = jQuery.extend(self._defaults(), @options);

    if self.enabled()
      @assets_digest = $("meta[name='assets-digest']").attr("content")

      if History.emulated.pushState && @options.html4 == true
        if window.location.href.indexOf('#!') == -1 && @options.html4_root_path != null && window.location.pathname != @options.html4_root_path
          window.location.href = "#{window.location.protocol}//#{window.location.host}#{@options.html4_root_path}#!#{window.location.pathname}"
        
        if window.location.hash.indexOf('#!') != -1                 
          self._call(window.location.hash.substring(2))    

      History.Adapter.bind(
        window,
        "statechange"
        (event, data) ->    
          state = History.getState()         
          self._call(state.url, state.data.target, state.data.render)        
      )
      
      $(document).on(
        "submit", "form[data-push], form[data-replace]"
        (event) ->        
          self._process_form($(this))
          
          event.preventDefault()
          return false
      )
    
      $(document).on(
        "click", "a[data-push], a[data-replace]"
        (event) ->        
          if self._cross_origin_link(event.currentTarget) || self._non_standard_click(event)
            return true;        
          self._process_link($(this))

          event.preventDefault()
          return false
      )           
  
  enabled: ->
    !History.emulated.pushState || @options.html4 == true 

  load: (url, target, render = 'template') ->    
    History.pushState({ timestamp: (new Date().getTime()), render: render, target: target }, document.title, url )
{'fraction_non_alphanumeric': 0.1471492784480719, 'fraction_numerical': 0.005204636858291933, 'mean_word_length': 2.3108848864526235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '7380184', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1223, 'n_words': 230}