{"size": 912, "ext": "js", "max_stars_repo_path": "src/util/tools.js", "max_stars_repo_name": "Mega-Mewthree/tile-trials-visualizer", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/util/tools.js", "max_issues_repo_name": "Mega-Mewthree/tile-trials-visualizer", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/util/tools.js", "max_forks_repo_name": "Mega-Mewthree/tile-trials-visualizer", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.0571428571, "max_line_length": 91, "alphanum_fraction": 0.6293859649}
let useNewCopy = false;
if (window.navigator.clipboard) {
  navigator.permissions.query({name: "clipboard-write"}).then(result => {
    if (result.state === "granted") {
      useNewCopy = true;
    }
  });
}

export function copyText(text, cb) {
  if (useNewCopy) {
    window.navigator.clipboard.writeText(text).then(() => cb(true)).catch(() => cb(false));
  } else {
    // https://stackoverflow.com/a/30810322
    const textArea = document.createElement("textarea");
    textArea.value = text;
    textArea.style.top = "0";
    textArea.style.left = "0";
    textArea.style.position = "fixed";

    document.body.appendChild(textArea);
    textArea.focus();
    textArea.select();

    try {
      const result = document.execCommand("copy");
      document.body.removeChild(textArea);
      return cb(result);
    } catch (e) {
      document.body.removeChild(textArea);
      return cb(false);
    }
  }
}
