summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/memory.js
blob: a614e91c2775256c89d3c47df2b2bffe8d7930f3 (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
$(function() {
  $('td').focus(function() {
    if (this.id.split("-")[0] == "memory") {
      $(this).css("background-color", "lightblue")
    }
  });
  var data = [];
  $('td').keydown(function() {
    data.push(this.id, $(this).html().substr(0, 2)); //position, value
  })
  $('td').blur(function() {
    $(this).css("background", "none");
    if ((id_i = data.indexOf(this.id) != -1) && data[id_i+1] != $(this).html().substr(0, 2)) {
      $(this).css("color", "darkgreen");
      var int_id = this.id.split("-")[1]
      $.post("/memory/update_memory?project="+$(this).closest("table").data("project")+"&file="+Math.floor((int_id/2048)+1)+"&mem_id="+int_id%2048+"&value="+$(this).html().substr(0, 2));
      data.splice(id_i, 2);
    }
  });
  $('select').change(function() {
    $.get("/memory/table?project="+$(this).data("project")+"&file="+$(this).find("option:selected").text()+".hex")
  });
});