Skip to content

Instantly share code, notes, and snippets.

@leecannon
Last active July 26, 2022 09:53
Show Gist options
  • Save leecannon/f38d1b0288f3a68a0461d2ea6da3bda3 to your computer and use it in GitHub Desktop.
Save leecannon/f38d1b0288f3a68a0461d2ea6da3bda3 to your computer and use it in GitHub Desktop.
Confluence user macro to tick all tasks on the page - No Macro Body
## @noparams
<script type="text/javascript">
function tick() {
var base_url = window.location.protocol + "//" + window.location.host;
var tasklist_id = document.getElementsByClassName("inline-task-list")[0].dataset.inlineTasksContentId;
var boxes = $("li[data-inline-task-id]").not(".checked");
var number_of_boxes = boxes.length;
if (number_of_boxes == 0) return;
var completed_boxes = 0;
document.getElementById("btnTick").innerHTML = "Please Wait...";
for (i = 0; i < number_of_boxes; i++) {
var task_id = boxes[i].dataset.inlineTaskId;
var targeturl = base_url + "/rest/inlinetasks/1/task/" + tasklist_id + "/" + task_id + "/";
jQuery.ajax({type: "POST",
url: targeturl,
data: JSON.stringify({status: "CHECKED", trigger: "VIEW_PAGE"}),
dataType: "json",
contentType: "application/json",
timeout: 30000,
success: function() {
completed_boxes = completed_boxes + 1;
if (completed_boxes == number_of_boxes) {
location.reload();
}
},
error: function() {
completed_boxes = completed_boxes + 1;
if (completed_boxes == number_of_boxes) {
location.reload();
}
}
});
}
}
</script>
<button id="btnTick" type="button" class="submit aui-button aui-button-primary" onclick="tick()">Tick all boxes</button>
@leecannon
Copy link
Author

Also made a gist to un-tick all checkboxes on the page.

@chrjoss
Copy link

chrjoss commented Mar 24, 2022

Unfortunatly this does not work with confluence 7.13.2 data-center. No new page-version is created, no changes of the tasks are done.
Does anyone have the same issue and does someone have a hint to help me to analyse and change the script to confluence 7.13.2?
Thanks very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment