{"size": 1056, "ext": "js", "max_stars_repo_path": "assets/js/foreigns.js", "max_stars_repo_name": "flpms/ftt", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assets/js/foreigns.js", "max_issues_repo_name": "flpms/ftt", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/js/foreigns.js", "max_forks_repo_name": "flpms/ftt", "max_forks_repo_forks_event_min_datetime": "2020-07-13T03:36:46.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-13T03:36:46.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 24.5581395349, "max_line_length": 81, "alphanum_fraction": 0.728219697}
var foreigns = document.getElementsByClassName('foreigns');
var i = 0;

function toggleActive(item) {
  item.classList.toggle('active');
}

function hasClassActiveIn(item) {
  return item.classList.contains('active');
}

function removeOthers() {
  document.querySelectorAll('.translation.active').forEach(function (item) {
    toggleActive(item);
  });
}

function clickListener(elem, callback) {
  elem.addEventListener('click', callback, false);
}

function addStyle(item) {
  var target = item.target;
  var translationItem = target.nextSibling;
  var boundaries = target.getBoundingClientRect();

  if (hasClassActiveIn(translationItem)) {
    return toggleActive(translationItem);
  }

  removeOthers();
  clickListener(translationItem, addStyle);

  translationItem.style.marginTop = '-' + boundaries.height.toFixed() + 'px';
  translationItem.style.left = boundaries.x.toFixed() + 'px';

  toggleActive(translationItem);
}

for (i = 0; i < foreigns.length; i++) {
  clickListener(foreigns[i].getElementsByClassName('to-translate')[0], addStyle);
}
