<commit_before>//this nodejs script will read the data points from the points/ directory, and 
//generate the index.html and get-involved.html files from that.

var elements = {};
var fs = require('fs');
function renderDataPoint(service, dataPoint, forPopup) {
  var text = fs.readFileSync('points/' + dataPoint + '.json').toString();
  var obj, badge, icon, sign, score;
  try {
    obj = JSON.parse(text);
  } catch (e) {
    console.log(e);
    console.log('Could not load data for data point ' + dataPoint + ', sorry! Refreshing the page might sometimes help.');
    die();
    return;
  }
  //this is choosing the css class for the icon that will be shown to the left of the data point:
  if (obj.tosdr.point == 'good') {
    badge = 'badge-success';
    icon = 'thumbs-up';
    sign = '+';
  } else if (obj.tosdr.point == 'mediocre') {
    badge = 'badge-warning';
    icon = 'thumbs-down';
    sign = '-';
  } else if (obj.tosdr.point == 'alert') {
    badge = 'badge-important';
    icon = 'remove';
    sign = '×';
  } else if (obj.tosdr.point == 'not bad') {
    badge = 'badge-neutral';
    icon = 'arrow-right';
    sign = '→';
  } else {
    badge = '';
    icon = 'question-sign';
    sign = '?';
  }
  //return the html for this data point, for inclusion in the popup or in the main page:
  if (forPopup) {
    return {
      id:dataPoint,
      score:obj.tosdr.score,
      text:'<div class="' + obj.tosdr.point + '"><h5><span class="badge ' + badge
        + '" title="' + obj.tosdr.point + '"><i class="icon-' + icon + ' icon-white">' + sign + '</i></span> ' + obj.name + ' <a href="' + obj.discussion + '" target="_blank" class="label context">Discussion</a></h5><p>'
        + obj.tosdr.tldr + '</p></div>'
    };
  } else {
    return {
      id:dataPoint,
      score:obj.tosdr.score,
      text:'<span class="badge ' + badge + '" title="' + obj.tosdr.score + '">'
        + '<i class="icon-' + icon + ' icon-white">' + sign + '</i></span>&nbsp;' + obj.name
    };
  }
}
function getServiceObject(name) {
  //each service (website) has its own generic description data, that is stored in the services/ directory
  //of this repo. this function loads in such a file:
  var text = fs.readFileSync('services/' + name + '.json').toString();
  var obj;
  try {
    obj = JSON.parse(text);
  } catch (e) {
    console.log(e);
    console.log('Could not load data for ' + name + ', sorry! Refreshing the page might sometimes help.');
    die();
  }
  if (obj) {
    return obj;
  } else {
    die('no obj in services/' + name + '.json');
  }
}
function getRatingText(className) {
  var ratingText = {
    0:"We haven't sufficiently reviewed the terms yet. Please contribute to our group: <a href=\"get-involved.html\">Get involved</a>.",
    "false":"We haven't sufficiently reviewed the terms yet. Please contribute to our group: <a href=\"get-involved.html\">Get involved</a>.",
    "A":"The terms of service treat you fairly, respect your rights and follows the best practices.",
    "B":"The terms of services are fair towards the user but they could be improved.",
    "C":"The terms of service are okay but some issues need your consideration.",
    "D":"The terms of service are very uneven or there are some important issues that need your attention.",
    "E":"The terms of service raise very serious concerns."
  };
  return ratingText[className];
}

