This repository has been archived by the owner on May 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
68 lines (53 loc) · 1.89 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
insertCommentButton = function() {
var button = document.createElement("a");
button.setAttribute("id","add-tmp");
button.setAttribute("class","toolbar-trigger");
button.addEventListener('click',clickHandler,true);
button.innerText = "Insert Template";
var div1 = document.createElement("div");
div1.setAttribute("class","aui-toolbar");
var div2 = document.createElement("div");
div2.setAttribute("class","toolbar-split");
var ul = document.createElement("ul");
ul.setAttribute("class","toolbar-group");
var li = document.createElement("li");
li.setAttribute("class","toolbar-item");
div1.appendChild(div2);
div2.appendChild(ul);
ul.appendChild(li);
li.appendChild(button);
document.getElementById('comment-wiki-edit').insertBefore(div1, document.getElementById('comment') );
};
clickHandler = function(){
document.getElementById('comment').value = "Review Comments:\n\nDecision: ";
};
addTime = function() {
var stuff = document.evaluate('//*[@id="issuetable"]//table[contains(@id, "tt_dpb_graph_orig_")]//tr[@class="tt_graph"]/td/img', document, null, XPathResult.ANY_TYPE, null );
var re = new RegExp("[0-9]{1,2}(?=h).");
arr = new Array();
thisNode = stuff.iterateNext();
while (thisNode) {
arr.push(thisNode);
thisNode = stuff.iterateNext();
}
arr.forEach(function(val) {
var parentID = findParentID(val);
var doco = document.getElementById(parentID);
var content = val.getAttribute("alt");
var newdiv = document.createElement("div");
newdiv.innerHTML = re.exec(content)[0];
newdiv.setAttribute("style","position: absolute; background-color: rgba(220, 220, 220, 0.8); right:0px;");
doco.parentNode.insertBefore(newdiv, doco);
});
};
findParentID = function(val) {
var myRe = new RegExp("tt_dpb_graph_inner_.+");
var tmp = val;
do {
var id = tmp.id;
tmp = tmp.parentNode;
} while (!myRe.exec(id));
return myRe.exec(id);
};
insertCommentButton();
addTime();