summaryrefslogtreecommitdiff
path: root/js/debug.js
blob: 9bc50f7ee391443b32721506618b14f088cbc648 (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
$().ready(function()
{

  // send commands using ajax
  $(".ajax").each(function(x) {
    $(this).click(function() {
       $.ajax({url: $(this).attr("tgt"), success: function(result){
          $("#control_reply").html(result);
      }});
    })
  })
  $("#features").click(function() { if (this.value=="Feature") this.value = ""; });
  $("#features").focusout(function() { if (this.value == "") this.value = "Feature"; });
  $("#features_value").click(function() { this.value = ""; });
  $("#features_value").focusout(function() { if (this.value == "") this.value = "1e-05"; });
  $("#feature_groups_value").click(function() { this.value = ""; });
  $("#feature_groups_value").focusout(function() { if (this.value == "") this.value = "1e-05"; });
  $("#set_features").click(function() {
    k = $("#features").val();
    v = $("#features_value").val();
    if (k=="Feature" || k=="" || v=="" || !parseFloat(v)) {
      alert("Malformed request.");
    } else {
      url_prefix = $("#features_type").val();
      $.ajax({url: url_prefix+"/"+k+"/"+v, success: function(result){
         $("#control_reply").html(result);
      }});
    }
  });
  $("#set_feature_groups").click(function() {
    k = $("#feature_groups").val();
    v = $("#feature_groups_value").val();
    if (v=="" || !parseFloat(v)) {
      alert("Malformed request.");
    } else {
       $.ajax({url: "/set_learning_rates/"+k+"/"+v, success: function(result){
          $("#control_reply").html(result);
      }});
    }
  });

  // sortable tables
  $("table.sortable").each(function(x) {
    $(this).tablesorter({widgets: ['zebra']});
  });

  // k-best list feature tables
  $(".toggle").each(function(x) {
    $(this).click(function() {
      $(this).next().toggle();
    })
  });
  $("table.kbest_features tr:odd").css("background-color", "#eee");
  $("table.kbest_features tr:even").css("background-color", "#fff");

  // display svg
  var d = atob(document.getElementById("svg_b64").innerHTML);
  $('#svg').append(
    $('<svg width="100%">'+d+'</svg>')
  );
  $("#svg").width($("#svg").children()[0].getBBox().width+"px");
  d = atob(document.getElementById("original_svg_b64").innerHTML);
  $('#original_svg').append(
    $('<svg width="100%">'+d+'</svg>')
  );
  $("#original_svg").width($("#original_svg").children()[0].getBBox().width+"px");

});