function renderDetails(name, points, toslinks, obj) {
  console.log('renderDetails ' + name);
  console.log(points);
  console.log(toslinks);
  console.log(obj);
  //this renders one service (for instance 'Facebook' or 'Google') on our main index.html page:
  var header = '<h3><img src="logo/' + name + '.png" class="favlogo"><a class="modal-link" data-service-name="' + name + '" href="#">' + obj.name + '</a>';
  var rating;
  if (!obj.tosdr) {
    obj.tosdr = {rated:false};
  }
  if (obj.tosdr.rated) {
    rating = '<div id="' + name + '-rating" class="service-rating"><a title="Learn more about our classification" href="classification.html"><span class="label ' + obj.tosdr.rated + '">Class ' + obj.tosdr.rated + '</span></a></div></h3>';
  } else {
    rating = '<div id="' + name + '-rating" class="service-rating"><a title="Learn more about our classification" href="classification.html"><span class="label ' + obj.tosdr.rated + '">No Class Yet</span></a></div></h3>';
  }
  //we collect the data points into an array first, so that we can sort them by score (the score is the impact/importance of a data point):
  var renderables = [];
  for (var i in points) {
    renderables.push(renderDataPoint(name, points[i], false));
  }
  renderables.sort(function (a, b) {
    return (Math.abs(b.score) - Math.abs(a.score));
  });
  //construct the issues list from the sorted data points:
  var issues = '<section class="specificissues"><ul class="tosdr-points">';
  for (var i = 0; i < renderables.length; i++) {
    issues += '<li id="point-' + name + '-' + renderables[i].id + '">'
      + renderables[i].text
      + '</li>';
  }
  //add link to 'read the full terms' at the bottom:
  issues += '</ul>'
    + '<a class="modal-link" data-service-name="' + name + '" href="#" class="btn"><i class="icon  icon-th-list"></i> Expand</a>'
    + (toslinks.terms ? '&nbsp;<a href="' + toslinks.terms.url + '" class="btn btn-mini" target="_blank"><i class="icon  icon-list-alt"></i> Read the full terms</a>' : '')
    + '</section>';
  //add some search terms to the data-search field. this is quite crude, but it works:
  var search = [name];
  if (obj.keywords) {
    for (var j = 0; j < obj.keywords.length; j++) {
      search.push(obj.keywords[j]);
    }
  }
  if (obj.related) {
    for (var j = 0; j < obj.related.length; j++) {<commit_msg>style for full terms link<commit_after>//this nodejs script will read the data points from the points/ directory, and 
//generate the index.html and get-involved.html files from that.

var elements = {};
var fs = require('fs');
function renderDataPoint(service, dataPoint, forPopup) {
  var text = fs.readFileSync('points/' + dataPoint + '.json').toString();
  var obj, badge, icon, sign, score;
  try {
    obj = JSON.parse(text);
  } catch (e) {
    console.log(e);
    console.log('Could not load data for data point ' + dataPoint + ', sorry! Refreshing the page might sometimes help.');
    die();
    return;
  }
  //this is choosing the css class for the icon that will be shown to the left of the data point:
  if (obj.tosdr.point == 'good') {
    badge = 'badge-success';
    icon = 'thumbs-up';
    sign = '+';
  } else if (obj.tosdr.point == 'mediocre') {
    badge = 'badge-warning';
    icon = 'thumbs-down';
    sign = '-';
  } else if (obj.tosdr.point == 'alert') {
    badge = 'badge-important';
    icon = 'remove';
    sign = '×';
  } else if (obj.tosdr.point == 'not bad') {
    badge = 'badge-neutral';
    icon = 'arrow-right';
    sign = '→';
  } else {
    badge = '';
    icon = 'question-sign';
    sign = '?';
  }
  //return the html for this data point, for inclusion in the popup or in the main page:
  if (forPopup) {
    return {
      id:dataPoint,
      score:obj.tosdr.score,
      text:'<div class="' + obj.tosdr.point + '"><h5><span class="badge ' + badge
        + '" title="' + obj.tosdr.point + '"><i class="icon-' + icon + ' icon-white">' + sign + '</i></span> ' + obj.name + ' <a href="' + obj.discussion + '" target="_blank" class="label context">Discussion</a></h5><p>'
        + obj.tosdr.tldr + '</p></div>'
    };
  } else {
    return {
      id:dataPoint,
      score:obj.tosdr.score,
      text:'<span class="badge ' + badge + '" title="' + obj.tosdr.score + '">'
        + '<i class="icon-' + icon + ' icon-white">' + sign + '</i></span>&nbsp;' + obj.name
    };
  }
}
function getServiceObject(name) {
  //each service (website) has its own generic description data, that is stored in the services/ directory
  //of this repo. this function loads in such a file:
  var text = fs.readFileSync('services/' + name + '.json').toString();
  var obj;
  try {
    obj = JSON.parse(text);
  } catch (e) {
    console.log(e);
    console.log('Could not load data for ' + name + ', sorry! Refreshing the page might sometimes help.');
    die();
  }
  if (obj) {
    return obj;
  } else {
    die('no obj in services/' + name + '.json');
  }
}
function getRatingText(className) {
  var ratingText = {
    0:"We haven't sufficiently reviewed the terms yet. Please contribute to our group: <a href=\"get-involved.html\">Get involved</a>.",
    "false":"We haven't sufficiently reviewed the terms yet. Please contribute to our group: <a href=\"get-involved.html\">Get involved</a>.",
    "A":"The terms of service treat you fairly, respect your rights and follows the best practices.",
    "B":"The terms of services are fair towards the user but they could be improved.",
    "C":"The terms of service are okay but some issues need your consideration.",
    "D":"The terms of service are very uneven or there are some important issues that need your attention.",
    "E":"The terms of service raise very serious concerns."
  };
  return ratingText[className];
}

function renderDetails(name, points, toslinks, obj) {
  console.log('renderDetails ' + name);
  console.log(points);
  console.log(toslinks);
  console.log(obj);
  //this renders one service (for instance 'Facebook' or 'Google') on our main index.html page:
  var header = '<h3><img src="logo/' + name + '.png" class="favlogo"><a class="modal-link" data-service-name="' + name + '" href="#">' + obj.name + '</a>';
  var rating;
  if (!obj.tosdr) {
    obj.tosdr = {rated:false};
  }
  if (obj.tosdr.rated) {
    rating = '<div id="' + name + '-rating" class="service-rating"><a title="Learn more about our classification" href="classification.html"><span class="label ' + obj.tosdr.rated + '">Class ' + obj.tosdr.rated + '</span></a></div></h3>';
  } else {
    rating = '<div id="' + name + '-rating" class="service-rating"><a title="Learn more about our classification" href="classification.html"><span class="label ' + obj.tosdr.rated + '">No Class Yet</span></a></div></h3>';
  }
  //we collect the data points into an array first, so that we can sort them by score (the score is the impact/importance of a data point):
  var renderables = [];
  for (var i in points) {
    renderables.push(renderDataPoint(name, points[i], false));
  }
  renderables.sort(function (a, b) {
    return (Math.abs(b.score) - Math.abs(a.score));
  });
  //construct the issues list from the sorted data points:
  var issues = '<section class="specificissues"><ul class="tosdr-points">';
  for (var i = 0; i < renderables.length; i++) {
    issues += '<li id="point-' + name + '-' + renderables[i].id + '">'
      + renderables[i].text
      + '</li>';
  }
  //add link to 'read the full terms' at the bottom:
  issues += '</ul>'
    + '<a class="modal-link" data-service-name="' + name + '" href="#"><i class="icon  icon-th-list"></i> Expand</a>'
    + (toslinks.terms ? '&nbsp;<a href="' + toslinks.terms.url + '" target="_blank"><i class="icon  icon-list-alt"></i> Read the full terms</a>' : '')
    + '</section>';
  //add some search terms to the data-search field. this is quite crude, but it works:
  var search = [name];
  if (obj.keywords) {
    for (var j = 0; j < obj.keywords.length; j++) {
      search.push(obj.keywords[j]);
    }
  }
  if (obj.related) {
    for (var j = 0; j < obj.related.length; j++) {
{'fraction_non_alphanumeric': 0.17563665003938042, 'fraction_numerical': 0.0015752165922814387, 'mean_word_length': 3.209208103130755, 'pattern_counts': {'":': 12, '<': 113, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7071893', 'n_tokens_mistral': 3723, 'n_tokens_neox': 3673, 'n_words': 1157}