<commit_before>var palettes = [];
var parse = function(data) {
  palettes = data.map(function(palette) {
    var colors = [];
    for (var i=0; i<5; i++) {
      colors.push({
        color: '#'+(palette.colors[i]||'FFFFFF'),
        width: ((palette.colorWidths[i]||0)*100|0)+'%'
      });
    }
    return colors;
  });
  console.log(palettes.length + ' palettes retrieved.');
  setInterval(change,5000);
  change();
};

var settings = {
  url: 'http://www.colourlovers.com/api/palettes/top',
  dataType: 'jsonp',
  data: {
    showPaletteWidths: 1,
    numResults: 100,
    hueOption: getTheme()
  },
  crossDomain: true,
  jsonp: 'jsonCallback',
  jsonpCallback: 'parse'
};
$.ajax(settings);

function getTheme() {
  var ret;
  var matches = window.location.href.match(/[\?&]theme=([^&#]*)/);
  if (matches === null){
    ret = 'all'
  }
  else{
    if (matches[1] === 'random') {
      var themes = ['red','orange','yellow','green','aqua','blue','violet','fuchsia'];
      ret = themes[Math.random()*themes.length|0];
    } else {
      ret = matches[1];
    }
  }
  console.log('Fetching ' + ret + ' palettes...');
  return ret;
}

function change() {
  if (palettes.length === 0) return;
  bars = $('.bar');
  var colors = palettes[0];
  palettes.push(palettes.shift());
  bars.each(function(i) {
    $(this).css('background-color',colors[i].color);
    $(this).css('width',colors[i].width);
  });
}
<commit_msg>Got rid of decimal truncation in width calculation<commit_after>var palettes = [];
var parse = function(data) {
  palettes = data.map(function(palette) {
    var colors = [];
    for (var i=0; i<5; i++) {
      colors.push({
        color: '#'+(palette.colors[i]||'FFFFFF'),
        width: ((palette.colorWidths[i]||0)*100)+'%'
      });
    }
    return colors;
  });
  console.log(palettes.length + ' palettes retrieved.');
  setInterval(change,5000);
  change();
};

var settings = {
  url: 'http://www.colourlovers.com/api/palettes/top',
  dataType: 'jsonp',
  data: {
    showPaletteWidths: 1,
    numResults: 100,
    hueOption: getTheme()
  },
  crossDomain: true,
  jsonp: 'jsonCallback',
  jsonpCallback: 'parse'
};
$.ajax(settings);

function getTheme() {
  var ret;
  var matches = window.location.href.match(/[\?&]theme=([^&#]*)/);
  if (matches === null){
    ret = 'all'
  }
  else{
    if (matches[1] === 'random') {
      var themes = ['red','orange','yellow','green','aqua','blue','violet','fuchsia'];
      ret = themes[Math.random()*themes.length|0];
    } else {
      ret = matches[1];
    }
  }
  console.log('Fetching ' + ret + ' palettes...');
  return ret;
}

function change() {
  if (palettes.length === 0) return;
  bars = $('.bar');
  var colors = palettes[0];
  palettes.push(palettes.shift());
  bars.each(function(i) {
    $(this).css('background-color',colors[i].color);
    $(this).css('width',colors[i].width);
  });
}

{'fraction_non_alphanumeric': 0.21406195614340412, 'fraction_numerical': 0.013574660633484163, 'mean_word_length': 3.3545454545454545, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '860359', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1031, 'n_words': 187}