36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
|
function grey_tasks(freetasks_ids){
|
||
|
$(".task_todo").each(function(){
|
||
|
var button = $(this).find("button[name='submit_getUnassignedTask_form']");
|
||
|
if(!freetasks_ids.includes(this.id) && !button.prop('disabled')){
|
||
|
button.prop('disabled', true);
|
||
|
button.text("Task assigned");
|
||
|
}
|
||
|
else if(freetasks_ids.includes(this.id) && button.prop('disabled')){
|
||
|
button.prop('disabled', false);
|
||
|
button.html("<i class='material-icons'>lock</i>");
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
function reatime_task_update(){
|
||
|
var self = reatime_task_update;
|
||
|
$.ajax({
|
||
|
type: "GET",
|
||
|
url: urlRoot + "custom/scripts/checkFreeTasks.php",
|
||
|
success: function(values)
|
||
|
{
|
||
|
var freetasks_ids = values.split(",");
|
||
|
freetasks_ids = $.map(freetasks_ids, function(id){
|
||
|
return "task_todo_" + id;
|
||
|
});
|
||
|
grey_tasks(freetasks_ids);
|
||
|
setTimeout(self, 5000);
|
||
|
},
|
||
|
error: function()
|
||
|
{
|
||
|
setTimeout(self, 5000);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
$(document).ready(reatime_task_update);
|