Skip to content

Commit

Permalink
Improve reporting (#23)(#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleroush committed Jun 8, 2018
1 parent 3d0eb66 commit 89bca88
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 23 deletions.
77 changes: 55 additions & 22 deletions HideAndSeek.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
function createToPublish() {
var span = document.createElement('span');
span.classList.add('HideAndSeekSpan')
span.classList.add('to-publish')
var label = document.createElement('label');
var checkBox = document.createElement('input');
checkBox.type = "checkBox";
checkBox.checked = true;
label.innerText = "Publish Review";
span.appendChild(label);
label.appendChild(checkBox);
return span;
}

function publishReview() {
var reviewMenu = document.querySelector('.pull-request-review-menu')
if(reviewMenu != null) {
var button = reviewMenu.querySelector('button');

button.onclick = function() {
var author = document.querySelector('.header-nav-current-user').querySelector('strong').innerText
var files = loadData()[getPullRequestId()]['files'];
//check button and then check if they want to completes
var meta = { author: author, files: files };
var rawMeta = metaData(localStorageKey, meta)
document.querySelector('#pull_request_review_body').value = document.querySelector('#pull_request_review_body').value + "\n" + rawMeta;
var parent = button.parentElement

if(parent.querySelector(".HideAndSeekSpan.to-publish") == null) {
parent.prepend(createToPublish())
button.onclick = function() {
var toPublish = document.querySelector(".HideAndSeekSpan.to-publish")
if(toPublish != null && toPublish.querySelector('input').checked) {
var author = document.querySelector('.header-nav-current-user').querySelector('strong').innerText
var files = loadData()[getPullRequestId()]['files'];
//check button and then check if they want to completes
var meta = { author: author, files: files };
var rawMeta = metaData(localStorageKey, meta)
document.querySelector('#pull_request_review_body').value = document.querySelector('#pull_request_review_body').value + "\n" + rawMeta;
}
}
}
}
}
Expand Down Expand Up @@ -81,31 +102,43 @@ function reportEveryone() {
}

function reportingBar() {
var sideBar = document.querySelector('#partial-discussion-sidebar');
if(sideBar != null && sideBar.querySelector('.HideAndSeekSpan') == null) {
var reportdiv = document.createElement('div');
reportdiv.className = 'discussion-sidebar-item HideAndSeekSpan';
var entireBar = document.createElement('div');
entireBar.style.width = "100%"
var tabnav = document.querySelector('.tabnav-extra');
if(tabnav != null && tabnav.querySelector('.HideAndSeekSpan.your-report') == null && tabnav.querySelector('.diffstat') != null) {
var reportSpan = document.createElement('span');
reportSpan.className = 'HideAndSeekSpan your-report';
// reportSpan.display = "block";

var entireBar = document.createElement('span');
entireBar.style.display = "inline-block";
entireBar.style.width = "100px"
entireBar.style.backgroundColor = "#ddd"
entireBar.style.height = "15px"
var completeBar = document.createElement('div');
entireBar.classList.add("tooltipped")
entireBar.classList.add("tooltipped-nw")

var completeBar = document.createElement('span');
completeBar.style.height = "15px"
completeBar.style.backgroundColor = "#4CAF50"
var divHeader = document.createElement('div');
divHeader.className = 'discussion-sidebar-heading text-bold';
divHeader.innerText = "Completeion %";
reportdiv.appendChild(divHeader);
reportdiv.appendChild(entireBar);
completeBar.style.display = "inline-block";

// var headerSpan = document.createElement('span');
// headerSpan.className = 'discussion-sidebar-heading text-bold';
reportSpan.appendChild(entireBar);
// reportSpan.appendChild(headerSpan);
entireBar.appendChild(completeBar);
sideBar.appendChild(reportdiv)
tabnav.prepend(reportSpan)

var files = loadData()[getPullRequestId()]["files"];
// var fileHeaders = document.querySelectorAll('.file-header');
var completedCount = Object.keys(files).length;
var totalCount = document.querySelector('#files_tab_counter').innerText;
var width = completedCount/totalCount;
completeBar.style.width = width*100 + "%";
completeBar.style.width = width * 100 + "%";
completeBar.classList.add("tooltipped")
completeBar.classList.add("tooltipped-nw")
completeBar.setAttribute("aria-label", "You have completed " + Math.floor(width * 100) + "% locally")
// completeBar.innerText = Math.floor(width * 100) + "%";
// completeBar.innerText = "You Completeion " + Math.floor(width * 100) + "%";
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Add the ability to remember completes files to a github pr.",
"manifest_version": 2,
"name": "Hide and Seek",
"version": "1.8",
"version": "1.9",
"homepage_url": "https://github.com/kyleroush/PR-Hide-And-Seek/",

"permissions": [
Expand Down

0 comments on commit 89bca88

Please sign in to comment.