Skip to content

Commit

Permalink
Implement shortcut for duration #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Konzertheld committed Mar 10, 2021
1 parent 01319ce commit c6d8907
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions _api.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
}
echo $conn->commit();
break;
case "duration":
$done = $conn->prepare('UPDATE tasks SET duration=:duration WHERE id = :id');
$conn->beginTransaction();
foreach ($task_ids as $task_id) {
$done->bindValue(':id', $task_id);
$done->bindValue(':duration', $_GET["additional_data"]);
$done->execute();
}
echo $conn->commit();
break;
}
}
echo "end";
8 changes: 7 additions & 1 deletion ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ window.onload = function () {
$("body").on("keypress", null, null, function (e) {
// Which tasks operate on?
task_ids = [];
additional = null;

$(".selected").each(function () {
task_ids.push(this.id.substring(5));
});
Expand All @@ -34,7 +36,10 @@ window.onload = function () {
case 52:
case 53:
case 54:
case 55:
case 56: // 2 hours
commands = ["duration"];
additional = (e.which - 48) * 15 * 60;
break;
case 32:
// space for abort all
Expand All @@ -46,7 +51,8 @@ window.onload = function () {
url: "/planer/_api.php",
data: {
task_ids: task_ids.join(","),
commands: commands.join(",")
commands: commands.join(","),
additional_data: additional
},
success: function (result) {
window.location.reload(true);
Expand Down

0 comments on commit c6d8907

Please sign in to comment.