{"size": 1120, "ext": "js", "max_stars_repo_path": "client/scripts/index.js", "max_stars_repo_name": "ffwdjs/ffwd-net", "max_stars_repo_stars_event_min_datetime": "2020-05-25T23:15:44.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-25T23:15:44.000Z", "max_issues_repo_path": "client/scripts/index.js", "max_issues_repo_name": "ffwdjs/ffwd-net", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/scripts/index.js", "max_forks_repo_name": "ffwdjs/ffwd-net", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.3333333333, "max_line_length": 114, "alphanum_fraction": 0.5491071429}
/* jshint browser: true*/
module.exports = function() {
  'use strict';
  var $ = window.jQuery;
  console.info('socket.io client initializes');

  var io = require('socket.io-client');

  var socket = io();
  var _connected;


  socket.on('connect', function() {
    console.info('socket:connect', arguments);
    if (_connected === false) {
      location.reload();
    }
    _connected = true;
  });


  socket.on('disconnect', function() {
    console.info('socket:disconnect', arguments);
    _connected = false;
  });

  socket.on('ffwd:asset', function(info) {
    console.info('socket ffwd:asset', info);
    if (info.type === 'partial') {
      var stamp = (new Date()).getTime();
      $('[href*="styles.css"]').each(function() {
        var $el = $(this);
        var href = $el.attr('href');
        $el.attr('href', href.replace(/(|&)_r_=[0-9]+/, '') +(href.indexOf('?') > -1 ? '&' : '?')+ '_r_='+ stamp);
        $(window).trigger('resize');
      });
    }
    else if (localStorage.getItem('autoreload')) {
      location.reload();
    }
    else {
      // notify user?
    }
  });

  return socket;
};
