Skip to content

Instantly share code, notes, and snippets.

@leecannon
Last active June 17, 2023 10:01
Show Gist options
  • Save leecannon/1734e3cb7b4d70c25f6c1c85fbe54665 to your computer and use it in GitHub Desktop.
Save leecannon/1734e3cb7b4d70c25f6c1c85fbe54665 to your computer and use it in GitHub Desktop.
Confluence user macro to un-tick all tasks on the page - No Macro Body
## @noparams
<script type="text/javascript">
function untick() {
var base_url = window.location.protocol + "//" + window.location.host;
var tasklist_id = document.getElementsByClassName("inline-task-list")[0].dataset.inlineTasksContentId;
var boxes = document.getElementsByClassName("checked");
var number_of_boxes = boxes.length;
if (number_of_boxes == 0) return;
var completed_boxes = 0;
document.getElementById("btnUntick").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: "UNCHECKED", 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="btnUntick" type="button" class="submit aui-button aui-button-primary" onclick="untick()">Un-tick all boxes</button>
@leecannon
Copy link
Author

I've update the gist with the latest version of the macro that i'm using.

@khallingstad
Copy link

Beautiful script! Thank you very much. Working nicely on On-prem Confluence v. 7.2.1. To bad Confluence could not add this feature as default.

@leecannon
Copy link
Author

Updated script to handle failed AJAX

@leecannon
Copy link
Author

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

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