diff --git a/contentscript.js b/contentscript.js index 9a755f5..2a9a844 100644 --- a/contentscript.js +++ b/contentscript.js @@ -22,7 +22,7 @@ function appendButtonToNav () { function resize () { var pageHeight = window.document.documentElement.clientHeight; var iframeHeight = pageHeight - contentHeight - 5; // -5 extra padding/margin - iframe.style.cssText = 'width:100%;height:' + iframeHeight + 'px;border:none'; + iframe.style.cssText = 'width:100%;height:' + iframeHeight + 'px;border:none;position:absolute;left:0;'; } // Replace content with board @@ -33,25 +33,35 @@ function appendContentToPage () { var repo = pathArray[1] var queryString = '?name=' + encodeURIComponent(name) + '&repo=' + encodeURIComponent(repo) - // Tab content element + // Remove GitHub body content contentElem = document.getElementsByClassName('repository-content')[0] - - // Clear contentElem for our content while (contentElem.firstChild) { contentElem.removeChild(contentElem.firstChild); } - // Set content height (as only header & footer are left on page now) + // Remove GitHub Footer + pageFooter = document.getElementsByClassName('site-footer-container')[0] + while (pageFooter.firstChild) { + pageFooter.removeChild(pageFooter.firstChild) + } + + // Zero-out uneeded margins + pageHeader = document.getElementsByClassName('pagehead')[0] + if (pageHeader) { + pageHeader.style.cssText = 'margin-bottom:0;' + } + + // Set content height (as only header is left on page now) contentHeight = document.body.clientHeight; - // Calculate height for iframe + // Calculate height for iframe (viewport minus contentHeight) var pageHeight = document.documentElement.clientHeight; var iframeHeight = pageHeight - contentHeight - 5; // -5 extra padding/margin // Create our content iframe = document.createElement('iframe'); iframe.src = chrome.runtime.getURL('frame/index.html' + queryString); - iframe.style.cssText = 'width:100%;height:' + iframeHeight + 'px;border:none'; + iframe.style.cssText = 'width:100%;height:' + iframeHeight + 'px;border:none;position:absolute;left:0;'; // Append our content to the content element contentElem.appendChild(iframe) diff --git a/frame/index.html b/frame/index.html index e3166a7..649b8fa 100644 --- a/frame/index.html +++ b/frame/index.html @@ -1,4 +1,19 @@ + -
+
+
+
diff --git a/frame/script.js b/frame/script.js index bb68bd0..fde553c 100644 --- a/frame/script.js +++ b/frame/script.js @@ -13,8 +13,18 @@ function generateIframe(queryObj) { var iframe = document.createElement('iframe') var iframe = document.createElement('iframe'); + iframe.id = 'fullpmIframe' iframe.src = 'https://staging-fullpm.wiredcraft.net/boards/' + queryObj.name + '/' + queryObj.repo; - iframe.style.cssText = 'width:100%;height:100%;border:none'; + iframe.style.cssText = 'width:1110px;height:100%;border:none;margin:0 auto;display:block;'; + + iframe.onload = function () { + // Timeout to allow time for fullpm webpage in iframe to render it's + // own loading spinner. Prevents a flash of nothing being shown + // The time value may need further adjustment + setTimeout(function () { + document.getElementById('loader').classList.add('hidden') + }, 1000) + } return iframe }; @@ -22,3 +32,4 @@ function generateIframe(queryObj) { var iframe = generateIframe(getJsonFromUrl()) var fullpm = document.getElementById('fullpm') fullpm.appendChild(iframe) +// document.getElementById('fullpmIframe').onload = function ()