var opsBar = $("#opsbar-opsbar-operations"); var issueID = JIRA.Issue.getIssueId(); var token = $("#atlassian-token").attr("content"); var timesToLog = ["15m", "30m", "45m", "1h"]; var timesToLogLength = timesToLog.length; for (var i = 0; i < timesToLogLength; i++) { var time = timesToLog[i]; var li = document.createElement("li"); $(li).attr("class", "toolbar-item"); var a = document.createElement("a"); $(a).attr("class", "toolbar-trigger log-quick-work"); $(a).attr("id", "log-work-" + time); $(a).attr("title", "Log Quick Work - " + time); $(a).attr("time-to-log", time); var span = document.createElement("span"); $(span).attr("class", "trigger-label"); var label = document.createTextNode("+" + time); $(opsBar).append($(li).append($(a).append($(span).append(label)))); } $(".log-quick-work").click(function() { $.ajax({ url: "/secure/CreateWorklog.jspa", type: "POST", dataType: "html", contentType: "application/x-www-form-urlencoded; charset=UTF-8", data: { inline: true, decorator: "dialog", atl_token: token, id: issueID, timeLogged: $(this).attr("time-to-log"), // 11/Jul/16 1:16 PM startDate: moment().format("Do/MMM/YY h:mm a"), adjustEstimate: "auto", }, success: function() { JIRA.trigger(JIRA.Events.REFRESH_ISSUE_PAGE, [issueID]); }, error: function() { alert("Failed to log work"); } }); });