All files / publisher/market publicMetrics.js

7.69% Statements 1/13
0% Branches 0/6
0% Functions 0/2
7.69% Lines 1/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 341x                                                                  
const NAMES = {
  public_metrics_territories: "installed_base_by_country_percent",
  public_metrics_distros:
    "weekly_installed_base_by_operating_system_normalized",
};
 
function publicMetrics(form) {
  const publicMetricsEnabled = form["public_metrics_enabled"].checked;
 
  let blackList = [];
 
  Object.keys(NAMES).forEach((name) => {
    const checked = form[name].checked;
 
    if (!checked) {
      blackList.push(NAMES[name]);
    }
 
    if (!publicMetricsEnabled) {
      form[name].setAttribute("disabled", "disabled");
    } else {
      form[name].removeAttribute("disabled");
    }
  });
 
  if (blackList.length > 0) {
    form["public_metrics_blacklist"].setAttribute("value", blackList.join(","));
  } else {
    form["public_metrics_blacklist"].removeAttribute("value");
  }
}
 
export { NAMES, publicMetrics };