diff --git a/public/index.html b/public/index.html index 4d3c7ba..652396f 100644 --- a/public/index.html +++ b/public/index.html @@ -81,11 +81,11 @@

GitHub Contribution Graph Customizer

- +
-
+
@@ -93,11 +93,6 @@

GitHub Contribution Graph Customizer

-

git commit --allow-empty --date="27 Oct 2022" --allow-empty-message -m "" &&

-

git commit --allow-empty --date="28 Oct 2022" --allow-empty-message -m "" &&

-

git commit --allow-empty --date="29 Oct 2022" --allow-empty-message -m "" &&

-

git commit --allow-empty --date="30 Oct 2022" --allow-empty-message -m "" &&

-

git commit --allow-empty --date="31 Oct 2022" --allow-empty-message -m ""

diff --git a/public/index.js b/public/index.js index 3ee1d26..0eb2627 100644 --- a/public/index.js +++ b/public/index.js @@ -41,7 +41,7 @@ document.addEventListener("DOMContentLoaded", function () { if (currentDate.getFullYear() < startDate.getFullYear()) { square.classList.add("previous-year"); } - + dateforgitlist = []; squaresContainer.appendChild(square); if (!square.classList.contains("previous-year")) { @@ -50,9 +50,9 @@ document.addEventListener("DOMContentLoaded", function () { const options = { year: "numeric", month: "short", day: "numeric" }; dateforgit = new Date(square.getAttribute("data-date")).toLocaleDateString("en", options); dateforgitlist.push(dateforgit); - console.log("dateforgit:",dateforgit); - console.log("dateforgitlist: ",dateforgitlist); - + console.log("dateforgit:", dateforgit); + console.log("dateforgitlist: ", dateforgitlist); + increaseLevel(square, currentLevel); }); @@ -66,8 +66,8 @@ document.addEventListener("DOMContentLoaded", function () { if (index > -1) { dateforgitlist.splice(index, 1); } - console.log("dateforgit:",dateforgit); - console.log("dateforgitlist: ",dateforgitlist); + console.log("dateforgit:", dateforgit); + console.log("dateforgitlist: ", dateforgitlist); }); square.addEventListener("mouseover", function (event) { @@ -103,3 +103,52 @@ document.addEventListener("DOMContentLoaded", function () { } } }); + +function generateCode() { + const dateList = dateforgitlist; + if (dateList.length === 0) { + alert("Don't try to play a fool with me Nikesh!"); + return; + } + const codeContainer = document.querySelector(".code"); + codeContainer.innerHTML = ""; + + dateList.forEach(date => { + const codeLine = document.createElement("p"); + codeLine.innerHTML = ` git commit --allow-empty --date="${date}" --allow-empty-message -m "" &&`; + codeContainer.appendChild(codeLine); + + }); + + if (codeContainer.lastElementChild) { + lastLine = codeContainer.lastElementChild; + lastLine.removeChild(lastLine.lastElementChild); + } + + const codeContainerElement = document.querySelector(".code-container"); + codeContainerElement.style.display = "block"; +} + +function copyCode() { + const codeContainer = document.querySelector(".code"); + const codeValue = codeContainer.innerText; + const codeText = document.createElement('textarea'); + codeText.value = codeValue; + document.body.appendChild(codeText); + + codeText.select(); + codeText.setSelectionRange(0, 99999); // For mobile devices + navigator.clipboard.writeText(codeText.value); + document.body.removeChild(codeText); + + const codeHeader = document.querySelector(".code-header"); + const codeIcon = codeHeader.querySelector(".code-icon"); + codeIcon.setAttribute("fill", "#26a641"); + codeIcon.innerHTML = ``; + + setTimeout(function () { + codeIcon.setAttribute("fill", "#26a641"); + codeIcon.innerHTML = ``; + }, 3000); + +} \ No newline at end of file diff --git a/public/style.css b/public/style.css index 1241f91..4afd988 100644 --- a/public/style.css +++ b/public/style.css @@ -64,7 +64,8 @@ h2 { } .generate-btn { - float: right; + display: block; + margin-left: auto; padding: 8px; font-weight: 600; border: #0e4429 1px solid; @@ -159,6 +160,7 @@ li { } .code-container { + display: none; margin-top: 1rem; margin-bottom: 1rem; max-width: 600px;