1 $(document).ready(function() {
2 $('a.home-tab').click(function() {
3 $('ul.nav-tabs li').removeClass('active');
4 $(this).parent().addClass('active');
5 $('div.home-panel').hide();
6 $('div#'+$(this).data('panel')).show();
8 var url = window.location;
11 tab = url.href.split("#")[1];
12 tab_exists = $('div#'+tab).length;
14 $('ul.nav-tabs li').removeClass('active');
15 $('li#'+tab+'-tab').addClass('active');
16 $('div.home-panel').hide();
21 /* TODO: factorize into functions */
22 $('button#deleteusers').click(function() {
23 $('input:checkbox.user').each(function (index) {
25 var record_id = this.id;
26 $.post("/delete/user/",{'filters':{'user_hrn':this.id}}, function(data) {
28 $('tr[id="'+record_id+'"]').fadeOut("slow");
29 $('tr[id="'+record_id+'"]').remove();
31 alert("Rest Error for "+record_id+": "+data.error);
38 $('button#deleteslices').click(function() {
39 $('input:checkbox.slice').each(function (index) {
41 var record_id = this.id;
42 $.post("/delete/slice/",{'filters':{'slice_hrn':this.id}}, function(data) {
44 $('tr[id="'+record_id+'"]').fadeOut("slow");
45 $('tr[id="'+record_id+'"]').remove();
47 alert("Rest Error for "+record_id+": "+data.error);
54 $('button#renewslices').click(function() {
56 /* In Javascript getMonth() gives month[0] = january, month[1] = february, and so on... */
57 var month = now.getMonth()+2;
58 var one_month_later = now.getFullYear()+"-"+month+"-"+now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
59 console.log(one_month_later);
60 $('input:checkbox.slice').each(function (index) {
62 var record_id = this.id;
63 $.post("/update/slice/",{'filters':{'slice_hrn':this.id},'params':{'expires':one_month_later}}, function(data) {
65 // TODO: highlight row after success
66 //$('tr[id="'+record_id+'"]').highlight();
68 alert("Rest Error for "+record_id+": "+data.error);
74 // TODO: refresh table
75 //window.location="/portal/institution#slices";
78 $('button#createslice').click(function() {
79 window.location="/portal/slice_request/";
81 $('button#slicerequestbtn').click(function() {
83 window.location="/portal/slice_request/";