<commit_before>// Policy:
//  do not rely on external library, incl jQuery etc.

var defConfig = {
  arrow : { width : 5, head : 10 },
  data  : { url : "", interval : 60 },
  image : { file: "", width : 0, height : 0, locale: undefined, font: 10,
    legend : { x: 20, y: 20, r: 5, sep: 0.3, 
               bar_width: 3, legend_width: 10 },
    lastupdated: { x: 5, y: 5 }
  },
  target: { name: "", maxsave: undefined },
  load  : {},
  na    : "black",
  unit  : ""
};
var defConfigName = 'config.json';
var defSVG = 'http://www.w3.org/2000/svg';
var defXlink = 'http://www.w3.org/1999/xlink';

var config;
var link_lines;
var arrows;
var curExecTime;

function LoadWeathermap() {
  // load config
  // this is base config, so use main thread but not sub.
  var httpReq = new XMLHttpRequest();
  httpReq.open('GET', defConfigName, false);
  httpReq.send();
  var num_load;
  if (httpReq.status === 200) {
    json_load = JSON.parse(httpReq.responseText);
    config = defConfig;
    var json_conf = json_load.config;
    if (json_conf.arrow.width !== undefined) {config.arrow.width = json_conf.arrow.width; }
    if (json_conf.arrow.head !== undefined) {config.arrow.head = json_conf.arrow.head; }
    if (json_conf.target.name !== undefined) {config.target.name = json_conf.target.name; }
    if (json_conf.target.maxsave !== undefined) {config.target.maxsave = json_conf.target.maxsave; }
    if (json_conf.image.file !== undefined) {config.image.file = json_conf.image.file; }
    if (json_conf.image.height !== undefined) {config.image.height = json_conf.image.height; }
    if (json_conf.image.width !== undefined) {config.image.width = json_conf.image.width; }
    if (json_conf.image.locale !== undefined) {config.image.locale = json_conf.image.locale; }
    if (json_conf.image.font !== undefined) {config.image.font = json_conf.image.font; }
    if (json_conf.image.legend !== undefined) {
      var jc_legend = json_conf.image.legend;
      if ((jc_legend.x !== undefined) && (jc_legend.x > 0)) {config.image.legend.x = jc_legend.x; }
      if ((jc_legend.y !== undefined) && (jc_legend.y > 0)) {config.image.legend.y = jc_legend.y; }
    }
    if (json_conf.image.lastupdated !== undefined) {
      var jc_lu = json_conf.image.lastupdated;
      if ((jc_lu.x !== undefined) && (jc_lu.x > 0)) {config.image.lastupdated.x = jc_lu.x; }
      if ((jc_lu.y !== undefined) && (jc_lu.y > 0)) {config.image.lastupdated.y = jc_lu.y; }
    }
    if (json_conf.data.url !== undefined) {config.data.url = json_conf.data.url; }
    if (json_conf.data.interval !== undefined) {
      if (json_conf.data.interval > 0) {
        config.data.interval = json_conf.data.interval;
      }
    }
    if (json_load.link !== undefined) {link_lines = json_load.link; }
    else {
      console.log("No link defined in config json: " + defConfigName);
      return;
    }
    if (json_conf.load !== undefined) {
      if (json_conf.load.na !== undefined) {config.na = json_conf.load.na; }
      if (json_conf.load.max !== undefined) {config.max = json_conf.load.max; }
      if (json_conf.load.unit !== undefined) {config.unit = json_conf.load.unit; }
      if (config.max !== undefined) {config.max = config.na; }
      num_load = 3; // na, max + title, margin<commit_msg>Added check codes for entries of loaded config.json<commit_after>// Policy:
//  do not rely on external library, incl jQuery etc.

var defConfig = {
  arrow : { width : 5, head : 10 },
  data  : { url : "", interval : 60 },
  image : { file: "", width : 0, height : 0, locale: undefined, font: 10,
    legend : { x: 20, y: 20, r: 5, sep: 0.3, 
               bar_width: 3, legend_width: 10 },
    lastupdated: { x: 5, y: 5 }
  },
  target: { name: "", maxsave: undefined },
  load  : {},
  na    : "black",
  unit  : ""
};
var defConfigName = 'config.json';
var defSVG = 'http://www.w3.org/2000/svg';
var defXlink = 'http://www.w3.org/1999/xlink';

var config;
var link_lines;
var arrows;
var curExecTime;

function LoadWeathermap() {
  // load config
  // this is base config, so use main thread but not sub.
  var httpReq = new XMLHttpRequest();
  httpReq.open('GET', defConfigName, false);
  httpReq.send();
  var num_load;
  if (httpReq.status === 200) {
    json_load = JSON.parse(httpReq.responseText);
    if (json_load === undefined) {return false; }
    config = defConfig;
    var json_conf = json_load.config;
    if (json_conf.arrow !== undefined) {
      if (json_conf.arrow.width !== undefined)
        {config.arrow.width = json_conf.arrow.width; }
      if (json_conf.arrow.head !== undefined)
        {config.arrow.head = json_conf.arrow.head; }
    }
    if (json_conf.target !== undefined) {
      if (json_conf.target.name !== undefined)
        {config.target.name = json_conf.target.name; }
      if (json_conf.target.maxsave !== undefined)
        {config.target.maxsave = json_conf.target.maxsave; }
    }
    if (json_conf.image !== undefined) {
      if (json_conf.image.file !== undefined)
        {config.image.file = json_conf.image.file; }
      if (json_conf.image.height !== undefined)
        {config.image.height = json_conf.image.height; }
      if (json_conf.image.width !== undefined)
        {config.image.width = json_conf.image.width; }
      if (json_conf.image.locale !== undefined)
        {config.image.locale = json_conf.image.locale; }
      if (json_conf.image.font !== undefined)
        {config.image.font = json_conf.image.font; }
      if (json_conf.image.legend !== undefined) {
        var jc_legend = json_conf.image.legend;
        if ((jc_legend.x !== undefined) && (jc_legend.x > 0))
          {config.image.legend.x = jc_legend.x; }
        if ((jc_legend.y !== undefined) && (jc_legend.y > 0))
          {config.image.legend.y = jc_legend.y; }
      }
      if (json_conf.image.lastupdated !== undefined) {
        var jc_lu = json_conf.image.lastupdated;
        if ((jc_lu.x !== undefined) && (jc_lu.x > 0))
          {config.image.lastupdated.x = jc_lu.x; }
        if ((jc_lu.y !== undefined) && (jc_lu.y > 0))
          {config.image.lastupdated.y = jc_lu.y; }
      }
    }
    if (json_conf.data !== undefined) {
      if (json_conf.data.url !== undefined)
        {config.data.url = json_conf.data.url; }
      if (json_conf.data.interval !== undefined) {
        if (json_conf.data.interval > 0) {
          config.data.interval = json_conf.data.interval;
        }
      }
    }
    if (json_load.link !== undefined) {link_lines = json_load.link; }
    else {
      console.log("No link defined in config json: " + defConfigName);
      return;
    }
    if (json_conf.load !== undefined) {
      if (json_conf.load.na !== undefined) {config.na = json_conf.load.na; }
      if (json_conf.load.max !== undefined) {config.max = json_conf.load.max; }
      if (json_conf.load.unit !== undefined) {config.unit = json_conf.load.unit; }
      if (config.max !== undefined) {config.max = config.na; }
      num_load = 3; // na, max + title, margin
{'fraction_non_alphanumeric': 0.16049913941480207, 'fraction_numerical': 0.011474469305794608, 'mean_word_length': 2.797930283224401, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '861410', 'n_tokens_mistral': 2495, 'n_tokens_neox': 2380, 'n_words': 525}