-
Notifications
You must be signed in to change notification settings - Fork 0
/
modal.js
57 lines (50 loc) · 1.84 KB
/
modal.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
function toggleModal() {
const enhanceSprintGoalElem = document.getElementById('enhanceSprintGoals');
if (enhanceSprintGoalElem.style.display === 'none') {
enhanceSprintGoalElem.style.display = 'block';
} else {
enhanceSprintGoalElem.style.display = 'none';
}
}
function createOrToggle() {
const enhanceSprintGoalElem = document.getElementById('enhanceSprintGoals');
if (enhanceSprintGoalElem === null) {
createModal();
} else {
toggleModal();
}
}
function createHeading() {
const headingContainer = document.createElement('div');
headingContainer.className = 'modal-header';
const heading = document.createElement('h1');
heading.innerHTML = "Sprint Goals";
const close = document.createElement('span');
close.innerHTML = '✕';
close.className = 'closeButton';
close.onclick = function(){document.getElementById('enhanceSprintGoals').style.display = 'none'; };
headingContainer.appendChild(heading);
headingContainer.appendChild(close);
return headingContainer;
}
function createModal() {
const newModal = document.createElement('div');
newModal.className = 'modal';
newModal.id = 'enhanceSprintGoals';
const modalContent = document.createElement('div');
modalContent.className = 'modal-content';
modalContent.appendChild(createHeading());
let sprintGoals = document.getElementsByClassName("ghx-sprint-goal")[0].innerText;
let sprintGoalTitle = document.body.querySelector(".ghx-sprint-goal > span").getAttribute("title")
let sprintGoalsArray = [];
sprintGoalsArray = sprintGoalTitle.split("\n");
const modalText = document.createTextNode(sprintGoals);
for(const para of sprintGoalsArray) {
const newP = document.createElement('p');
newP.innerHTML = para;
modalContent.appendChild(newP);
}
newModal.appendChild(modalContent);
document.body.appendChild(newModal);
}
createOrToggle();