+function unspin_all(){
+ $('input:checkbox').each(function (index) {
+ if(this.checked){
+ this.nextElementSibling.style.display = "none";
+ }
+ });
+}
+function spin_all(){
+ $('input:checkbox').each(function (index) {
+ if(this.checked){
+ this.nextElementSibling.style.display = "inline";
+ }
+ });
+}
$(document).ready(function() {
loadedTabs = [];
});
$('button#deleteusers').click(function() {
+ spin_all();
$('input:checkbox.user').each(function (index) {
if(this.checked){
var record_id = this.id;
mysliceAlert('Rest Error for: '+data.error,'warning', true);
//alert("Rest Error for "+record_id+": "+data.error);
}
+ unspin_all();
});
}
});
/* TODO: factorize into functions */
$('button#deleteslices').click(function() {
+ spin_all();
var flag = false;
$('input:checkbox.slice').each(function (index) {
if(this.checked){
var record_id = this.id;
+ $('#'+record_id+'-loading').spin();
$.post("/delete/slice/",{'filters':{'slice_hrn':this.id}}, function(data) {
if(data.success){
localStorage.clear();
mysliceAlert('Rest Error for: '+data.error,'warning', true);
//alert("Rest Error for "+record_id+": "+data.error);
}
+ unspin_all();
});
}
});
});
$('button#renewslices').click(function() {
+ spin_all();
var now = new Date();
/* In Javascript getMonth() gives month[0] = january, month[1] = february, and so on... */
var month = now.getMonth()+2;
$('input:checkbox.slice').each(function (index) {
if(this.checked){
var record_id = this.id;
+ $('#'+record_id+'-loading').spin();
$.post("/update/slice/",{'filters':{'slice_hrn':this.id},'params':{'expires':one_month_later}}, function(data) {
if(data.success){
// TODO: highlight row after success
mysliceAlert('Rest Error for: '+data.error,'warning', true);
//alert("Rest Error for "+record_id+": "+data.error);
}
+ unspin_all();
});
}
//window.location="/portal/institution#slices";
});
$('button#deleteprojects').click(function() {
+ spin_all();
var flag = false;
$('input:checkbox.project').each(function (index) {
if(this.checked){
var record_id = this.id;
+ $('#'+record_id+'-loading').spin();
console.log(record_id);
$.post("/delete/myslice:authority/",{'filters':{'authority_hrn':this.id}}, function(data) {
if(data.success){
mysliceAlert('Rest Error for: '+data.error,'warning', true);
//alert("Rest Error for "+record_id+": "+data.error);
}
+ unspin_all();
});
}
});