summaryrefslogtreecommitdiff
path: root/js/pool.js
blob: 4cb2af812410e0f7d73a77c7f78438359de16aa4 (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
var ids = [];
var clicked = false;
var clicked_sess = "";

$().ready(function()
{
  $(".item").click(function () {
    var id = $(this).attr("id");
    if (!ids.includes(id) && !clicked) {
      $(this).append("<input id='name' />");
      ids.push(id);
      clicked = true;
      clicked_sess = $(this).attr("session");
    }
  });

  $("#button").click(function () {
    if (!clicked) return;
    if ($("#name").val()=="") return;
    $.ajax({url: "pool_save.php?name="+encodeURIComponent($("#name").val())+"&session="+encodeURIComponent(clicked_sess), success: function(result){
      if (result=="ok") {
        window.location = "http://postedit.cl.uni-heidelberg.de/interface.php?key="+clicked_sess+"&ui_type=t"; // FIXME
      } else {
        alert("Session taken, choose another session.");
      }
    }});
  });
});