<commit_before>
/* =========================================================================
 * Svelto - Widgets - Remote - Reaction
 * =========================================================================
 * Copyright (c) 2015-2017 <NAME>
 * Licensed under MIT (https://github.com/svelto/svelto/blob/master/LICENSE)
 * =========================================================================
 * @require ../remote.js
 * @require widgets/toast/toast.js
 * ========================================================================= */

(function ( $, _, Svelto, Widgets, Factory, Pointer ) {

  'use strict';

  /* CONFIG */

  let config = {
    name: 'remoteReaction',
    options: {
      state: undefined, // The state of the reaction
      stateDefault: null, // The default state
      stateUrl: false, // If provided, fetch the state from here
      url: false, // Submit the reaction to this url
      ajax: {
        cache: false,
        method: 'POST'
      },
      datas: {
        state: 'state',
        stateUrl: 'state-url',
        url: 'url'
      }
    }
  };

  /* REMOTE REACTION */

  class RemoteReaction extends Widgets.Remote {

    /* SPECIAL */

    _variables () {

      this.$reaction = this.$element;

    }

    _init () {

      this.options.state = this.$reaction.hasAttribute ( `data-${this.options.datas.state}` ) ? this.$reaction.data ( this.options.datas.state ) : this.options.state || this.options.stateDefault;
      this.options.stateUrl = this.$reaction.data ( this.options.datas.stateUrl ) || this.options.stateUrl;
      this.options.url = this.$reaction.data ( this.options.datas.url ) || this.options.url;

      this._update ();

      this.___remoteState ();

    }

    /* REMOTE STATE */

    ___remoteState () {

      if ( !this.options.stateUrl ) return;

      $.get ( this.options.stateUrl, this.__remoteState.bind ( this ) );

    }

    __remoteState ( res ) {

      let state = $.ajaxResponseGet ( res, 'state' );

      if ( _.isUndefined ( state ) ) return;

      this._remoteState ( resj );

    }

    _remoteState ( resj ) {

      if ( resj.state === this.options.state ) return;<commit_msg>RemoteReaction: fixed leftover refactoring<commit_after>
/* =========================================================================
 * Svelto - Widgets - Remote - Reaction
 * =========================================================================
 * Copyright (c) 2015-2017 <NAME>
 * Licensed under MIT (https://github.com/svelto/svelto/blob/master/LICENSE)
 * =========================================================================
 * @require ../remote.js
 * @require widgets/toast/toast.js
 * ========================================================================= */

(function ( $, _, Svelto, Widgets, Factory, Pointer ) {

  'use strict';

  /* CONFIG */

  let config = {
    name: 'remoteReaction',
    options: {
      state: undefined, // The state of the reaction
      stateDefault: null, // The default state
      stateUrl: false, // If provided, fetch the state from here
      url: false, // Submit the reaction to this url
      ajax: {
        cache: false,
        method: 'POST'
      },
      datas: {
        state: 'state',
        stateUrl: 'state-url',
        url: 'url'
      }
    }
  };

  /* REMOTE REACTION */

  class RemoteReaction extends Widgets.Remote {

    /* SPECIAL */

    _variables () {

      this.$reaction = this.$element;

    }

    _init () {

      this.options.state = this.$reaction.hasAttribute ( `data-${this.options.datas.state}` ) ? this.$reaction.data ( this.options.datas.state ) : this.options.state || this.options.stateDefault;
      this.options.stateUrl = this.$reaction.data ( this.options.datas.stateUrl ) || this.options.stateUrl;
      this.options.url = this.$reaction.data ( this.options.datas.url ) || this.options.url;

      this._update ();

      this.___remoteState ();

    }

    /* REMOTE STATE */

    ___remoteState () {

      if ( !this.options.stateUrl ) return;

      $.get ( this.options.stateUrl, this.__remoteState.bind ( this ) );

    }

    __remoteState ( res ) {

      let state = $.ajaxResponseGet ( res, 'state' );

      if ( _.isNull ( state ) ) return;

      this._remoteState ( state );

    }

    _remoteState ( resj ) {

      if ( resj.state === this.options.state ) return;
{'fraction_non_alphanumeric': 0.2591400321913083, 'fraction_numerical': 0.0036790066681995862, 'mean_word_length': 2.75, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3298935', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1166, 'n_words': 258}