Last active
January 2, 2016 13:29
-
-
Save qtip/8310293 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @match http://jira.fanhattan.com/* | |
// @match https://jira.fanhattan.com/* | |
// ==/UserScript== | |
var li = document.createElement("li"); | |
var label = document.createElement("li"); | |
document.querySelector(".aui-nav").appendChild(li); | |
document.querySelector(".aui-nav").appendChild(label); | |
var make_button = function(text, class_name){ | |
var button_a = document.createElement("a"); | |
button_a.appendChild(document.createTextNode(text)); | |
button_a.classList.add("aui-button") | |
button_a.classList.add("aui-style") | |
button_a.onclick = function(){ | |
var safe = function(x, d) { if(typeof d == "undefined") { d = 0.0} return isFinite(x) ? x : d }; | |
var t = {"day": 1, "days": 1, "hour": 0.125, "hours": 0.125, "week": 5, "weeks": 5}; | |
var sum = function(q){ return q.reduce(function(a,b){return safe(a) + safe(b); }, 0) }; | |
var time = sum([].slice.call(document.querySelectorAll(class_name)).map(function(e){ | |
return sum(e.innerText.split(", ").map(function(x){ | |
return safe(x.split(" ")[0]) * t[x.split(" ")[1]] | |
})); | |
})) | |
label.innerHTML = "<span style='padding-left: 10px;'>" + time + " days</span>"; | |
} | |
return button_a; | |
}; | |
li.appendChild(make_button("Orig. Time", ".nav.timeoriginalestimate")); | |
li.appendChild(make_button("Rem. Time", ".nav.timeestimate")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment