aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/static/new/javascript/create_corr_matrix.js
blob: c0c39fbc6e10421c1c24fa8e99fa41b037fa682e (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
var neg_color_scale = chroma.scale(['#91bfdb', '#ffffff']).domain([-1, -0.4]);
var pos_color_scale = chroma.scale(['#ffffff', '#fc8d59']).domain([0.4, 1])
$('.corr_cell').each( function () {
  corr_value = parseFloat($(this).find('span.corr_value').text())
  if (corr_value >= 0.5){
    $(this).css('background-color', pos_color_scale(parseFloat(corr_value))._rgb)
  }
  else if (corr_value <= -0.5) {
    $(this).css('background-color', neg_color_scale(parseFloat(corr_value))._rgb)
  }
  else {
    $(this).css('background-color', 'white')
  }
});

$('#short_labels').click( function (){
  if ($('.short_check').css("display") == "none"){
    $('.short_check').css("display", "inline-block")
  } else {
    $('.short_check').css("display", "none")
  }
  $('.shortName').each( function() {
    if ($(this).css("display") == "none"){
      $(this).css("display", "block");
    }
    else {
      $(this).css("display", "none");
    }
  });
});

$('#long_labels').click( function (){
  if ($('.long_check').css("display") == "none"){
    $('.long_check').css("display", "inline-block")
  } else {
    $('.long_check').css("display", "none")
  }
  $('.verboseName').each( function() {
    if ($(this).css("display") == "none"){
      $(this).css("display", "block");
    }
    else {
      $(this).css("display", "none");
    }
  });
});

select_all = function() {
  $(".trait_checkbox").each(function() {
      $(this).prop('checked', true);
  });
};

deselect_all = function() {
  $(".trait_checkbox").each(function() {
      $(this).prop('checked', false);
  });
};

change_buttons = function() {
  num_checked = $('.trait_checkbox:checked').length;
  if (num_checked === 0) {
    $("#add").prop("disabled", true);
  } else {
    $("#add").prop("disabled", false);
  }
};

add = function() {
  var traits;
  traits = $("input[name=pca_trait]:checked").map(function() {
    return $(this).val();
  }).get();

  var traits_hash = md5(traits.toString());

  $.ajax({
        type: "POST",
        url: "/collections/store_trait_list",
        data: {
          hash: traits_hash,
          traits: traits.toString()
        }
  });

  return $.colorbox({
    href: "/collections/add?hash=" + traits_hash
  });
}

$("#select_all").click(select_all);
$("#deselect_all").click(deselect_all);
$("#add").click(add);
$(".btn, .trait_checkbox").click(change_buttons);