Last active
June 17, 2023 10:01
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## @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> |
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.
Updated script to handle failed AJAX
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
I've update the gist with the latest version of the macro that i'm using.