Refactoring
This commit is contained in:
parent
a45a89a02a
commit
8ef5d987a1
|
@ -14,8 +14,8 @@ foreach(!is_null($result) ? $result : [] as $row){
|
|||
$name_encoded = urlencode($user->name());
|
||||
$helmet_colour = $row["chief"] ? "red" : "black";
|
||||
$firstCellName = (time()-$row["online_time"])<=30 ? "<u>".$name."</u>" : $name;
|
||||
$firstCell = "<a id='username-{$row['id']}' style='text-align: left;'><img alt='{$helmet_colour} helmet' src='./resources/images/{$helmet_colour}_helmet.png' width='20px'>$firstCellName</a>";
|
||||
$secondCell = $row["available"] ? "<a><i class='fa fa-check' style='color:green'></i></a>" : "<a><i class='fa fa-times' style='color:red'></i></a>";
|
||||
$firstCell = "<a data-clickable data-user='{$row['id']}' data-user-available='{$row['available']}' style='text-align: left;'><img alt='{$helmet_colour} helmet' src='./resources/images/{$helmet_colour}_helmet.png' width='20px'>$firstCellName</a>";
|
||||
$secondCell = $row["available"] ? "<a data-clickable><i class='fa fa-check' style='color:green'></i></a>" : "<a data-clickable><i class='fa fa-times' style='color:red'></i></a>";
|
||||
$response[] = [
|
||||
$firstCell,
|
||||
$secondCell,
|
||||
|
@ -30,7 +30,7 @@ foreach(!is_null($result) ? $result : [] as $row){
|
|||
$name = $user->nameById($row["id"]);
|
||||
$helmet_colour = $row["chief"] ? "red" : "black";
|
||||
$firstCellName = (time()-$row["online_time"])<=30 ? "<u>".$name."</u>" : $name;
|
||||
$firstCell = "<a id='username-{$row['id']}' style='text-align: left;'><img alt='{$helmet_colour} helmet' src='./resources/images/{$helmet_colour}_helmet.png' width='20px'>$firstCellName</a>";
|
||||
$firstCell = "<a style='text-align: left;'><img alt='{$helmet_colour} helmet' src='./resources/images/{$helmet_colour}_helmet.png' width='20px'>$firstCellName</a>";
|
||||
$secondCell = $row["available"] ? "<a><i class='fa fa-check' style='color:green'></i></a>" : "<a><i class='fa fa-times' style='color:red'></i></a>";
|
||||
$response[] = [
|
||||
$firstCell,
|
||||
|
|
|
@ -75,19 +75,23 @@
|
|||
$("#deactivate-btn").click(function(){
|
||||
allertaJS.main.deactivate('{{ user.id }}', '');
|
||||
});
|
||||
allertaJS.main.loadTable({tablePage: "list", useCustomTableEngine: "default", callbackRepeat: true, callback: function() {
|
||||
$("tbody tr").each(function(key, el) {
|
||||
$(el.children[1]).click(function(event) {
|
||||
console.log(event.target);
|
||||
userId = event.target.parentElement.parentElement.parentElement.firstElementChild.firstElementChild.id.replace("username-","");
|
||||
console.log(userId);
|
||||
if(event.target.classList.contains("fa-times")) {
|
||||
allertaJS.main.activate(userId,0);
|
||||
} else {
|
||||
allertaJS.main.deactivate(userId,0);
|
||||
}
|
||||
});
|
||||
});
|
||||
allertaJS.main.loadTable({tablePage: "list", useCustomTableEngine: "default", callback: function() {
|
||||
$("tbody tr").on("click", function(key, el) {
|
||||
let targetElem = event.target;
|
||||
let userInfoElem = event.currentTarget.querySelector("[data-user]");
|
||||
let userId = userInfoElem.dataset.user;
|
||||
if(
|
||||
targetElem.hasAttribute("data-clickable") ||
|
||||
targetElem.parentElement.hasAttribute("data-clickable") ||
|
||||
(targetElem.childElementCount > 0 && targetElem.firstElementChild.hasAttribute("data-clickable"))
|
||||
){
|
||||
if(userInfoElem.dataset.userAvailable === "1") {
|
||||
allertaJS.main.deactivate(userId,0);
|
||||
} else {
|
||||
allertaJS.main.activate(userId,0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}});
|
||||
</script>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue